X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=8a299f89755bc13d2c51466c85681d3f90f7c1aa;hb=1e21af42a685f600f4a53f49a194013e78b12f20;hp=78a4b8763695141e90738201f96ebc8c52c5a573;hpb=104a47e4a2903f1c7ea73363a73cee12f0cf14ac;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index 78a4b87636..8a299f8975 100644 --- a/install.php +++ b/install.php @@ -31,6 +31,7 @@ * @author Robin Millette * @author Sarven Capadisli * @author Tom Adams + * @author Zach Copley * @license GNU Affero General Public License http://www.gnu.org/licenses/ * @version 0.9.x * @link http://status.net @@ -300,8 +301,21 @@ function checkPrereqs() $pass = false; } + // Look for known library bugs + $str = "abcdefghijklmnopqrstuvwxyz"; + $replaced = preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str); + if ($str != $replaced) { + printf('

PHP is linked to a version of the PCRE library ' . + 'that does not support Unicode properties. ' . + 'If you are running Red Hat Enterprise Linux / ' . + 'CentOS 5.4 or earlier, see our documentation page on fixing this.

'); + $pass = false; + } + $reqs = array('gd', 'curl', - 'xmlwriter', 'mbstring','tidy'); + 'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml'); foreach ($reqs as $req) { if (!checkExtension($req)) { @@ -391,7 +405,7 @@ function showLibs() libraries instead, as they tend to provide security updates faster, and may offer improved performance.

On Debian based distributions, such as Ubuntu, use a package manager (such as "aptitude", "apt-get", and "synaptic") to install the package listed.

On RPM based distributions, such as Red Hat, Fedora, CentOS, Scientific Linux, Yellow Dog Linux and Oracle Enterprise Linux, use a package manager (such as "yum", "apt-rpm", and "up2date") to install the package listed.

-

On servers without a package manager (such as Windows), or if the library is not packaged for your distribution, you can use PHP PEAR to install the library. Simply run "pear install <name>".

+

On servers without a package manager (such as Windows), or if the library is not packaged for your distribution, you can use PHP's PEAR to install the library. Simply run "pear install <name>".

Absent Libraries

    @@ -434,73 +448,125 @@ E_O_T; E_O_T; } +/** + * Helper class for building form + */ +class Posted { + function value($name) + { + if (isset($_POST[$name])) { + return htmlspecialchars(strval($_POST[$name])); + } else { + return ''; + } + } +} + function showForm() { global $dbModules; + $post = new Posted(); $dbRadios = ''; - $checked = 'checked="checked" '; // Check the first one which exists + if (isset($_POST['dbtype'])) { + $dbtype = $_POST['dbtype']; + } else { + $dbtype = null; + } foreach ($dbModules as $type => $info) { if (checkExtension($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 .= " $info[name]
    \n"; - $checked = ''; } } + echo<< -
    -
    Page notice
    -
    -
    -

    Enter your database connection information below to initialize the database.

    -

    StatusNet bundles a number of libraries for ease of installation. You can see what bundled libraries you are using, versus what libraries are installed on your server. -

    -
    -
    - Connection settings -
      -
    • - - -

      The name of your site

      -
    • -
    • - - enable
      - disable
      -

      Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

      -
    • -
    • - - -

      Database hostname

      -
    • -
    • - - - $dbRadios -

      Database type

      -
    • - -
    • - - -

      Database name

      -
    • -
    • - - -

      Database username

      -
    • -
    • - - -

      Database password (optional)

      -
    • -
    +
    + Site settings +
      +
    • + + +

      The name of your site

      +
    • +
    • + + enable
      + disable
      +

      Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

      +
    • +
    +
    + +
    + Database settings +
      +
    • + + +

      Database hostname

      +
    • +
    • + + $dbRadios +

      Database type

      +
    • +
    • + + +

      Database name

      +
    • +
    • + + +

      Database username

      +
    • +
    • + + +

      Database password (optional)

      +
    • +
    +
    + +
    + Administrator settings +
      +
    • + + +

      Nickname for the initial StatusNet user (administrator)

      +
    • +
    • + + +

      Password for the initial StatusNet user (administrator)

      +
    • +
    • + + +
    • +
    • + + +

      Optional email address for the initial StatusNet user (administrator)

      +
    • +
    • + + +

      Release and security feed from update@status.net (recommended)

      +
    • +
    +
    @@ -518,10 +584,17 @@ function handlePost() $host = $_POST['host']; $dbtype = $_POST['dbtype']; $database = $_POST['database']; - $username = $_POST['username']; - $password = $_POST['password']; + $username = $_POST['dbusername']; + $password = $_POST['dbpassword']; $sitename = $_POST['sitename']; $fancy = !empty($_POST['fancy']); + + $adminNick = strtolower($_POST['admin_nickname']); + $adminPass = $_POST['admin_password']; + $adminPass2 = $_POST['admin_password2']; + $adminEmail = $_POST['admin_email']; + $adminUpdates = $_POST['admin_updates']; + $server = $_SERVER['HTTP_HOST']; $path = substr(dirname($_SERVER['PHP_SELF']), 1); @@ -553,6 +626,34 @@ STR; $fail = true; } + if (empty($adminNick)) { + updateStatus("No initial StatusNet user nickname specified.", true); + $fail = true; + } + if ($adminNick && !preg_match('/^[0-9a-z]{1,64}$/', $adminNick)) { + updateStatus('The user nickname "' . htmlspecialchars($adminNick) . + '" is invalid; should be plain letters and numbers no longer than 64 characters.', true); + $fail = true; + } + // @fixme hardcoded list; should use User::allowed_nickname() + // if/when it's safe to have loaded the infrastructure here + $blacklist = array('main', 'admin', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'bookmarklet', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook'); + if (in_array($adminNick, $blacklist)) { + updateStatus('The user nickname "' . htmlspecialchars($adminNick) . + '" is reserved.', true); + $fail = true; + } + + if (empty($adminPass)) { + updateStatus("No initial StatusNet user password specified.", true); + $fail = true; + } + + if ($adminPass != $adminPass2) { + updateStatus("Administrator passwords do not match. Did you mistype?", true); + $fail = true; + } + if ($fail) { showForm(); return; @@ -570,7 +671,21 @@ STR; $res = writeConf($sitename, $server, $path, $fancy, $db); if (!$res) { - updateStatus("Cannot write config file.", true); + updateStatus("Can't write config file.", true); + showForm(); + return; + } + + // Okay, cross fingers and try to register an initial user + if (registerInitialUser($adminNick, $adminPass, $adminEmail, $adminUpdates)) { + updateStatus( + "An initial user with the administrator role has been created." + ); + } else { + updateStatus( + "Could not create initial StatusNet user (administrator).", + true + ); showForm(); return; } @@ -581,7 +696,9 @@ STR; $link = "http://".$server.'/'.$path; updateStatus("StatusNet has been installed at $link"); - updateStatus("You can visit your new StatusNet site."); + updateStatus( + "DONE! You can visit your new StatusNet site (login as '$adminNick'). If this is your first StatusNet install, you may want to poke around our Getting Started guide." + ); } function Pgsql_Db_installer($host, $database, $username, $password) @@ -616,7 +733,7 @@ function Pgsql_Db_installer($host, $database, $username, $password) $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); if ($res === false) { - updateStatus("Cannot run database script.", true); + updateStatus("Can't run database script.", true); showForm(); return false; } @@ -627,7 +744,7 @@ function Pgsql_Db_installer($host, $database, $username, $password) updateStatus(sprintf("Adding %s data to database...", $name)); $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); if ($res === false) { - updateStatus(sprintf("Cannot run %d script.", $name), true); + updateStatus(sprintf("Can't run %d script.", $name), true); showForm(); return false; } @@ -652,21 +769,21 @@ function Mysql_Db_installer($host, $database, $username, $password) $conn = mysql_connect($host, $username, $password); if (!$conn) { - updateStatus("Cannot connect to server '$host' as '$username'.", true); + updateStatus("Can't connect to server '$host' as '$username'.", true); showForm(); return false; } updateStatus("Changing to database..."); $res = mysql_select_db($database, $conn); if (!$res) { - updateStatus("Cannot change to database.", true); + updateStatus("Can't change to database.", true); showForm(); return false; } updateStatus("Running database script..."); $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn); if ($res === false) { - updateStatus("Cannot run database script.", true); + updateStatus("Can't run database script.", true); showForm(); return false; } @@ -677,7 +794,7 @@ function Mysql_Db_installer($host, $database, $username, $password) updateStatus(sprintf("Adding %s data to database...", $name)); $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); if ($res === false) { - updateStatus(sprintf("Cannot run %d script.", $name), true); + updateStatus(sprintf("Can't run %d script.", $name), true); showForm(); return false; } @@ -757,6 +874,47 @@ function runDbScript($filename, $conn, $type = 'mysqli') return true; } +function registerInitialUser($nickname, $password, $email, $adminUpdates) +{ + define('STATUSNET', true); + define('LACONICA', true); // compatibility + + require_once INSTALLDIR . '/lib/common.php'; + + $data = array('nickname' => $nickname, + 'password' => $password, + 'fullname' => $nickname); + if ($email) { + $data['email'] = $email; + } + $user = User::register($data); + + if (empty($user)) { + return false; + } + + // give initial user carte blanche + + $user->grantRole('owner'); + $user->grantRole('moderator'); + $user->grantRole('administrator'); + + // Attempt to do a remote subscribe to update@status.net + // Will fail if instance is on a private network. + + if (class_exists('Ostatus_profile') && $adminUpdates) { + try { + $oprofile = Ostatus_profile::ensureProfileURL('http://update.status.net/'); + Subscription::start($user->getProfile(), $oprofile->localProfile()); + updateStatus("Set up subscription to update@status.net."); + } catch (Exception $e) { + updateStatus("Could not set up subscription to update@status.net."); + } + } + + return true; +} + ?> xml version="1.0" encoding="UTF-8" "; ?> Install StatusNet - - - - + + + + @@ -785,8 +943,10 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    -

    Install StatusNet

    +
    +

    Install StatusNet

    +