[INSTALL] Minor reformatting and modernization. Shouldn't change functionality significatively.
This commit is contained in:
parent
7d262ad50b
commit
893bafa14b
@ -1,76 +1,88 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009-2010, StatusNet, Inc.
|
||||
* Installation lib
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Installation
|
||||
* @package Installation
|
||||
*
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brett Taylor <brett@webfroot.co.nz>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Eric Helgeson <helfire@Erics-MBP.local>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009-2010 StatusNet, Inc http://status.net
|
||||
* @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
* @version 1.0.x
|
||||
* @link http://status.net
|
||||
* @package Installation
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brett Taylor <brett@webfroot.co.nz>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Eric Helgeson <helfire@Erics-MBP.local>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
abstract class Installer
|
||||
{
|
||||
/** Web site info */
|
||||
public $sitename, $server, $path, $fancy, $siteProfile, $ssl;
|
||||
public $sitename;
|
||||
public $server;
|
||||
public $path;
|
||||
public $fancy;
|
||||
public $siteProfile;
|
||||
public $ssl;
|
||||
/** DB info */
|
||||
public $host, $database, $dbtype, $username, $password, $db;
|
||||
public $host;
|
||||
public $database;
|
||||
public $dbtype;
|
||||
public $username;
|
||||
public $password;
|
||||
public $db;
|
||||
/** Storage info */
|
||||
public $avatarDir, $fileDir;
|
||||
public $avatarDir;
|
||||
public $fileDir;
|
||||
/** Administrator info */
|
||||
public $adminNick, $adminPass, $adminEmail;
|
||||
public $adminNick;
|
||||
public $adminPass;
|
||||
public $adminEmail;
|
||||
/** Should we skip writing the configuration file? */
|
||||
public $skipConfig = false;
|
||||
|
||||
public static $dbModules = array(
|
||||
'mysql' => array(
|
||||
public static $dbModules = [
|
||||
'mysql' => [
|
||||
'name' => 'MariaDB 10.3+',
|
||||
'check_module' => 'mysqli',
|
||||
'scheme' => 'mysqli', // DSN prefix for PEAR::DB
|
||||
),
|
||||
/* 'pgsql' => array(
|
||||
],
|
||||
/*'pgsql' => [
|
||||
'name' => 'PostgreSQL',
|
||||
'check_module' => 'pgsql',
|
||||
'scheme' => 'pgsql', // DSN prefix for PEAR::DB
|
||||
),*/
|
||||
);
|
||||
]*/
|
||||
];
|
||||
|
||||
/**
|
||||
* Attempt to include a PHP file and report if it worked, while
|
||||
* suppressing the annoying warning messages on failure.
|
||||
* @param string $filename
|
||||
* @return bool
|
||||
*/
|
||||
private function haveIncludeFile($filename) {
|
||||
private function haveIncludeFile(string $filename): bool
|
||||
{
|
||||
$old = error_reporting(error_reporting() & ~E_WARNING);
|
||||
$ok = include_once($filename);
|
||||
error_reporting($old);
|
||||
@ -80,13 +92,13 @@ abstract class Installer
|
||||
/**
|
||||
* Check if all is ready for installation
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
function checkPrereqs()
|
||||
public function checkPrereqs(): bool
|
||||
{
|
||||
$pass = true;
|
||||
|
||||
$config = INSTALLDIR.'/config.php';
|
||||
$config = INSTALLDIR . '/config.php';
|
||||
if (!$this->skipConfig && file_exists($config)) {
|
||||
if (!is_writable($config) || filesize($config) > 0) {
|
||||
if (filesize($config) == 0) {
|
||||
@ -103,20 +115,19 @@ abstract class Installer
|
||||
$pass = false;
|
||||
}
|
||||
|
||||
$reqs = array('gd', 'curl', 'intl', 'json',
|
||||
'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml');
|
||||
|
||||
$reqs = ['bcmath', 'curl', 'dom', 'gd', 'intl', 'json', 'mbstring', 'openssl', 'simplexml', 'xml', 'xmlwriter'];
|
||||
foreach ($reqs as $req) {
|
||||
if (!$this->checkExtension($req)) {
|
||||
// Checks if a php extension is both installed and loaded
|
||||
if (!extension_loaded($req)) {
|
||||
$this->warning(sprintf('Cannot load required extension: <code>%s</code>', $req));
|
||||
$pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we have at least one database module available
|
||||
$missingExtensions = array();
|
||||
$missingExtensions = [];
|
||||
foreach (self::$dbModules as $type => $info) {
|
||||
if (!$this->checkExtension($info['check_module'])) {
|
||||
if (!extension_loaded($info['check_module'])) {
|
||||
$missingExtensions[] = $info['check_module'];
|
||||
}
|
||||
}
|
||||
@ -129,8 +140,10 @@ abstract class Installer
|
||||
|
||||
// @fixme this check seems to be insufficient with Windows ACLs
|
||||
if (!$this->skipConfig && !is_writable(INSTALLDIR)) {
|
||||
$this->warning(sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
|
||||
sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR));
|
||||
$this->warning(
|
||||
sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
|
||||
sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR)
|
||||
);
|
||||
$pass = false;
|
||||
}
|
||||
|
||||
@ -140,22 +153,29 @@ abstract class Installer
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true);
|
||||
require_once INSTALLDIR . '/lib/language.php';
|
||||
$_server=$this->server; $_path=$this->path; // We won't be using those so it's safe to do this small hack
|
||||
require_once INSTALLDIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'util.php';
|
||||
require_once INSTALLDIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'default.php';
|
||||
$fileSubdirs = [empty($this->avatarDir) ? $default['avatar']['dir'] : $this->avatarDir,
|
||||
empty($this->fileDir) ? $default['attachments']['dir'] : $this->fileDir];
|
||||
$_server = $this->server;
|
||||
$_path = $this->path; // We won't be using those so it's safe to do this small hack
|
||||
require_once INSTALLDIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'util.php';
|
||||
require_once INSTALLDIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'default.php';
|
||||
$fileSubdirs = [
|
||||
empty($this->avatarDir) ? $default['avatar']['dir'] : $this->avatarDir,
|
||||
empty($this->fileDir) ? $default['attachments']['dir'] : $this->fileDir
|
||||
];
|
||||
unset($default);
|
||||
foreach ($fileSubdirs as $fileFullPath) {
|
||||
if (!file_exists($fileFullPath)) {
|
||||
$pass = $pass && mkdir($fileFullPath);
|
||||
} elseif (!is_dir($fileFullPath)) {
|
||||
$this->warning(sprintf('GNU social expected a directory but found something else on this path: %s', $fileFullPath),
|
||||
'Either make sure it goes to a directory or remove it and a directory will be created.');
|
||||
$this->warning(
|
||||
sprintf('GNU social expected a directory but found something else on this path: %s', $fileFullPath),
|
||||
'Either make sure it goes to a directory or remove it and a directory will be created.'
|
||||
);
|
||||
$pass = false;
|
||||
} elseif (!is_writable($fileFullPath)) {
|
||||
$this->warning(sprintf('Cannot write to %s directory: <code>%s</code>', $fileSubdir, $fileFullPath),
|
||||
sprintf('On your server, try this command: <code>chmod a+w %s</code>', $fileFullPath));
|
||||
$this->warning(
|
||||
sprintf('Cannot write to directory: <code>%s</code>', $fileFullPath),
|
||||
sprintf('On your server, try this command: <code>chmod a+w %s</code>', $fileFullPath)
|
||||
);
|
||||
$pass = false;
|
||||
}
|
||||
}
|
||||
@ -164,36 +184,12 @@ abstract class Installer
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a php extension is both installed and loaded
|
||||
*
|
||||
* @param string $name of extension to check
|
||||
*
|
||||
* @return boolean whether extension is installed and loaded
|
||||
*/
|
||||
function checkExtension($name)
|
||||
{
|
||||
if (extension_loaded($name)) {
|
||||
return true;
|
||||
} elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
|
||||
// dl will throw a fatal error if it's disabled or we're in safe mode.
|
||||
// More fun, it may not even exist under some SAPIs in 5.3.0 or later...
|
||||
$soname = $name . '.' . PHP_SHLIB_SUFFIX;
|
||||
if (PHP_SHLIB_SUFFIX == 'dll') {
|
||||
$soname = "php_" . $soname;
|
||||
}
|
||||
return @dl($soname);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic validation on the database paramters
|
||||
* Basic validation on the database parameters
|
||||
* Side effects: error output if not valid
|
||||
*
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function validateDb()
|
||||
public function validateDb(): bool
|
||||
{
|
||||
$fail = false;
|
||||
|
||||
@ -221,12 +217,12 @@ abstract class Installer
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic validation on the administrator user paramters
|
||||
* Basic validation on the administrator user parameters
|
||||
* Side effects: error output if not valid
|
||||
*
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function validateAdmin()
|
||||
public function validateAdmin(): bool
|
||||
{
|
||||
$fail = false;
|
||||
|
||||
@ -236,15 +232,16 @@ abstract class Installer
|
||||
}
|
||||
if ($this->adminNick && !preg_match('/^[0-9a-z]{1,64}$/', $this->adminNick)) {
|
||||
$this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
|
||||
'" is invalid; should be plain letters and numbers no longer than 64 characters.', true);
|
||||
'" is invalid; should be plain letters and numbers no longer than 64 characters.', true);
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
// @fixme hardcoded list; should use Nickname::isValid()
|
||||
// if/when it's safe to have loaded the infrastructure here
|
||||
$blacklist = array('main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook', 'activity');
|
||||
$blacklist = ['main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook', 'activity'];
|
||||
if (in_array($this->adminNick, $blacklist)) {
|
||||
$this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
|
||||
'" is reserved.', true);
|
||||
'" is reserved.', true);
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
@ -259,11 +256,11 @@ abstract class Installer
|
||||
/**
|
||||
* Make sure a site profile was selected
|
||||
*
|
||||
* @return type boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function validateSiteProfile()
|
||||
public function validateSiteProfile(): bool
|
||||
{
|
||||
if (empty($this->siteProfile)) {
|
||||
if (empty($this->siteProfile)) {
|
||||
$this->updateStatus("No site profile selected.", true);
|
||||
return false;
|
||||
}
|
||||
@ -277,8 +274,9 @@ abstract class Installer
|
||||
*
|
||||
* @fixme escape things in the connection string in case we have a funny pass etc
|
||||
* @return mixed array of database connection params on success, false on failure
|
||||
* @throws Exception
|
||||
*/
|
||||
function setupDatabase()
|
||||
public function setupDatabase()
|
||||
{
|
||||
if ($this->db) {
|
||||
throw new Exception("Bad order of operations: DB already set up.");
|
||||
@ -302,15 +300,17 @@ abstract class Installer
|
||||
}
|
||||
|
||||
// ensure database encoding is UTF8
|
||||
$conn->query('SET NAMES utf8mb4');
|
||||
if ($this->dbtype == 'mysql') {
|
||||
// @fixme utf8m4 support for mysql 5.5?
|
||||
// Force the comms charset to utf8 for sanity
|
||||
// This doesn't currently work. :P
|
||||
//$conn->executes('set names utf8');
|
||||
} else if ($this->dbtype == 'pgsql') {
|
||||
$record = $conn->getRow('SHOW server_encoding');
|
||||
if ($record->server_encoding != 'UTF8') {
|
||||
$this->updateStatus("GNU social requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
|
||||
$server_encoding = $conn->getRow("SHOW VARIABLES LIKE 'character_set_server'")[1];
|
||||
if ($server_encoding != 'utf8mb4') {
|
||||
$this->updateStatus("GNU social requires UTF8 character encoding. Your database is " . htmlentities($server_encoding));
|
||||
return false;
|
||||
}
|
||||
} elseif ($this->dbtype == 'pgsql') {
|
||||
$server_encoding = $conn->getRow('SHOW server_encoding')[0];
|
||||
if ($server_encoding != 'UTF8') {
|
||||
$this->updateStatus("GNU social requires UTF8 character encoding. Your database is " . htmlentities($server_encoding));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -321,29 +321,29 @@ abstract class Installer
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (array('sms_carrier' => 'SMS carrier',
|
||||
'notice_source' => 'notice source',
|
||||
'foreign_services' => 'foreign service')
|
||||
as $scr => $name) {
|
||||
foreach (['sms_carrier' => 'SMS carrier',
|
||||
'notice_source' => 'notice source',
|
||||
'foreign_services' => 'foreign service']
|
||||
as $scr => $name) {
|
||||
$this->updateStatus(sprintf("Adding %s data to database...", $name));
|
||||
$res = $this->runDbScript($scr.'.sql', $conn);
|
||||
$res = $this->runDbScript($scr . '.sql', $conn);
|
||||
if ($res === false) {
|
||||
$this->updateStatus(sprintf("Can't run %s script.", $name), true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db = array('type' => $this->dbtype, 'database' => $dsn);
|
||||
$db = ['type' => $this->dbtype, 'database' => $dsn];
|
||||
return $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a connection to the database.
|
||||
*
|
||||
* @param <type> $dsn
|
||||
* @return <type>
|
||||
* @param string $dsn
|
||||
* @return DB|DB_Error
|
||||
*/
|
||||
function connectDatabase($dsn)
|
||||
public function connectDatabase(string $dsn)
|
||||
{
|
||||
global $_DB;
|
||||
return $_DB->connect($dsn);
|
||||
@ -353,8 +353,9 @@ abstract class Installer
|
||||
* Create core tables on the given database connection.
|
||||
*
|
||||
* @param DB_common $conn
|
||||
* @return bool
|
||||
*/
|
||||
function createCoreTables(DB_common $conn)
|
||||
public function createCoreTables(DB_common $conn): bool
|
||||
{
|
||||
$schema = Schema::get($conn);
|
||||
$tableDefs = $this->getCoreSchema();
|
||||
@ -372,9 +373,9 @@ abstract class Installer
|
||||
*
|
||||
* @return array of table names => table def arrays
|
||||
*/
|
||||
function getCoreSchema()
|
||||
public function getCoreSchema(): array
|
||||
{
|
||||
$schema = array();
|
||||
$schema = [];
|
||||
include INSTALLDIR . '/db/core.php';
|
||||
return $schema;
|
||||
}
|
||||
@ -386,7 +387,7 @@ abstract class Installer
|
||||
* @param mixed $val
|
||||
* @return string
|
||||
*/
|
||||
function phpVal($val)
|
||||
public function phpVal($val): string
|
||||
{
|
||||
return var_export($val, true);
|
||||
}
|
||||
@ -395,63 +396,63 @@ abstract class Installer
|
||||
* Return an array of parseable PHP literal for the given values.
|
||||
* These will include quotes for strings, etc.
|
||||
*
|
||||
* @param mixed $val
|
||||
* @param mixed $map
|
||||
* @return array
|
||||
*/
|
||||
function phpVals($map)
|
||||
public function phpVals($map): array
|
||||
{
|
||||
return array_map(array($this, 'phpVal'), $map);
|
||||
return array_map([$this, 'phpVal'], $map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a stock configuration file.
|
||||
*
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*
|
||||
* @fixme escape variables in output in case we have funny chars, apostrophes etc
|
||||
*/
|
||||
function writeConf()
|
||||
public function writeConf(): bool
|
||||
{
|
||||
$vals = $this->phpVals(array(
|
||||
$vals = $this->phpVals([
|
||||
'sitename' => $this->sitename,
|
||||
'server' => $this->server,
|
||||
'path' => $this->path,
|
||||
'ssl' => in_array($this->ssl, array('never', 'always'))
|
||||
? $this->ssl
|
||||
: 'never',
|
||||
'ssl' => in_array($this->ssl, ['never', 'always'])
|
||||
? $this->ssl
|
||||
: 'never',
|
||||
'db_database' => $this->db['database'],
|
||||
'db_type' => $this->db['type']
|
||||
));
|
||||
]);
|
||||
|
||||
// assemble configuration file in a string
|
||||
$cfg = "<?php\n".
|
||||
"if (!defined('GNUSOCIAL')) { exit(1); }\n\n".
|
||||
$cfg = "<?php\n" .
|
||||
"if (!defined('GNUSOCIAL')) { exit(1); }\n\n" .
|
||||
|
||||
// site name
|
||||
"\$config['site']['name'] = {$vals['sitename']};\n\n".
|
||||
// site name
|
||||
"\$config['site']['name'] = {$vals['sitename']};\n\n" .
|
||||
|
||||
// site location
|
||||
"\$config['site']['server'] = {$vals['server']};\n".
|
||||
"\$config['site']['path'] = {$vals['path']}; \n\n".
|
||||
"\$config['site']['ssl'] = {$vals['ssl']}; \n\n".
|
||||
// site location
|
||||
"\$config['site']['server'] = {$vals['server']};\n" .
|
||||
"\$config['site']['path'] = {$vals['path']}; \n\n" .
|
||||
"\$config['site']['ssl'] = {$vals['ssl']}; \n\n" .
|
||||
|
||||
// checks if fancy URLs are enabled
|
||||
($this->fancy ? "\$config['site']['fancy'] = true;\n\n":'').
|
||||
// checks if fancy URLs are enabled
|
||||
($this->fancy ? "\$config['site']['fancy'] = true;\n\n" : '') .
|
||||
|
||||
// database
|
||||
"\$config['db']['database'] = {$vals['db_database']};\n\n".
|
||||
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
|
||||
"\$config['db']['type'] = {$vals['db_type']};\n\n".
|
||||
// database
|
||||
"\$config['db']['database'] = {$vals['db_database']};\n\n" .
|
||||
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n" : '') .
|
||||
"\$config['db']['type'] = {$vals['db_type']};\n\n" .
|
||||
|
||||
"// Uncomment below for better performance. Just remember you must run\n".
|
||||
"// php scripts/checkschema.php whenever your enabled plugins change!\n".
|
||||
"//\$config['db']['schemacheck'] = 'script';\n\n";
|
||||
"// Uncomment below for better performance. Just remember you must run\n" .
|
||||
"// php scripts/checkschema.php whenever your enabled plugins change!\n" .
|
||||
"//\$config['db']['schemacheck'] = 'script';\n\n";
|
||||
|
||||
// Normalize line endings for Windows servers
|
||||
$cfg = str_replace("\n", PHP_EOL, $cfg);
|
||||
|
||||
// write configuration file out to install directory
|
||||
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg);
|
||||
$res = file_put_contents(INSTALLDIR . '/config.php', $cfg);
|
||||
|
||||
return $res;
|
||||
}
|
||||
@ -465,16 +466,16 @@ abstract class Installer
|
||||
*
|
||||
* @return int res number of bytes written
|
||||
*/
|
||||
function writeSiteProfile()
|
||||
public function writeSiteProfile(): int
|
||||
{
|
||||
$vals = $this->phpVals(array(
|
||||
$vals = $this->phpVals([
|
||||
'site_profile' => $this->siteProfile,
|
||||
'nickname' => $this->adminNick
|
||||
));
|
||||
]);
|
||||
|
||||
$cfg =
|
||||
// site profile
|
||||
"\$config['site']['profile'] = {$vals['site_profile']};\n";
|
||||
// site profile
|
||||
"\$config['site']['profile'] = {$vals['site_profile']};\n";
|
||||
|
||||
if ($this->siteProfile == "singleuser") {
|
||||
$cfg .= "\$config['singleuser']['nickname'] = {$vals['nickname']};\n\n";
|
||||
@ -486,7 +487,7 @@ abstract class Installer
|
||||
$cfg = str_replace("\n", PHP_EOL, $cfg);
|
||||
|
||||
// write configuration file out to install directory
|
||||
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg, FILE_APPEND);
|
||||
$res = file_put_contents(INSTALLDIR . '/config.php', $cfg, FILE_APPEND);
|
||||
|
||||
return $res;
|
||||
}
|
||||
@ -494,12 +495,12 @@ abstract class Installer
|
||||
/**
|
||||
* Install schema into the database
|
||||
*
|
||||
* @param string $filename location of database schema file
|
||||
* @param DB_common $conn connection to database
|
||||
* @param string $filename location of database schema file
|
||||
* @param DB_common $conn connection to database
|
||||
*
|
||||
* @return boolean - indicating success or failure
|
||||
* @return bool - indicating success or failure
|
||||
*/
|
||||
function runDbScript($filename, DB_common $conn)
|
||||
public function runDbScript(string $filename, DB_common $conn): bool
|
||||
{
|
||||
$sql = trim(file_get_contents(INSTALLDIR . '/db/' . $filename));
|
||||
$stmts = explode(';', $sql);
|
||||
@ -509,7 +510,7 @@ abstract class Installer
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$res = $conn->simpleQuery($stmt);
|
||||
$res = $conn->query($stmt);
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$this->updateStatus("ERROR ($error) for SQL '$stmt'");
|
||||
@ -524,16 +525,16 @@ abstract class Installer
|
||||
* Side effect: may load portions of GNU social framework.
|
||||
* Side effect: outputs program info
|
||||
*/
|
||||
function registerInitialUser()
|
||||
public function registerInitialUser(): bool
|
||||
{
|
||||
// initalize hostname from install arguments, so it can be used to find
|
||||
// the /etc config file from the commandline installer
|
||||
$server = $this->server;
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
$data = array('nickname' => $this->adminNick,
|
||||
'password' => $this->adminPass,
|
||||
'fullname' => $this->adminNick);
|
||||
$data = ['nickname' => $this->adminNick,
|
||||
'password' => $this->adminPass,
|
||||
'fullname' => $this->adminNick];
|
||||
if ($this->adminEmail) {
|
||||
$data['email'] = $this->adminEmail;
|
||||
}
|
||||
@ -558,9 +559,9 @@ abstract class Installer
|
||||
*
|
||||
* Prerequisites: validation of input data.
|
||||
*
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function doInstall()
|
||||
public function doInstall(): bool
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -595,8 +596,8 @@ abstract class Installer
|
||||
}
|
||||
|
||||
if (!$this->skipConfig) {
|
||||
// Make sure we can write to the file twice
|
||||
$oldUmask = umask(000);
|
||||
// Make sure we can write to the file twice
|
||||
$oldUmask = umask(000);
|
||||
|
||||
$this->updateStatus("Writing config file...");
|
||||
$res = $this->writeConf();
|
||||
@ -631,18 +632,18 @@ abstract class Installer
|
||||
return false;
|
||||
}
|
||||
|
||||
// Restore original umask
|
||||
umask($oldUmask);
|
||||
// Set permissions back to something decent
|
||||
chmod(INSTALLDIR.'/config.php', 0644);
|
||||
// Restore original umask
|
||||
umask($oldUmask);
|
||||
// Set permissions back to something decent
|
||||
chmod(INSTALLDIR . '/config.php', 0644);
|
||||
}
|
||||
|
||||
|
||||
$scheme = $this->ssl === 'always' ? 'https' : 'http';
|
||||
$link = "{$scheme}://{$this->server}/{$this->path}";
|
||||
|
||||
$this->updateStatus("GNU social has been installed at $link");
|
||||
$this->updateStatus(
|
||||
'<strong>DONE!</strong> You can visit your <a href="'.htmlspecialchars($link).'">new GNU social site</a> (log in as "'.htmlspecialchars($this->adminNick).'"). If this is your first GNU social install, make your experience the best possible by visiting our resource site to join the <a href="https://gnu.io/social/resources/">mailing list or IRC</a>. <a href="'.htmlspecialchars($link).'/doc/faq">FAQ is found here</a>.'
|
||||
'<strong>DONE!</strong> You can visit your <a href="' . htmlspecialchars($link) . '">new GNU social site</a> (log in as "' . htmlspecialchars($this->adminNick) . '"). If this is your first GNU social install, make your experience the best possible by visiting our resource site to join the <a href="https://gnu.io/social/resources/">mailing list or IRC</a>. <a href="' . htmlspecialchars($link) . '/doc/faq">FAQ is found here</a>.'
|
||||
);
|
||||
|
||||
return true;
|
||||
@ -653,13 +654,12 @@ abstract class Installer
|
||||
* @param string $message HTML ok, but should be plaintext-able
|
||||
* @param string $submessage HTML ok, but should be plaintext-able
|
||||
*/
|
||||
abstract function warning($message, $submessage='');
|
||||
abstract public function warning(string $message, string $submessage = '');
|
||||
|
||||
/**
|
||||
* Output an install-time progress message
|
||||
* @param string $message HTML ok, but should be plaintext-able
|
||||
* @param boolean $error true if this should be marked as an error condition
|
||||
* @param string $status HTML ok, but should be plaintext-able
|
||||
* @param bool $error true if this should be marked as an error condition
|
||||
*/
|
||||
abstract function updateStatus($status, $error=false);
|
||||
|
||||
abstract public function updateStatus(string $status, bool $error = false);
|
||||
}
|
||||
|
@ -1,57 +1,56 @@
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009-2010, StatusNet, Inc.
|
||||
* Web Installer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Installation
|
||||
* @package Installation
|
||||
*
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brett Taylor <brett@webfroot.co.nz>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Eric Helgeson <helfire@Erics-MBP.local>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
* @version 0.9.x
|
||||
* @link http://status.net
|
||||
* @package Installation
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Brett Taylor <brett@webfroot.co.nz>
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author CiaranG <ciaran@ciarang.com>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Eric Helgeson <helfire@Erics-MBP.local>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', __DIR__);
|
||||
define('INSTALLDIR', dirname(__DIR__));
|
||||
|
||||
require dirname(INSTALLDIR) . '/lib/installer.php';
|
||||
require INSTALLDIR . '/lib/installer.php';
|
||||
|
||||
/**
|
||||
* Helper class for building form
|
||||
*/
|
||||
class Posted {
|
||||
class Posted
|
||||
{
|
||||
/**
|
||||
* HTML-friendly escaped string for the POST param of given name, or empty.
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function value($name)
|
||||
public function value(string $name): string
|
||||
{
|
||||
return htmlspecialchars($this->string($name));
|
||||
}
|
||||
@ -63,7 +62,7 @@ class Posted {
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function string($name)
|
||||
public function string(string $name): string
|
||||
{
|
||||
return strval($this->raw($name));
|
||||
}
|
||||
@ -76,7 +75,7 @@ class Posted {
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
function raw($name)
|
||||
public function raw(string $name)
|
||||
{
|
||||
if (isset($_POST[$name])) {
|
||||
return $this->dequote($_POST[$name]);
|
||||
@ -91,13 +90,13 @@ class Posted {
|
||||
* @param mixed $val
|
||||
* @return mixed
|
||||
*/
|
||||
function dequote($val)
|
||||
public function dequote($val)
|
||||
{
|
||||
if (get_magic_quotes_gpc()) {
|
||||
if (is_string($val)) {
|
||||
return stripslashes($val);
|
||||
} else if (is_array($val)) {
|
||||
return array_map(array($this, 'dequote'), $val);
|
||||
} elseif (is_array($val)) {
|
||||
return array_map([$this, 'dequote'], $val);
|
||||
}
|
||||
}
|
||||
return $val;
|
||||
@ -115,7 +114,7 @@ class WebInstaller extends Installer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function main()
|
||||
public function main()
|
||||
{
|
||||
if (!$this->checkPrereqs()) {
|
||||
$this->warning(_('Please fix the above stated problems and refresh this page to continue installing.'));
|
||||
@ -131,8 +130,10 @@ class WebInstaller extends Installer
|
||||
|
||||
/**
|
||||
* Web implementation of warning output
|
||||
* @param string $message
|
||||
* @param string $submessage
|
||||
*/
|
||||
function warning($message, $submessage='')
|
||||
public function warning(string $message, string $submessage = '')
|
||||
{
|
||||
print "<p class=\"error\">$message</p>\n";
|
||||
if ($submessage != '') {
|
||||
@ -142,43 +143,48 @@ class WebInstaller extends Installer
|
||||
|
||||
/**
|
||||
* Web implementation of status output
|
||||
* @param string $status
|
||||
* @param bool $error
|
||||
*/
|
||||
function updateStatus($status, $error=false)
|
||||
public function updateStatus(string $status, bool $error = false)
|
||||
{
|
||||
echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
|
||||
echo '<li' . ($error ? ' class="error"' : '') . ">$status</li>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the web form!
|
||||
*/
|
||||
function showForm()
|
||||
public function showForm()
|
||||
{
|
||||
global $dbModules;
|
||||
$post = new Posted();
|
||||
$dbRadios = '';
|
||||
$dbtype = $post->raw('dbtype');
|
||||
foreach (self::$dbModules as $type => $info) {
|
||||
if ($this->checkExtension($info['check_module'])) {
|
||||
if (extension_loaded($info['check_module'])) {
|
||||
if ($dbtype == null || $dbtype == $type) {
|
||||
$checked = 'checked="checked" ';
|
||||
$dbtype = $type; // if we didn't have one checked, hit the first
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$dbRadios .= sprintf('<input type="radio" name="dbtype" id="dbtype-%1$s" value="%1$s" %2$s/>%3$s<br />',
|
||||
htmlspecialchars($type), $checked,
|
||||
htmlspecialchars($info['name']));
|
||||
$dbRadios .= sprintf(
|
||||
'<input type="radio" name="dbtype" id="dbtype-%1$s" value="%1$s" %2$s/>%3$s<br>',
|
||||
htmlspecialchars($type),
|
||||
$checked,
|
||||
htmlspecialchars($info['name'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$ssl = array('always'=>null, 'never'=>null);
|
||||
$ssl = ['always' => null, 'never' => null];
|
||||
if (!empty($_SERVER['HTTPS'])) {
|
||||
$ssl['always'] = 'checked="checked"';
|
||||
} else {
|
||||
$ssl['never'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
echo<<<E_O_T
|
||||
echo <<<E_O_T
|
||||
<form method="post" action="install.php" class="form_settings" id="form_install">
|
||||
<fieldset>
|
||||
<fieldset id="settings_site">
|
||||
@ -186,19 +192,19 @@ class WebInstaller extends Installer
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="sitename">Site name</label>
|
||||
<input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
|
||||
<input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}">
|
||||
<p class="form_guide">The name of your site</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="fancy-enable">Fancy URLs</label>
|
||||
<input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
|
||||
<input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
|
||||
<input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked'> enable<br>
|
||||
<input type="radio" name="fancy" id="fancy-disable" value=""> disable<br>
|
||||
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="ssl">Server SSL</label>
|
||||
<input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']} /> enable<br />
|
||||
<input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']} /> disable<br />
|
||||
<input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']}> enable<br>
|
||||
<input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']}> disable<br>
|
||||
<p class="form_guide" id="ssl-form_guide">Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.</p>
|
||||
</li>
|
||||
</ul>
|
||||
@ -209,7 +215,7 @@ class WebInstaller extends Installer
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="host">Hostname</label>
|
||||
<input type="text" id="host" name="host" value="{$post->value('host')}" />
|
||||
<input type="text" id="host" name="host" value="{$post->value('host')}">
|
||||
<p class="form_guide">Database hostname</p>
|
||||
</li>
|
||||
<li>
|
||||
@ -219,17 +225,17 @@ class WebInstaller extends Installer
|
||||
</li>
|
||||
<li>
|
||||
<label for="database">Name</label>
|
||||
<input type="text" id="database" name="database" value="{$post->value('database')}" />
|
||||
<input type="text" id="database" name="database" value="{$post->value('database')}">
|
||||
<p class="form_guide">Database name</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="dbusername">DB username</label>
|
||||
<input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
|
||||
<input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}">
|
||||
<p class="form_guide">Database username</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="dbpassword">DB password</label>
|
||||
<input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
|
||||
<input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}">
|
||||
<p class="form_guide">Database password (optional)</p>
|
||||
</li>
|
||||
</ul>
|
||||
@ -240,21 +246,21 @@ class WebInstaller extends Installer
|
||||
<ul class="form_data">
|
||||
<li>
|
||||
<label for="admin_nickname">Administrator nickname</label>
|
||||
<input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
|
||||
<input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}">
|
||||
<p class="form_guide">Nickname for the initial user (administrator)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_password">Administrator password</label>
|
||||
<input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
|
||||
<input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}">
|
||||
<p class="form_guide">Password for the initial user (administrator)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_password2">Confirm password</label>
|
||||
<input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
|
||||
<input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}">
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_email">Administrator e-mail</label>
|
||||
<input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
|
||||
<input id="admin_email" name="admin_email" value="{$post->value('admin_email')}">
|
||||
<p class="form_guide">Optional email address for the initial user (administrator)</p>
|
||||
</li>
|
||||
</ul>
|
||||
@ -274,7 +280,7 @@ class WebInstaller extends Installer
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||
<input type="submit" name="submit" class="submit" value="Submit">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
@ -285,7 +291,7 @@ E_O_T;
|
||||
* Handle a POST submission... if we have valid input, start the install!
|
||||
* Otherwise shows the form along with any error messages.
|
||||
*/
|
||||
function handlePost()
|
||||
public function handlePost()
|
||||
{
|
||||
echo <<<STR
|
||||
<dl class="system_notice">
|
||||
@ -311,23 +317,23 @@ STR;
|
||||
* Read and validate input data.
|
||||
* May output side effects.
|
||||
*
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function prepare()
|
||||
public function prepare(): bool
|
||||
{
|
||||
$post = new Posted();
|
||||
$this->host = $post->string('host');
|
||||
$this->dbtype = $post->string('dbtype');
|
||||
$this->host = $post->string('host');
|
||||
$this->dbtype = $post->string('dbtype');
|
||||
$this->database = $post->string('database');
|
||||
$this->username = $post->string('dbusername');
|
||||
$this->password = $post->string('dbpassword');
|
||||
$this->sitename = $post->string('sitename');
|
||||
$this->fancy = (bool)$post->string('fancy');
|
||||
$this->fancy = (bool)$post->string('fancy');
|
||||
|
||||
$this->adminNick = strtolower($post->string('admin_nickname'));
|
||||
$this->adminPass = $post->string('admin_password');
|
||||
$adminPass2 = $post->string('admin_password2');
|
||||
$this->adminEmail = $post->string('admin_email');
|
||||
$this->adminNick = strtolower($post->string('admin_nickname'));
|
||||
$this->adminPass = $post->string('admin_password');
|
||||
$adminPass2 = $post->string('admin_password2');
|
||||
$this->adminEmail = $post->string('admin_email');
|
||||
|
||||
$this->siteProfile = $post->string('site_profile');
|
||||
|
||||
@ -350,7 +356,7 @@ STR;
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (!in_array($this->ssl, array('never', 'always'))) {
|
||||
if (!in_array($this->ssl, ['never', 'always'])) {
|
||||
$this->updateStatus("Bad value for server SSL enabling.");
|
||||
$fail = true;
|
||||
}
|
||||
@ -361,57 +367,53 @@ STR;
|
||||
|
||||
return !$fail;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
|
||||
<head>
|
||||
<title>Install GNU social</title>
|
||||
<link rel="shortcut icon" href="favicon.ico"/>
|
||||
<link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
|
||||
<link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<script src="js/extlib/jquery.js"></script>
|
||||
<script src="js/install.js"></script>
|
||||
</head>
|
||||
<body id="install">
|
||||
<div id="wrap">
|
||||
<div id="header">
|
||||
<address id="site_contact" class="h-card">
|
||||
<a class="u-url p-name home bookmark org" href=".">
|
||||
<img class="logo u-photo" src="theme/neo/logo.png" alt="GNU social"/>
|
||||
GNU social
|
||||
</a>
|
||||
</address>
|
||||
<div id="site_nav_global_primary"></div>
|
||||
</div>
|
||||
<div id="core">
|
||||
<div id="aside_primary_wrapper">
|
||||
<div id="content_wrapper">
|
||||
<div id="site_nav_local_views_wrapper">
|
||||
<div id="site_nav_local_views"></div>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Install GNU social</title>
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv">
|
||||
<link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script src="js/extlib/jquery.js"></script>
|
||||
<script src="js/install.js"></script>
|
||||
</head>
|
||||
<body id="install">
|
||||
<div id="wrap">
|
||||
<div id="header">
|
||||
<address id="site_contact" class="h-card">
|
||||
<a class="u-url p-name home bookmark org" href=".">
|
||||
<img class="logo u-photo" src="theme/neo/logo.png" alt="GNU social"/>
|
||||
GNU social
|
||||
</a>
|
||||
</address>
|
||||
<div id="site_nav_global_primary"></div>
|
||||
</div>
|
||||
<div id="core">
|
||||
<div id="aside_primary_wrapper">
|
||||
<div id="content_wrapper">
|
||||
<div id="site_nav_local_views_wrapper">
|
||||
<div id="site_nav_local_views"></div>
|
||||
|
||||
<div id="content">
|
||||
<div id="content_inner">
|
||||
<h1>Install GNU social</h1>
|
||||
<?php
|
||||
$installer = new WebInstaller();
|
||||
$installer->main();
|
||||
?>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="content_inner">
|
||||
<h1>Install GNU social</h1>
|
||||
<?php
|
||||
$installer = new WebInstaller();
|
||||
$installer->main();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aside_primary" class="aside"></div>
|
||||
</div>
|
||||
|
||||
<div id="aside_primary" class="aside"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
</body>
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,37 +1,36 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
* CLI Installer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Installation
|
||||
* @package Installation
|
||||
*
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
* @version 1.1.x
|
||||
* @link http://status.net
|
||||
* @package Installation
|
||||
* @author Brion Vibber <brion@pobox.com>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', dirname(dirname(__FILE__)));
|
||||
define('INSTALLDIR', dirname(__DIR__));
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib');
|
||||
|
||||
require_once INSTALLDIR . '/lib/installer.php';
|
||||
@ -43,16 +42,16 @@ class CliInstaller extends Installer
|
||||
|
||||
/**
|
||||
* Go for it!
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function main()
|
||||
public function main(): bool
|
||||
{
|
||||
if ($this->prepare()) {
|
||||
if (!$this->checkPrereqs()) {
|
||||
return false;
|
||||
}
|
||||
if (!$this->checkPrereqs()) {
|
||||
return false;
|
||||
}
|
||||
return $this->handle();
|
||||
} else {
|
||||
} else {
|
||||
$this->showHelp();
|
||||
return false;
|
||||
}
|
||||
@ -60,23 +59,23 @@ class CliInstaller extends Installer
|
||||
|
||||
/**
|
||||
* Get our input parameters...
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
function prepare()
|
||||
public function prepare(): bool
|
||||
{
|
||||
$shortoptions = 'qvh';
|
||||
$longoptions = array('quiet', 'verbose', 'help', 'skip-config');
|
||||
$map = array(
|
||||
'-s' => 'server',
|
||||
'--server' => 'server',
|
||||
'-p' => 'path',
|
||||
'--path' => 'path',
|
||||
$longoptions = ['quiet', 'verbose', 'help', 'skip-config'];
|
||||
$map = [
|
||||
'-s' => 'server',
|
||||
'--server' => 'server',
|
||||
'-p' => 'path',
|
||||
'--path' => 'path',
|
||||
'--sitename' => 'sitename',
|
||||
'--fancy' => 'fancy',
|
||||
'--ssl' => 'ssl',
|
||||
'--fancy' => 'fancy',
|
||||
'--ssl' => 'ssl',
|
||||
|
||||
'--dbtype' => 'dbtype',
|
||||
'--host' => 'host',
|
||||
'--dbtype' => 'dbtype',
|
||||
'--host' => 'host',
|
||||
'--database' => 'database',
|
||||
'--username' => 'username',
|
||||
'--password' => 'password',
|
||||
@ -86,7 +85,7 @@ class CliInstaller extends Installer
|
||||
'--admin-email' => 'adminEmail',
|
||||
|
||||
'--site-profile' => 'siteProfile'
|
||||
);
|
||||
];
|
||||
foreach ($map as $arg => $target) {
|
||||
if (substr($arg, 0, 2) == '--') {
|
||||
$longoptions[] = substr($arg, 2) . '=';
|
||||
@ -116,13 +115,13 @@ class CliInstaller extends Installer
|
||||
if ($arg == '--fancy') {
|
||||
$this->$var = ($option[1] != 'false') && ($option[1] != 'no');
|
||||
}
|
||||
} else if ($arg == '--skip-config') {
|
||||
} elseif ($arg == '--skip-config') {
|
||||
$this->skipConfig = true;
|
||||
} else if ($arg == 'q' || $arg == '--quiet') {
|
||||
} elseif ($arg == 'q' || $arg == '--quiet') {
|
||||
$this->verbose = false;
|
||||
} else if ($arg == 'v' || $arg == '--verbose') {
|
||||
} elseif ($arg == 'v' || $arg == '--verbose') {
|
||||
$this->verbose = true;
|
||||
} else if ($arg == 'h' || $arg == '--help') {
|
||||
} elseif ($arg == 'h' || $arg == '--help') {
|
||||
// will go back to show help
|
||||
return false;
|
||||
}
|
||||
@ -146,15 +145,15 @@ class CliInstaller extends Installer
|
||||
return !$fail;
|
||||
}
|
||||
|
||||
function handle()
|
||||
public function handle()
|
||||
{
|
||||
return $this->doInstall();
|
||||
}
|
||||
|
||||
function showHelp()
|
||||
public function showHelp()
|
||||
{
|
||||
echo <<<END_HELP
|
||||
install_cli.php - StatusNet command-line installer
|
||||
install_cli.php - GNU social command-line installer
|
||||
|
||||
-s --server=<name> Use <name> as server name (required)
|
||||
-p --path=<path> Use <path> as path name
|
||||
@ -189,7 +188,11 @@ install_cli.php - StatusNet command-line installer
|
||||
END_HELP;
|
||||
}
|
||||
|
||||
function warning($message, $submessage='')
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $submessage
|
||||
*/
|
||||
public function warning(string $message, string $submessage = '')
|
||||
{
|
||||
print $this->html2text($message) . "\n";
|
||||
if ($submessage != '') {
|
||||
@ -198,7 +201,11 @@ END_HELP;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
function updateStatus($status, $error=false)
|
||||
/**
|
||||
* @param string $status
|
||||
* @param bool $error
|
||||
*/
|
||||
public function updateStatus(string $status, bool $error = false)
|
||||
{
|
||||
if ($this->verbose || $error) {
|
||||
if ($error) {
|
||||
@ -209,12 +216,18 @@ END_HELP;
|
||||
}
|
||||
}
|
||||
|
||||
private function html2text($html)
|
||||
/**
|
||||
* @param string $html
|
||||
* @return string
|
||||
*/
|
||||
private function html2text(string $html): string
|
||||
{
|
||||
// break out any links for text legibility
|
||||
$breakout = preg_replace('/<a[^>+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
|
||||
'\2 <\1>',
|
||||
$html);
|
||||
$breakout = preg_replace(
|
||||
'/<a[^>+]\bhref="(.*)"[^>]*>(.*)<\/a>/',
|
||||
'\2 <\1>',
|
||||
$html
|
||||
);
|
||||
return html_entity_decode(strip_tags($breakout), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user