X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=7fece8999fe7bcf3ee644086c5543e114d807f69;hb=58192ad68758437a37d8af19d6676d35699ed070;hp=c2a5bb29ee394f392abe062ebf355f6d64b5fecc;hpb=fc682ecede72680bad849ea1cf159fdf2ec70898;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index c2a5bb29ee..7fece8999f 100644 --- a/install.php +++ b/install.php @@ -1,3 +1,4 @@ + * @author Sarven Capadisli * @author Tom Adams + * @author Zach Copley * @license GNU Affero General Public License http://www.gnu.org/licenses/ - * @version 0.9 + * @version 0.9.x * @link http://status.net */ @@ -92,6 +94,13 @@ $external_libraries=array( 'include'=>'HTTP/Request.php', 'check_class'=>'HTTP_Request' ), + array( + 'name'=>'HTTP_Request2', + 'pear'=>'HTTP_Request2', + 'url'=>'http://pear.php.net/package/HTTP_Request2', + 'include'=>'HTTP/Request2.php', + 'check_class'=>'HTTP_Request2' + ), array( 'name'=>'Mail', 'pear'=>'Mail', @@ -122,6 +131,14 @@ $external_libraries=array( 'include'=>'Net/URL/Mapper.php', 'check_class'=>'Net_URL_Mapper' ), + array( + 'name'=>'Net_LDAP2', + 'pear'=>'Net_LDAP2', + 'url'=>'http://pear.php.net/package/Net_LDAP2', + 'deb'=>'php-net-ldap2', + 'include'=>'Net/LDAP2.php', + 'check_class'=>'Net_LDAP2' + ), array( 'name'=>'Net_Socket', 'pear'=>'Net_Socket', @@ -284,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.3 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)) { @@ -340,13 +370,13 @@ 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); + // 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; } @@ -371,7 +401,7 @@ function showLibs() } echo<< -

Laconica comes bundled with a number of libraries required for the application to work. However, it is best that you use PEAR or you distribution to manage +

StatusNet comes bundled with a number of libraries required for the application to work. However, it is best that you use PEAR or you distribution to manage 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.

@@ -383,7 +413,7 @@ E_O_T; foreach ($absent_libraries as $library) { echo '
  • '; if (isset($library['url'])) { - echo ''.htmlentities($library['name']).''; + echo ''.htmlentities($library['name']).''; } else { echo htmlentities($library['name']); } @@ -407,7 +437,7 @@ E_O_T; foreach ($present_libraries as $library) { echo '
  • '; if (isset($library['url'])) { - echo ''.htmlentities($library['name']).''; + echo ''.htmlentities($library['name']).''; } else { echo htmlentities($library['name']); } @@ -418,73 +448,119 @@ 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.

    -

    Laconica 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)

      +
    • +
    +
    @@ -502,10 +578,16 @@ 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 = $_POST['admin_nickname']; + $adminPass = $_POST['admin_password']; + $adminPass2 = $_POST['admin_password2']; + $adminEmail = $_POST['admin_email']; + $server = $_SERVER['HTTP_HOST']; $path = substr(dirname($_SERVER['PHP_SELF']), 1); @@ -537,6 +619,21 @@ STR; $fail = true; } + if (empty($adminNick)) { + updateStatus("No initial StatusNet user nickname specified.", 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; @@ -559,13 +656,29 @@ STR; return; } + // Okay, cross fingers and try to register an initial user + if (registerInitialUser($adminNick, $adminPass, $adminEmail)) { + updateStatus( + "An initial user with the administrator role has been created." + ); + } else { + updateStatus( + "Could not create initial StatusNet user (administrator).", + true + ); + showForm(); + return; + } + /* TODO https needs to be considered */ $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) @@ -691,9 +804,7 @@ function writeConf($sitename, $server, $path, $fancy, $db) // database "\$config['db']['database'] = '{$db['database']}';\n\n". ($db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":''). - "\$config['db']['type'] = '{$db['type']}';\n\n". - - "?>"; + "\$config['db']['type'] = '{$db['type']}';\n\n"; // write configuration file out to install directory $res = file_put_contents(INSTALLDIR.'/config.php', $cfg); @@ -743,6 +854,47 @@ function runDbScript($filename, $conn, $type = 'mysqli') return true; } +function registerInitialUser($nickname, $password, $email) +{ + 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')) { + try { + $oprofile = Ostatus_profile::ensureProfile('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 - - - - + + + + @@ -771,8 +923,10 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    -

    Install StatusNet

    +
    +

    Install StatusNet

    +