X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=9b0d19882cf5e4f3e4af9507230490eef9ca6f31;hb=3d835bb8b5473783fffb571ccc7f51b6b82b225e;hp=87a99a650895b3774adc3b2e0c84cf401cb370fe;hpb=558fa2743e182e50efb8aa1ad3fbc756ca1665e7;p=quix0rs-gnu-social.git diff --git a/install.php b/install.php index 87a99a6508..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()) +require INSTALLDIR . '/lib/installer.php'; + +/** + * 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; + return htmlspecialchars($this->string($name)); } - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - handlePost(); - } else { - showForm(); + /** + * The given POST parameter value, forced to a string. + * Missing value will give ''. + * + * @param string $name + * @return string + */ + function string($name) + { + return strval($this->raw($name)); } -} -function checkPrereqs() -{ - if (file_exists(INSTALLDIR.'/config.php')) { - ?>

Config file "config.php" already exists.

- dequote($_POST[$name]); + } else { + return null; + } } - if (version_compare(PHP_VERSION, '5.0.0', '<')) { - ?>

Require PHP version 5 or greater.

checkPrereqs()) { + $this->showForm(); + return; + } - foreach ($reqs as $req) { - if (!checkExtension($req)) { - ?>

Cannot load required extension "".

handlePost(); + } else { + $this->showForm(); } } - if (!is_writable(INSTALLDIR)) { - ?>

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/
- $message

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

$submessage

\n"; + } + } - return true; -} + /** + * Web implementation of status output + */ + function updateStatus($status, $error=false) + { + echo '$status"; + } -function checkExtension($name) -{ - if (!extension_loaded($name)) { - if (!dl($name.'.so')) { - return false; + /** + * 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"; + } } - } - return true; -} -function showForm() -{ -?> -

Enter your database connection information below to initialize the database.

-
-
-
    -
  • - - -

    The name of your site

    -
  • -
  • -
  • - - -

    Database hostname

    -
  • -
  • - - -

    Database name

    -
  • -
  • - - -

    Database username

    -
  • -
  • - - -

    Database password

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

    The name of your site

    +
  • +
  • + + enable
    + disable
    +

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

    +
  • +
+
-function updateStatus($status, $error=false) -{ -?> -
  • - -
  • - + Database settings +
      +
    • + + +

      Database hostname

      +
    • +
    • + + $dbRadios +

      Database type

      +
    • +
    • + + +

      Database name

      +
    • +
    • + + +

      Database username

      +
    • +
    • + + +

      Database password (optional)

      +
    • +
    +
    -function handlePost() -{ -?> -
      - + 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($host)) { - updateStatus("No hostname specified.", true); - showForm(); - return; +E_O_T; } - if (empty($database)) { - updateStatus("No database specified.", true); - showForm(); - return; + /** + * 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($username)) { - updateStatus("No username specified.", true); - 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'); - if (empty($password)) { - updateStatus("No password specified.", true); - showForm(); - return; - } + $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 (empty($sitename)) { - updateStatus("No sitename specified.", true); - 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); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); -?> -
    -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; + } ?> - - - Install Laconica - - - - - -
    -
    -
    -

    Install Laconica

    - -
    -
    -
    - + xml version="1.0" encoding="UTF-8" "; ?> + + + + Install StatusNet + + + + + + + + + +
    + +
    +
    +
    +

    Install StatusNet

    +main(); +?> +
    +
    +
    +
    +