Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
generate_install_key.php
1 <?php
27 ini_set('memory_limit', -1);
28 $SYSTEM_ROOT = '';
29 
30 if ((php_sapi_name() == 'cli')) {
31  if (isset($_SERVER['argv'][1])) {
32  $SYSTEM_ROOT = $_SERVER['argv'][1];
33  }
34 
35  $err_msg = "ERROR: You need to supply the path to the System Root as the first argument\n";
36 
37 } else {
38  if (isset($_GET['SYSTEM_ROOT'])) {
39  $SYSTEM_ROOT = $_GET['SYSTEM_ROOT'];
40  }
41 
42  $err_msg = '
43  <div style="background-color: red; color: white; font-weight: bold;">
44  You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
45  </div>
46  ';
47 }
48 
49 if (empty($SYSTEM_ROOT)) {
50  $err_msg .= "Usage: php install/step_02.php <PATH_TO_MATRIX>\n";
51  echo $err_msg;
52  exit();
53 }
54 
55 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.'/core/include/init.inc')) {
56  $err_msg = "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
57  $err_msg .= "Usage: php install/step_02.php <PATH_TO_MATRIX>\n";
58  echo $err_msg;
59  exit();
60 }
61 
62 if (!defined('SQ_SYSTEM_ROOT')) {
63  define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
64 }
65 require_once $SYSTEM_ROOT.'/core/include/init.inc';
66 require_once $SYSTEM_ROOT.'/install/install.inc';
67 require_once SQ_FUDGE_PATH.'/general/file_system.inc';
68 
69 echo 'Generating install key...'."\n";
70 
71 $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
72 $install_key = generate_install_key(TRUE);
73 $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
74 
75 if (is_null($install_key)) {
76  echo 'Could not generate an install key because the main.inc file was not found or is not accessible'."\n";
77 } else {
78  echo 'Your system\'s install key is [ '.$install_key.' ]'."\n";
79 }
80 ?>