X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=9b0d19882cf5e4f3e4af9507230490eef9ca6f31;hb=3d835bb8b5473783fffb571ccc7f51b6b82b225e;hp=570b08edf473b13e709ece605656a279d89016de;hpb=ccbc5c447df5a5284b8845d9a53f28d17d8df875;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index 570b08edf4..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; - } +require INSTALLDIR . '/lib/installer.php'; - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - handlePost(); - } else { - showForm(); +/** + * Helper class for building form + */ +class Posted { + /** + * HTML-friendly escaped string for the POST param of given name, or empty. + * @param string $name + * @return string + */ + function value($name) + { + return htmlspecialchars($this->string($name)); } -} -function checkPrereqs() -{ - $pass = true; - - if (file_exists(INSTALLDIR.'/config.php')) { - ?>

Config file "config.php" already exists.

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

Require PHP version 5 or greater.

dequote($_POST[$name]); + } else { + return null; + } } - $reqs = array('gd', 'mysql', 'curl', - 'xmlwriter', 'mbstring', - 'gettext'); - - foreach ($reqs as $req) { - if (!checkExtension($req)) { - ?>

Cannot load required extension:

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/

- checkPrereqs()) { + $this->showForm(); + return; } - } - return true; -} -function showForm() -{ - echo<< - - -
-
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

    -
  • -
  • - - -

    Database name

    -
  • -
  • - - -

    Database username

    -
  • -
  • - - -

    Database password

    -
  • -
- -
-
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->handlePost(); + } else { + $this->showForm(); + } + } -E_O_T; -} + /** + * Web implementation of warning output + */ + function warning($message, $submessage='') + { + print "

$message

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

$submessage

\n"; + } + } -function updateStatus($status, $error=false) -{ -?> -
  • >
  • + /** + * Web implementation of status output + */ + function updateStatus($status, $error=false) + { + echo '$status"; + } -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"; + } + } -function handlePost() -{ -?> + echo<< +
    +
    + Site settings +
      +
    • + + +

      The name of your site

      +
    • +
    • + + enable
      + disable
      +

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

      +
    • +
    +
    - -
    -
    Page notice
    -
    -
      - + Database settings +
        +
      • + + +

        Database hostname

        +
      • +
      • + + $dbRadios +

        Database type

        +
      • +
      • + + +

        Database name

        +
      • +
      • + + +

        Database username

        +
      • +
      • + + +

        Database password (optional)

        +
      • +
      +
    - if (empty($host)) { - updateStatus("No hostname 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($database)) { - updateStatus("No database specified.", true); - $fail = true; +E_O_T; } - if (empty($username)) { - updateStatus("No username 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 (empty($password)) { - updateStatus("No password specified.", true); - $fail = true; - } + /** + * 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'); - if (empty($sitename)) { - updateStatus("No sitename specified.", true); - $fail = true; - } + $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'); - if($fail){ - showForm(); - return; - } + $this->server = $_SERVER['HTTP_HOST']; + $this->path = substr(dirname($_SERVER['PHP_SELF']), 1); - 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; + $fail = false; + if (!$this->validateDb()) { + $fail = true; } - } - 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!"); - if ($path) $path .= '/'; - updateStatus("You can visit your new Laconica site."); -?> -"); - return $res; -} - -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; + } ?> @@ -292,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 - - - - + + + + @@ -306,15 +347,20 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    -

    Install Laconica

    - +
    +

    Install StatusNet

    +main(); +?> +