ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

installcli.php
Go to the documentation of this file.
1 <?php
2 /* -------------------- COMMON HEADER ---------------------- */
3 $base = dirname(__FILE__);
4 $onabase = dirname($base);
6 $include = $onabase . '/www/include';
7 if (!is_dir($include)) { print "ERROR => Couldn't find include folder!\n"; exit; }
8 
9 // MP: Since we know ONA will generate a ton of notice level errors, lets turn them off here
10 error_reporting (E_ALL ^ E_NOTICE);
11 
12 $conf = array (
13  /* General Setup */
14  // Database Context
15  // For possible values see the $ona_contexts() array in the database_settings.inc.php file
16  "default_context" => 'DEFAULT',
17 
18  /* Include Files: Functions */
19  "inc_functions" => "$include/functions_general.inc.php",
20  "inc_functions_db" => "$include/functions_db.inc.php",
21  "inc_functions_auth" => "$include/functions_auth.inc.php",
22  "inc_db_sessions" => "$include/adodb_sessions.inc.php",
23  "inc_adodb" => "$include/adodb/adodb.inc.php",
24  "inc_adodb_xml" => "$include/adodb/adodb-xmlschema03.inc.php",
25 
26  /* Defaults for some user definable options normally in sys_config table */
27  "debug" => "2",
28  "logfile" => "/var/log/ona.log",
29 
30 );
31 
32 // Include the basic system functions
33 // any $conf settings used in this "require" should not be user adjusted in the sys_config table
34 require_once("{$include}/functions_general.inc.php");
35 
36 // Include the basic database functions
37 #require_once("{$include}/functions_db.inc.php");
38 
39 // Include the localized Database settings
40 $dbconffile = "{$onabase}/www/local/config/database_settings.inc.php";
41 if (file_exists($dbconffile)) {
42  if (substr(exec("php -l $dbconffile"), 0, 28) == "No syntax errors detected in") {
43  @include($dbconffile);
44  } else {
45  echo "Syntax error in your DB config file: {$dbconffile} Please check that it contains a valid PHP formatted array, or check that you have the php cli tools installed. You can perform this check maually using the command 'php -l {$dbconffile}'.";
46  exit;
47  }
48 } else {
49 # require_once($base.'/../install/install.php');
50 # exit;
51 }
52 
53 #// If it does, run the install process.
54 #if (file_exists($base.'/local/config/run_install') or @$runinstaller or @$install_submit == 'Y') {
55 # // Process the install script
56 # require_once($base.'/../install/install.php');
57 # exit;
58 #}
59 
60 
61 
62 
63 
64 
65 // get adodb xml processing
66 @require_once($conf['inc_adodb_xml']);
67 /* --------------------------------------------------------- */
68 
69 
70 // Init and setup some variables.
71 $text = '';
72 $status = 0;
73 $runinstall = $onabase.'/www/local/config/run_install';
74 $xmlfile_tables = $base.'/ona-table_schema.xml';
75 $xmlfile_data = $base.'/ona-data.xml';
76 $new_ver = trim(file_get_contents($onabase.'/VERSION'));
77 $curr_ver = '';
78 
79 # junk output from included functions
80 $stdout = '';
81 $syslog = '';
83 
85 
86 // Start the menu loop
87 while($install_complete){
88 
89  echo "\nWELCOME TO THE OPENNETADMIN INSTALLER..\n";
90 
91  // License info
92  echo "ONA is licensed under GPL v2.0.\n";
93  $showlicense = promptUser("Would you like to view license? [y/N] ", 'n');
94  if ($showlicense == 'y') {
95  system("more -80 {$base}/../docs/LICENSE");
96  promptUser("[Press Enter To Continue]");
97  }
98 
100 
101  // Check if it is a fresh install or upgrade
102  if (@file_exists($dbconffile)) {
103  upgrade();
104  } else {
105  new_install();
106  }
107 
108  exit;
109 
110 }
111 
112 
113 
114 
115 
116 // Gather requirement information
117 function check_requirements() {
118 
119  global $conf,$onabase;
120 
121  system('clear');
122  // Get some pre-requisite information
123  $phpversion = phpversion() > '5.0' ? 'PASS' : 'FAIL';
124  $hasgmp = function_exists( 'gmp_init' ) ? 'PASS' : 'FAIL';
125  //echo function_exists( 'gmp_init' ) ? '' : 'PHP GMP module is missing.';
126  $hasmysql = function_exists( 'mysqli_connect' ) ? 'PASS' : 'FAIL';
127  $hasxml = function_exists( 'xml_parser_create' ) ? 'PASS' : 'FAIL';
128  $hasmbstring = function_exists( 'mb_internal_encoding' ) ? 'PASS' : 'FAIL';
129  $dbconfwrite = @is_writable($onabase.'/www/local/config/') ? 'PASS' : 'FAIL';
130  $logfilewrite = @is_writable($conf['logfile']) ? 'PASS' : 'FAIL';
131 
132  echo <<<EOL
133 
134 CHECKING PREREQUISITES...
135 
136  PHP version greater than 5.0: $phpversion
137  PHP GMP module: $hasgmp
138  PHP XML module: $hasxml
139  PHP mysqli function: $hasmysql
140  PHP mbstring function: $hasmbstring
141  $onabase/www/local/config dir writable: $dbconfwrite
142  {$conf['logfile']} writable: $logfilewrite
143 
144 EOL;
145 }
146 
147 
148 
149 
150 function upgrade() {
151 
152  echo "\n\n";
154 
155  // If they already have a dbconffile, assume that we are doing and upgrade
156  if (@file_exists($dbconffile)) {
157  // Get the existing database config (again) so we can connect using its settings
158  include($dbconffile);
159 
160  $context_count = count($ona_contexts);
161 
162  $text = "It looks as though you already have a version of OpenNetAdmin installed.\nYou should make a backup of the data for each context listed below before proceeding with this upgrade.\n\nWe will be upgrading to version '{$new_ver}'.\n\nWe have found {$context_count} context(s) in your current db configuration file.\n\n";
163 
164  $text .= "Context DB type Server DB name Version Upgrade Index\n";
165  // Loop through each context and identify the Databases within
166  foreach(array_keys($ona_contexts) as $cname) {
167 
168  foreach($ona_contexts[$cname]['databases'] as $cdbs) {
169  $curr_ver = 'Unable to determine';
170  // Make an initial connection to a DB server without specifying a database
171  $db = ADONewConnection($cdbs['db_type']);
172  @$db->Connect( $cdbs['db_host'], $cdbs['db_login'], $cdbs['db_passwd'], '' );
173 
174  if (!$db->IsConnected()) {
175  $status++;
176  printmsg("INFO => Unable to connect to server '{$cdbs['db_host']}'. ".$db->ErrorMsg(),0);
177  $text .= "[{$cname}] Failed to connect as '{$cdbs['db_login']}'. ERROR: ".$db->ErrorMsg();
178  } else {
179  if ($db->SelectDB($cdbs['db_database'])) {
180  $rs = $db->Execute("SELECT value FROM sys_config WHERE name like 'version'");
181  $array = $rs->FetchRow();
182  $curr_ver = $array['value'];
183 
184  $rs = $db->Execute("SELECT value FROM sys_config WHERE name like 'upgrade_index'");
185  $array = $rs->FetchRow();
186  $upgrade_index = $array['value'];
187 
188  $levelinfo = $upgrade_index;
189 
190  if ($upgrade_index < 8) { $levelinfo = "Must upgrade to at least v09.09.15 first!\n"; }
191  } else {
192  $status++;
193  $text .= "[{$cname}] Failed to select DB '{$cdbs['db_database']}'. ERROR: ".$db->ErrorMsg()."\n";
194  }
195  }
196  // Close the database connection
197  @$db->Close();
198 
199 
200  $text .= "{$cname} {$cdbs['db_type']} {$cdbs['db_host']} {$cdbs['db_database']} {$curr_ver} {$levelinfo}\n";
201  }
202 
203  }
204 
205 
206  if ($status == 0) {
207  echo $text."\n";
208  $upgrade = promptUser("Perform the upgrade? ", 'y/N');
209  $text = '';
210  } else {
211  $text .= <<<EOL
212  There was an error determining database context versions. Please correct them before proceeding. \n\nCheck that the content of your database configuration file '{$dbconffile}' is accurate and that the databases themselves are configured properly.\n\n{$err_txt}\n
213 EOL;
214  }
215 
216  }
217 
218 
219  $dbtype = 'mysqli'; $adotype = $dbtype;
220 
221 // If they have selected to keep the tables then remove the run_install file
222 if ($upgrade == 'Y' or $upgrade == 'y') {
223 
224  // Loop through each context and upgrade the Databases within
225  foreach(array_keys($ona_contexts) as $cname) {
226 
227  foreach($ona_contexts[$cname]['databases'] as $cdbs) {
228  printmsg("INFO => [{$cname}/{$cdbs['db_host']}] Performing an upgrade.",0);
229 
230  // Make an initial connection to a DB server without specifying a database
231  $db = ADONewConnection($adotype);
232  @$db->NConnect( $cdbs['db_host'], $cdbs['db_login'], $cdbs['db_passwd'], '' );
233 
234  if (!$db->IsConnected()) {
235  $status++;
236  printmsg("INFO => Unable to connect to server '{$cdbs['db_host']}'. ".$db->ErrorMsg(),0);
237  $text .= " [{$cname}] Failed to connect to '{$cdbs['db_host']}' as '{$cdbs['db_login']}'. ERROR: ".$db->ErrorMsg()."\n";
238  } else {
239  $db->Close();
240  if ($db->NConnect( $database_host, $cdbs['db_login'], $cdbs['db_passwd'], $cdbs['db_database'])) {
241 
242 
243  // Get the current upgrade index if there is one.
244  $rs = $db->Execute("SELECT value FROM sys_config WHERE name like 'upgrade_index'");
245  $array = $rs->FetchRow();
246  $upgrade_index = $array['value'];
247 
248  $text .= "[{$cname}/{$cdbs['db_host']}] Keeping your original data.\n";
249 
250  // update existing tables in our database to match our baseline xml schema
251  // create a schema object and build the query array.
252  $schema = new adoSchema( $db );
253  // Build the SQL array from the schema XML file
254  $sql = $schema->ParseSchema($xmlfile_tables);
255  // Uncomment the following to display the raw SQL
256  #$text .= "----------\n".$schema->PrintSQL('TEXT')."\n---------\n";
257  // Execute the SQL on the database
258  if ($schema->ExecuteSchema( $sql ) == 2) {
259  $text .= "[{$cname}/{$cdbs['db_host']}] Upgrading tables within database '{$cdbs['db_database']}'.\n";
260  printmsg("INFO => [{$cname}/{$cdbs['db_host']}] Upgrading tables within database: {$cdbs['db_database']}",0);
261  } else {
262  $status++;
263  $text .= "There was an error upgrading tables. ERROR: ".$db->ErrorMsg()."\n";
264  printmsg("ERROR => There was an error processing tables: ".$db->ErrorMsg(),0);
265  break;
266  }
267 
268 
269 
270 
271 
272  $script_text = '';
273  if ($upgrade_index == '') {
274  $text .= "[{$cname}/{$cdbs['db_host']}] Auto upgrades not yet supported. Please see docs/UPGRADES\n";
275  } else {
276  // loop until we have processed all the upgrades
277  while(1 > 0) {
278  // Find out what the next index will be
279  $new_index = $upgrade_index + 1;
280  // Determine file name
281  //$upgrade_sqlfile = "{$base}/{$upgrade_index}-to-{$new_index}.sql";
282  $upgrade_xmlfile = "{$base}/{$upgrade_index}-to-{$new_index}.xml";
283  $upgrade_phpfile = "{$base}/{$upgrade_index}-to-{$new_index}.php";
284  // Check that the upgrade script exists
285  if (file_exists($upgrade_phpfile)) {
286  $script_text .= "Please go to a command prompt and execute 'php {$upgrade_phpfile}' manually to complete the upgrade!\n";
287  }
288  // Check that the upgrade file exists
289  if (file_exists($upgrade_xmlfile)) {
290  // get the contents of the sql update file
291  // create new tables in our database
292  // create a schema object and build the query array.
293  $schema = new adoSchema( $db );
294  // Build the SQL array from the schema XML file
295  $sql = $schema->ParseSchema($upgrade_xmlfile);
296  // Execute the SQL on the database
297  if ($schema->ExecuteSchema( $sql ) == 2) {
298  $text .= "[{$cname}/{$cdbs['db_host']}] Processed XML update file.\n";
299 
300  // update index info in the DB
301  $text .= "[{$cname}/{$cdbs['db_host']}] Upgraded from index {$upgrade_index} to {$new_index}.\n";
302  // Update the upgrade_index element in the sys_config table
303  if($db->Execute("UPDATE sys_config SET value='{$new_index}' WHERE name like 'upgrade_index'")) {
304  $text .= "[{$cname}/{$cdbs['db_host']}] Updated DB upgrade_index variable to '{$new_index}'.\n";
305  }
306  else {
307  $status++;
308  $text .= "[{$cname}/{$cdbs['db_host']}] Failed to update upgrade_index variable in table 'sys_config'.\n";
309  break;
310  }
311  $upgrade_index++;
312  } else {
313  $status++;
314  $text .= "[{$cname}/{$cdbs['db_host']}] Failed to process XML update file.\n".$db->ErrorMsg()."\n";
315  printmsg("ERROR => [{$cname}/{$cdbs['db_host']}] Failed to process XML update file. ".$db->ErrorMsg(),0);
316  break;
317  }
318  } else {
319  break;
320  }
321  }
322 
323  }
324 
325 
326  // Update the version element in the sys_config table if there were no previous errors
327  if($status == 0) {
328  if($db->Execute("UPDATE sys_config SET value='{$new_ver}' WHERE name like 'version'")) {
329  $text .= "[{$cname}/{$cdbs['db_host']}] Updated DB version variable to '{$new_ver}'.\n";
330  }
331  else {
332  $status++;
333  $text .= "[{$cname}/{$cdbs['db_host']}] Failed to update version info in table 'sys_config'.\n";
334  }
335  }
336  } else {
337  $status++;
338  $text .= "[{$cname}] Failed to select DB '{$cdbs['db_database']}'. ERROR: ".$db->ErrorMsg()."\n";
339  }
340  }
341  // Close the database connection
342  @$db->Close();
343 
344  }
345 
346  }
347 
348  // If we still have the old reference to db_context in our config, upgrade it
349  if (is_array($db_context)) {
350  // set default db name to uppercase
351  $ona_contexts['DEFAULT'] = $ona_contexts['default'];unset($ona_contexts['default']);
352 
353  // Open the database config and write the contents to it.
354  if (!$fh = @fopen($dbconffile, 'w')) {
355  $status++;
356  $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to open config file for writing: '{$dbconffile}'.<br>";
357  printmsg("ERROR => Failed to open config file for writing: '{$dbconffile}'.",0);
358  }
359  else {
360  fwrite($fh, "<?php\n\n\$ona_contexts=".var_export($ona_contexts,TRUE).";\n\n?>");
361  fclose($fh);
362  $text .= "Upgraded database connection config file to new format.\n";
363  }
364  }
365 
366 
367  if($status == 0) {
368  $text .= $script_text;
369  $text .= "Upgrade complete, you may start using OpenNetAdmin! Enjoy!\n";
370 
371  if (@file_exists($runinstall)) {
372  if (!@unlink($runinstall)) {
373  $text .= "Buuut.. Failed to delete the file '{$runinstall}'.\n";
374  $text .= "Please remove '{$runinstall}' manually.\n";
375  }
376  }
377  } else {
378  $text .= "There was a fatal error. Upgrade may be incomplete. Fix the issue and try again\n";
379  }
380 
381  echo $text."\n";
382 }
383 
384 
385 }
386 
387 
388 
389 
390 
391 // This is the section for an brand new install
392 function new_install() {
393 
394  echo "\n\n";
396 
397  // Gather info
398  $adotype = 'mysqli';
399  $database_host = promptUser("Database host? ", 'localhost');
400  $admin_login = promptUser("Database admin? ", 'root');
401  $admin_passwd = promptUser("Database admin password? ", '');
402  $sys_login = promptUser("Application Database user name? ", 'ona_sys');
403  $sys_passwd = promptUser("Application Database user password? ", 'changeme');
404  $database_name = promptUser("Database name? ona_", 'default');
405  $default_domain = promptUser("Default DNS domain? ", 'example.com');
406 
407 
408  // Just to keep things a little bit grouped, lets prepend the database with ona_
409  $database_name = 'ona_'.$database_name;
410 
411  // set up initial context connection information
412  $context_name = 'DEFAULT';
413  $ona_contexts[$context_name]['databases']['0']['db_type'] = $adotype;
414  $ona_contexts[$context_name]['databases']['0']['db_host'] = $database_host;
415  $ona_contexts[$context_name]['databases']['0']['db_login'] = $sys_login;
416  $ona_contexts[$context_name]['databases']['0']['db_passwd'] = $sys_passwd;
417  $ona_contexts[$context_name]['databases']['0']['db_database'] = $database_name;
418  $ona_contexts[$context_name]['databases']['0']['db_debug'] = FALSE;
419  $ona_contexts[$context_name]['description'] = 'Default data context';
420  $ona_contexts[$context_name]['context_color'] = '#D3DBFF';
421 
422 
423  // Make an initial connection to a DB server without specifying a database
424  $db = ADONewConnection($adotype);
425  $db->charSet = 'utf8';
426  $db->NConnect( $database_host, $admin_login, $admin_passwd, '' );
427 
428  if (!$db->IsConnected()) {
429  $status++;
430  $text .= "Failed to connect to '{$database_host}' as '{$admin_login}'.\n".$db->ErrorMsg()."\n";
431  } else {
432  $text .= "Connected to '{$database_host}' as '{$admin_login}'.\n";
433 
434  // Drop out any existing database and user
435  if (@$db->Execute("DROP DATABASE IF EXISTS {$database_name}")) {
436  //@$db->Execute("DROP USER IF EXISTS '{$sys_login}'@'%'");
437  $text .= "Dropped existing instance of '{$database_name}'.\n";
438  printmsg("INFO => Dropped existing DB: $database_name",0);
439  }
440  else {
441  $status++;
442  $text .= "Failed to drop existing instance of '{$database_name}'.\n".$db->ErrorMsg()."\n";
443  }
444 
445  // MP TODO: when this is done as part of an add conext, we must copy the system_config data from the default context to populate it
446  // so that plugins that have created options will show up etc. Prompt the user that this happened so they can change what they want.
447 
448  // Create the new database
449  $datadict = NewDataDictionary($db);
450  $sqlarray = $datadict->CreateDatabase($database_name);
451  if ($datadict->ExecuteSQLArray($sqlarray) == 2) {
452  $text .= "Created new database '{$database_name}'.\n";
453  printmsg("INFO => Added new DB: $database_name",0);
454  }
455  else {
456  $status++;
457  $text .= "Failed to create new database '{$database_name}'.\n".$db->ErrorMsg()."\n";
458  printmsg("ERROR => Failed to create new database '{$database_name}'. ".$db->ErrorMsg(),0);
459  }
460 
461 
462  // select the new database we just created
463  $db->Close();
464  if ($db->NConnect( $database_host, $admin_login, $admin_passwd, $database_name)) {
465 
466  $text .= "Selected existing DB: '{$database_name}'.\n";
467 
468  // create new tables in our database
469  // create a schema object and build the query array.
470  $schema = new adoSchema( $db );
471  // Build the SQL array from the schema XML file
472  $sql = $schema->ParseSchema($xmlfile_tables);
473  // Execute the SQL on the database
474  if ($schema->ExecuteSchema( $sql ) == 2) {
475  $text .= "Creating and updating tables within database '{$database_name}'.\n";
476  printmsg("INFO => Creating and updating tables within new DB: {$database_name}",0);
477  } else {
478  $status++;
479  $text .= "There was an error processing tables.\n".$db->ErrorMsg()."\n";
480  printmsg("ERROR => There was an error processing tables: ".$db->ErrorMsg(),0);
481  }
482 
483  // Load initial data into the new tables
484  if ($status == 0) {
485  $schema = new adoSchema( $db );
486  // Build the SQL array from the schema XML file
487  $sql = $schema->ParseSchema($xmlfile_data);
488  // Uncomment the following to display the raw SQL
489  #$text .= "----------\n".$schema->PrintSQL('TEXT')."\n---------\n";
490  // Execute the SQL on the database
491  if ($schema->ExecuteSchema( $sql ) == 2) {
492  $text .= "Loaded tables with default data.\n";
493  printmsg("INFO => Loaded data to new DB: {$database_name}",0);
494  } else {
495  $status++;
496  $text .= "Failed load default data.\n".$db->ErrorMsg()."\n";
497  printmsg("ERROR => There was an error loading the data: ".$db->ErrorMsg(),0);
498  }
499  }
500 
501  // Add the system user to the database
502  // Run the query
503  if ($status == 0) {
504 
505  // it is likely that this method here is mysql only?
506  if($db->Execute("GRANT ALL ON {$database_name}.* TO '{$sys_login}'@'localhost' IDENTIFIED BY '{$sys_passwd}'")) {
507  $db->Execute("GRANT ALL ON {$database_name}.* TO '{$sys_login}'@'%' IDENTIFIED BY '{$sys_passwd}'");
508  $db->Execute("GRANT ALL ON {$database_name}.* TO '{$sys_login}'@'{$database_host}' IDENTIFIED BY '{$sys_passwd}'");
509  $db->Execute("FLUSH PRIVILEGES");
510  $text .= "Created system user '{$sys_login}'.\n";
511  printmsg("INFO => Created new DB user: {$sys_login}",0);
512  }
513  else {
514  $status++;
515  $text .= "Failed to create system user '{$sys_login}'.\n".$db->ErrorMsg()."\n";
516  printmsg("ERROR => There was an error creating DB user: ".$db->ErrorMsg(),0);
517  }
518 
519 
520  // add the default domain to the system
521  // This is a manual add with hard coded values for timers.
522  $xmldefdomain = <<<EOL
523 <?xml version="1.0"?>
524 <schema version="0.3">
525 <sql>
526  <query>INSERT INTO domains (id,name,admin_email,default_ttl,refresh,retry,expiry,minimum,parent_id,serial,primary_master) VALUES (1,'{$default_domain}','hostmaster', 86400, 86400, 3600, 3600, 3600,0,0,0)</query>
527  <query>UPDATE sys_config SET value='{$default_domain}' WHERE name like 'dns_defaultdomain'</query>
528 </sql>
529 </schema>
530 EOL;
531  $schema = new adoSchema( $db );
532 
533  // Build the SQL array from the schema XML file
534  $domainsql = $schema->ParseSchemaString($xmldefdomain);
535 
536  // Execute the SQL on the database
537  if ($schema->ExecuteSchema( $domainsql ) == 2) {
538  $text .= "Created default DNS domain '{$default_domain}'.\n";
539  } else {
540  $status++;
541  $text .= "Failed to create default DNS domain '{$default_domain}'.\n".$db->ErrorMsg()."\n";
542  }
543 
544 
545  // Open the database config and write the contents to it.
546  if (!$fh = @fopen($dbconffile, 'w')) {
547  $status++;
548  $text .= "Failed to open config file for writing: '{$dbconffile}'.\n";
549  }
550  else {
551  fwrite($fh, "<?php\n\n\$ona_contexts=".var_export($ona_contexts,TRUE).";\n\n?>");
552  fclose($fh);
553  $text .= "Created database connection config file.\n";
554  }
555 
556  // Update the version element in the sys_config table
557  if(@$db->Execute("UPDATE sys_config SET value='{$new_ver}' WHERE name like 'version'")) {
558  $text .= "Updated local version info.\n";
559  }
560  else {
561  $status++;
562  $text .= "Failed to update version info in table 'sys_config'.\n".$db->ErrorMsg()."\n";
563  }
564  }
565 
566  } else {
567  $status++;
568  $text .= "Failed to select DB '{$database_name}'.\n".$db->ErrorMsg()."\n";
569  printmsg("ERROR => Failed to select DB: {$database_name}. ".$db->ErrorMsg(),0);
570  }
571 
572 
573 
574  if ($status > 0) {
575  $text .= "There was a fatal error. Install may be incomplete. Fix the issue and try again\n";
576  } else {
577  // remove the run_install file in the install dir
578  if (@file_exists($runinstall)) {
579  if (!@unlink($runinstall)) {
580  $text .= "Failed to delete the file '{$runinstall}'.\n";
581  $text .= "Please remove '{$runinstall}' manually.\n";
582  }
583  }
584  $text .= "You can now go the following URL in your browser: ".parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH)."' using OpenNetAdmin!\nYou can log in as 'admin' with a password of 'admin'\nEnjoy!";
585  }
586 
587  // Close the database connection
588  @$db->Close();
589  }
590 
591 
592 }
593 
594 
595 
596 // Print out the text to the end user
597 echo $text;
598 
599 
600 
601 if ($upgrademain != '') {
602  print $upgrademain;
603  print $main;
604  print $blankmain;
605 } else {
606  print $main;
607 }
608 
609 
610 
611 
612 
613 
614 //#######################################################################
615 //# Function: Prompt user and get user input, returns value input by user.
616 //# Or if return pressed returns a default if used e.g usage
617 //# $name = promptUser("Enter your name");
618 //# $serverName = promptUser("Enter your server name", "localhost");
619 //# Note: Returned value requires validation
620 // from http://wiki.uniformserver.com/index.php/PHP_CLI:_User_Input
621 //#.......................................................................
622 function promptUser($promptStr,$defaultVal=false){;
623 
624  if($defaultVal) { // If a default set
625  echo $promptStr. "[". $defaultVal. "] : "; // print prompt and default
626  }
627  else { // No default set
628  echo $promptStr. ": "; // print prompt only
629  }
630  $name = chop(fgets(STDIN)); // Read input. Remove CR
631  if(empty($name)) { // No value. Enter was pressed
632  return $defaultVal; // return default
633  }
634  else { // Value entered
635  return $name; // return value
636  }
637 }
638 //========================================= End promptUser ============
639 
640 
641 
642 ?>
$hasmbstring
$hasmbstring
Definition: install.php:25
$hasmysql
$hasmysql
Definition: install.php:24
$syslog
$syslog
Definition: installcli.php:81
$curr_ver
$curr_ver
Definition: installcli.php:77
$install_complete
$install_complete
Definition: installcli.php:84
$stdout
$stdout
Definition: installcli.php:80
$rs
if(isset($_REQUEST['nrows'])) else $rs
Definition: server.php:94
$sql
$sql
Definition: server.php:84
exit
exit
Definition: config.inc.php:186
upgrade
upgrade()
Definition: installcli.php:150
new_install
new_install()
Definition: installcli.php:392
$log_to_db
$log_to_db
Definition: installcli.php:82
check_requirements
while($install_complete) check_requirements()
Definition: installcli.php:117
adoSchema
Definition: adodb-xmlschema.inc.php:1219
$upgrademain
$upgrademain
Definition: install.php:60
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
$new_ver
$new_ver
Definition: installcli.php:76
$text
$text
Definition: installcli.php:71
$blankmain
$blankmain
Definition: install.php:28
$runinstall
$runinstall
Definition: installcli.php:73
promptUser
promptUser($promptStr, $defaultVal=false)
Definition: installcli.php:622
$base
$base
Definition: installcli.php:3
$main
if(!is_array($ona_contexts) and is_array($db_context)) if(@file_exists($dbconffile)) $main
Definition: install.php:158
$xmlfile_tables
$xmlfile_tables
Definition: installcli.php:74
EOL
< a style="text-decoration: none;" href="/">< input class='edit' type="button" value="I don't like free stuff?" onclick=""/></a ></center ></div > EOL
Definition: install.php:40
$conf
$conf
Definition: installcli.php:12
$xmlfile_data
$xmlfile_data
Definition: installcli.php:75
$include
$include
Definition: installcli.php:6
$dbconffile
$dbconffile
Definition: installcli.php:40
$ona_contexts
n n $ona_contexts
Definition: install.php:354
$dbconfwrite
$dbconfwrite
Definition: install.php:26
$status
$status
Definition: installcli.php:72
$phpversion
$phpversion
Definition: install.php:22
$hasgmp
$hasgmp
Definition: install.php:23
$onabase
$onabase
Definition: installcli.php:4