X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=install.php;h=a468d2a6f00a2710c4877156e853225fbb1b7bb2;hb=f6e929d61c8fc8e16f05f5ac9c0fe7d4289dbb0e;hp=61156e9371745bf64149ea21cdedfa4b58a7abb0;hpb=3fe182e86503a9e95183fe6d641e511a4d3eb0f1;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index 61156e9371..a468d2a6f0 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; -} + /** + * the actual installation. + * If call libraries are present, then install + * + * @return void + */ + function main() + { + if (!$this->checkPrereqs()) { + $this->showForm(); + return; + } -function updateStatus($status, $error=false) -{ -?> -
  • >
  • + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->handlePost(); + } else { + $this->showForm(); + } + } -$message

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

    $submessage

    \n"; + } + } -function handlePost() -{ -?> + /** + * Web implementation of status output + */ + function updateStatus($status, $error=false) + { + echo '$status"; + } - -
    -
    Page notice
    -
    -
      -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($host)) { - updateStatus("No hostname 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.

        +
      • +
      +
      - if (empty($database)) { - updateStatus("No database specified.", true); - $fail = true; - } +
      + Database settings +
        +
      • + + +

        Database hostname

        +
      • +
      • + + $dbRadios +

        Database type

        +
      • +
      • + + +

        Database name

        +
      • +
      • + + +

        Database username

        +
      • +
      • + + +

        Database password (optional)

        +
      • +
      +
      - if (empty($username)) { - updateStatus("No username specified.", true); - $fail = true; - } +
      + 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 (empty($password)) { - updateStatus("No password specified.", true); - $fail = true; +E_O_T; } - if (empty($sitename)) { - updateStatus("No sitename specified.", true); - $fail = true; + /** + * 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(); + } } - if($fail){ - showForm(); - return; - } + /** + * 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'); - 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: - } - if ($path) $path .= '/'; - updateStatus("You can visit your new Laconica site."); -?> + $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'); -server = $_SERVER['HTTP_HOST']; + $this->path = substr(dirname($_SERVER['PHP_SELF']), 1); - function pgsql_db_installer($host, $database, $username, $password, $sitename) { - echo 'TODO'; exit; - } - - 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!"); - } -function writeConf($sitename, $sqlUrl, $fancy) -{ - $res = file_put_contents(INSTALLDIR.'/config.php', - ""); - return $res; -} + $fail = false; + if (!$this->validateDb()) { + $fail = true; + } -function runDbScript($filename, $conn) -{ - $sql = trim(file_get_contents($filename)); - $stmts = explode(';', $sql); - foreach ($stmts as $stmt) { - $stmt = trim($stmt); - if (!mb_strlen($stmt)) { - continue; + if (!$this->validateAdmin()) { + $fail = true; } - $res = mysql_query($stmt, $conn); - if ($res === false) { - return $res; + + if ($this->adminPass != $adminPass2) { + $this->updateStatus("Administrator passwords do not match. Did you mistype?", true); + $fail = true; } + + return !$fail; } - return true; + } ?> @@ -320,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 - - - - + + + + @@ -334,15 +347,20 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    -

    Install Laconica

    - +
    +

    Install StatusNet

    +main(); +?> +