Elgg  Version 1.11
sample_installer.php
Go to the documentation of this file.
1 <?php
2 
7 // change to true to run this script. Change back to false when done.
8 $enabled = false;
9 
10 // none of the following may be empty
11 $params = array(
12  // database parameters
13  'dbuser' => '',
14  'dbpassword' => '',
15  'dbname' => '',
16 
17  // site settings
18  'sitename' => '',
19  'siteemail' => '',
20  'wwwroot' => '',
21  'dataroot' => '',
22 
23  // admin account
24  'displayname' => '',
25  'email' => '',
26  'username' => '',
27  'password' => '',
28 );
29 
30 
31 // Do not edit below this line. //////////////////////////////
32 
33 
34 if (!$enabled) {
35  echo "To enable this script, change \$enabled to true.\n";
36  echo "You *must* disable this script after a successful installation.\n";
37  exit;
38 }
39 
40 if (PHP_SAPI !== 'cli') {
41  echo "You must use the command line to run this script.";
42  exit;
43 }
44 
45 $elggRoot = dirname(dirname(__DIR__));
46 
47 require_once "$elggRoot/vendor/autoload.php";
48 
50 
51 // install and create the .htaccess file
52 $installer->batchInstall($params, TRUE);
53 
54 // at this point installation has completed (otherwise an exception halted execution).
55 // try to rewrite the script to disable it.
56 if (is_writable(__FILE__)) {
57  $code = file_get_contents(__FILE__);
58  if (preg_match('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', $code)) {
59  // looks safe to rewrite
60  $code = preg_replace('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', '$enabled = false;', $code);
61  file_put_contents(__FILE__, $code);
62 
63  echo "\nNote: This script has been disabled for your safety.\n";
64  exit;
65  }
66 }
67 
68 echo "\nWarning: You *must* disable this script by setting \$enabled = false;.\n";
69 echo "Leaving this script enabled could endanger your installation.\n";
exit
Definition: reorder.php:12
$enabled
Sample cli installer script.
elgg echo
Translates a string.
Definition: languages.js:43
$installer
if(!$enabled) if(PHP_SAPI!== 'cli') $elggRoot