Elgg  Version 1.9
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 require_once(dirname(dirname(__FILE__)) . "/ElggInstaller.php");
46 
48 
49 // install and create the .htaccess file
50 $installer->batchInstall($params, TRUE);
51 
52 // at this point installation has completed (otherwise an exception halted execution).
53 // try to rewrite the script to disable it.
54 if (is_writable(__FILE__)) {
55  $code = file_get_contents(__FILE__);
56  if (preg_match('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', $code)) {
57  // looks safe to rewrite
58  $code = preg_replace('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', '$enabled = false;', $code);
59  file_put_contents(__FILE__, $code);
60 
61  echo "\nNote: This script has been disabled for your safety.\n";
62  exit;
63  }
64 }
65 
66 echo "\nWarning: You *must* disable this script by setting \$enabled = false;.\n";
67 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