X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=9b0d19882cf5e4f3e4af9507230490eef9ca6f31;hb=3d835bb8b5473783fffb571ccc7f51b6b82b225e;hp=096746d4aedfcdcfb284a4b37c9a1e34baa1450e;hpb=d591e24eac5f37dbff7b17ac039c2e8bc0a33653;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index 096746d4ae..9b0d19882c 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ . + * + * @category Installation + * @package Installation + * + * @author Adrian Lang + * @author Brenda Wallace + * @author Brett Taylor + * @author Brion Vibber + * @author CiaranG + * @author Craig Andrews + * @author Eric Helgeson + * @author Evan Prodromou + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams + * @author Zach Copley + * @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 */ define('INSTALLDIR', dirname(__FILE__)); -function main() -{ - if (!checkPrereqs()) - { - return; - } - - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - handlePost(); - } else { - showForm(); - } -} - -function checkPrereqs() -{ - $pass = true; +require INSTALLDIR . '/lib/installer.php'; - if (file_exists(INSTALLDIR.'/config.php')) { - ?>

Config file "config.php" already exists.

- string($name)); } - if (version_compare(PHP_VERSION, '5.0.0', '<')) { - ?>

Require PHP version 5 or greater.

raw($name)); } - $reqs = array('gd', 'curl', - 'xmlwriter', 'mbstring', - 'gettext'); - - foreach ($reqs as $req) { - if (!checkExtension($req)) { - ?>

Cannot load required extension:

dequote($_POST[$name]); + } else { + return null; } } - if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?>

Cannot find mysql or pgsql extension. You need one or the other:

Cannot write config file to:

-

On your server, try this command: chmod a+w -

Cannot write avatar directory: /avatar/

-

On your server, try this command: chmod a+w /avatar/

-

Cannot write background directory: /background/

-

On your server, try this command: chmod a+w /background/

- - - -
-
Page notice
-
-
-

Enter your database connection information below to initialize the database.

-
-
-
-
-
- Connection settings -
    -
  • - - -

    The name of your site

    -
  • -
  • - - enable
    - disable
    -

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

    -
  • -
  • - - -

    Database hostname

    -
  • -
  • - - - MySQL
    - PostgreSQL
    -

    Database type

    -
  • - -
  • - - -

    Database name

    -
  • -
  • - - -

    Database username

    -
  • -
  • - - -

    Database password (optional)

    -
  • -
- -
-
- -E_O_T; } -function updateStatus($status, $error=false) -{ -?> -
  • >
  • - - - - -
    -
    Page notice
    -
    -
      -checkPrereqs()) { + $this->showForm(); + return; + } - if (empty($host)) { - updateStatus("No hostname specified.", true); - $fail = true; + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->handlePost(); + } else { + $this->showForm(); + } } - if (empty($database)) { - updateStatus("No database specified.", true); - $fail = true; + /** + * Web implementation of warning output + */ + function warning($message, $submessage='') + { + print "

      $message

      \n"; + if ($submessage != '') { + print "

      $submessage

      \n"; + } } - if (empty($username)) { - updateStatus("No username specified.", true); - $fail = true; + /** + * Web implementation of status output + */ + function updateStatus($status, $error=false) + { + echo '$status"; } -// if (empty($password)) { -// updateStatus("No password specified.", true); -// $fail = true; -// } + /** + * Show the web form! + */ + 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 ($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"; + } + } - if (empty($sitename)) { - updateStatus("No sitename specified.", true); - $fail = true; - } + echo<< +
      +
      + 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)

        +
      • +
      +
      + +
      + - if($fail){ - showForm(); - return; - } - - switch($dbtype) { - case 'mysql': mysql_db_installer($host, $database, $username, $password, $sitename); - break; - case 'pgsql': pgsql_db_installer($host, $database, $username, $password, $sitename); - break; - default: +E_O_T; } - if ($path) $path .= '/'; - updateStatus("You can visit your new Laconica site."); -?> - 'SMS carrier', - 'notice_source' => 'notice source', - 'foreign_services' => 'foreign service') - as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return; - } - } - pg_query($conn, 'COMMIT'); - - updateStatus("Writing config file..."); - if (empty($password)) { - $sqlUrl = "pgsql://$username@$host/$database"; - } - else { - $sqlUrl = "pgsql://$username:$password@$host/$database"; - } - $res = writeConf($sitename, $sqlUrl, $fancy, 'pgsql'); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); - -} - -function mysql_db_installer($host, $database, $username, $password, $sitename) { - updateStatus("Starting installation..."); - updateStatus("Checking database..."); - - $conn = mysql_connect($host, $username, $password); - if (!$conn) { - updateStatus("Can't connect to server '$host' as '$username'.", true); - showForm(); - return; - } - updateStatus("Changing to database..."); - $res = mysql_select_db($database, $conn); - if (!$res) { - updateStatus("Can't change to database.", true); - showForm(); - return; - } - updateStatus("Running database script..."); - $res = runDbScript(INSTALLDIR.'/db/laconica.sql', $conn); - if ($res === false) { - updateStatus("Can't run database script.", true); - showForm(); - return; - } - foreach (array('sms_carrier' => 'SMS carrier', - 'notice_source' => 'notice source', - 'foreign_services' => 'foreign service') - as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return; - } - } - - updateStatus("Writing config file..."); - $sqlUrl = "mysqli://$username:$password@$host/$database"; - $res = writeConf($sitename, $sqlUrl, $fancy); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); + /** + * Handle a POST submission... if we have valid input, start the install! + * Otherwise shows the form along with any error messages. + */ + function handlePost() + { + echo << +
      Page notice
      +
      +
        +STR; + $this->validated = $this->prepare(); + if ($this->validated) { + $this->doInstall(); + } + echo << +
      +
    +STR; + if (!$this->validated) { + $this->showForm(); + } } -function writeConf($sitename, $sqlUrl, $fancy, $type='mysql') -{ - $res = file_put_contents(INSTALLDIR.'/config.php', - ""); - return $res; -} -function runDbScript($filename, $conn, $type='mysql') -{ - $sql = trim(file_get_contents($filename)); - $stmts = explode(';', $sql); - foreach ($stmts as $stmt) { - $stmt = trim($stmt); - if (!mb_strlen($stmt)) { - continue; + /** + * Read and validate input data. + * May output side effects. + * + * @return boolean success + */ + function prepare() + { + $post = new Posted(); + $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->adminNick = strtolower($post->string('admin_nickname')); + $this->adminPass = $post->string('admin_password'); + $adminPass2 = $post->string('admin_password2'); + $this->adminEmail = $post->string('admin_email'); + $this->adminUpdates = $post->string('admin_updates'); + + $this->server = $_SERVER['HTTP_HOST']; + $this->path = substr(dirname($_SERVER['PHP_SELF']), 1); + + $fail = false; + if (!$this->validateDb()) { + $fail = true; } - if ($type == 'mysql') { - $res = mysql_query($stmt, $conn); - } elseif ($type=='pgsql') { - $res = pg_query($conn, $stmt); + + if (!$this->validateAdmin()) { + $fail = true; } - if ($res === false) { - updateStatus("FAILED SQL: $stmt"); - return $res; + + if ($this->adminPass != $adminPass2) { + $this->updateStatus("Administrator passwords do not match. Did you mistype?", true); + $fail = true; } + + return !$fail; } - return true; + } ?> @@ -375,12 +333,12 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - Install Laconica + Install StatusNet - - - - + + + + @@ -389,15 +347,20 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    -

    Install Laconica

    - +
    +

    Install StatusNet

    +main(); +?> +