install.php
changeset 261 5f1cd51bf1be
parent 256 f8356d9c3481
child 269 4da2dfc28728
equal deleted inserted replaced
259:112debff64bd 261:5f1cd51bf1be
    39   define('contentPath', $sp);
    39   define('contentPath', $sp);
    40 }
    40 }
    41 global $_starttime, $this_page, $sideinfo;
    41 global $_starttime, $this_page, $sideinfo;
    42 $_starttime = microtime(true);
    42 $_starttime = microtime(true);
    43 
    43 
       
    44 global $db;
       
    45 
    44 // Determine directory (special case for development servers)
    46 // Determine directory (special case for development servers)
    45 if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') )
    47 if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') )
    46 {
    48 {
    47   $filename = str_replace('/repo/', '/', __FILE__);
    49   $filename = str_replace('/repo/', '/', __FILE__);
    48 }
    50 }
   174 // INSTALLER STAGES
   176 // INSTALLER STAGES
   175 //
   177 //
   176 
   178 
   177 function stg_mysql_connect($act_get = false)
   179 function stg_mysql_connect($act_get = false)
   178 {
   180 {
       
   181   global $db;
       
   182   $db = new mysql();
       
   183   
   179   static $conn = false;
   184   static $conn = false;
   180   if ( $act_get )
   185   if ( $act_get )
   181     return $conn;
   186     return $conn;
   182   
   187   
   183   $db_user =& $_POST['db_user'];
   188   $db_user =& $_POST['db_user'];
   298     {
   303     {
   299       // really failed this time; bail out
   304       // really failed this time; bail out
   300       return false;
   305       return false;
   301     }
   306     }
   302   }
   307   }
       
   308   // initialize DBAL
       
   309   $db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name);
   303   // connected and database exists
   310   // connected and database exists
   304   return true;
   311   return true;
   305 }
   312 }
   306 
   313 
       
   314 function stg_pgsql_connect($act_get = false)
       
   315 {
       
   316   global $db;
       
   317   $db = new postgresql();
       
   318   
       
   319   static $conn = false;
       
   320   if ( $act_get )
       
   321     return $conn;
       
   322   
       
   323   $db_user =& $_POST['db_user'];
       
   324   $db_pass =& $_POST['db_pass'];
       
   325   $db_name =& $_POST['db_name'];
       
   326   
       
   327   if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) )
       
   328   {
       
   329     $db_name = htmlspecialchars($db_name);
       
   330     die("<p>SECURITY: malformed database name \"$db_name\"</p>");
       
   331   }
       
   332   
       
   333   // First, try to connect using the normal credentials
       
   334   $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
       
   335   if ( !$conn )
       
   336   {
       
   337     // Connection failed. Do we have the root username and password?
       
   338     if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
       
   339     {
       
   340       $conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}");
       
   341       if ( !$conn_root )
       
   342       {
       
   343         // Couldn't connect using either set of credentials. Bail out.
       
   344         return false;
       
   345       }
       
   346       unset($db_user, $db_pass);
       
   347       $db_user = pg_escape_string($_POST['db_user']);
       
   348       $db_pass = pg_escape_string($_POST['db_pass']);
       
   349       // Create the user account
       
   350       $q = @pg_query("CREATE ROLE '$db_user' WITH NOSUPERUSER UNENCRYPTED PASSWORD '$db_pass';", $conn_root);
       
   351       if ( !$q )
       
   352       {
       
   353         return false;
       
   354       }
       
   355       pg_close($conn_root);
       
   356       $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
       
   357       if ( !$conn )
       
   358       {
       
   359         // This should honestly never happen.
       
   360         return false;
       
   361       }
       
   362     }
       
   363   }
       
   364   if ( !$q )
       
   365   {
       
   366     // access denied to the database; try the whole root schenanegan again
       
   367     if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
       
   368     {
       
   369       $conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}");
       
   370       if ( !$conn_root )
       
   371       {
       
   372         // Couldn't connect as root; bail out
       
   373         return false;
       
   374       }
       
   375       unset($db_user, $db_pass);
       
   376       $db_user = pg_escape_string($_POST['db_user']);
       
   377       $db_pass = pg_escape_string($_POST['db_pass']);
       
   378       // create the database, if it doesn't exist
       
   379       $q = @mysql_query("CREATE DATABASE $db_name WITH OWNER $db_user;", $conn_root);
       
   380       if ( !$q )
       
   381       {
       
   382         // this really should never fail, so don't give any tolerance to it
       
   383         return false;
       
   384       }
       
   385       // Setting the owner to $db_user should grant all the rights we need
       
   386       pg_close($conn_root);
       
   387       // grant tables have hopefully been flushed, kill and reconnect our regular user connection
       
   388       pg_close($conn);
       
   389       $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
       
   390       if ( !$conn )
       
   391       {
       
   392         return false;
       
   393       }
       
   394     }
       
   395     else
       
   396     {
       
   397       return false;
       
   398     }
       
   399     // try again
       
   400     $q = @mysql_query("USE `$db_name`;", $conn);
       
   401     if ( !$q )
       
   402     {
       
   403       // really failed this time; bail out
       
   404       return false;
       
   405     }
       
   406   }
       
   407   // initialize DBAL
       
   408   $db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name);
       
   409   // connected and database exists
       
   410   return true;
       
   411 }
       
   412 
   307 function stg_drop_tables()
   413 function stg_drop_tables()
   308 {
   414 {
   309   $conn = stg_mysql_connect(true);
   415   global $db;
   310   if ( !$conn )
       
   311     return false;
       
   312   // Our list of tables included in Enano
   416   // Our list of tables included in Enano
   313   $tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'tags', 'page_groups', 'page_group_members' );
   417   $tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'tags', 'page_groups', 'page_group_members' );
   314   
   418   
   315   // Drop each table individually; if it fails, it probably means we're trying to drop a
   419   // Drop each table individually; if it fails, it probably means we're trying to drop a
   316   // table that didn't exist in the Enano version we're deleting the database for.
   420   // table that didn't exist in the Enano version we're deleting the database for.
   317   foreach ( $tables as $table )
   421   foreach ( $tables as $table )
   318   {
   422   {
   319     // Remember that table_prefix is sanitized.
   423     // Remember that table_prefix is sanitized.
   320     $table = "{$_POST['table_prefix']}$table";
   424     $table = "{$_POST['table_prefix']}$table";
   321     @mysql_query("DROP TABLE $table;", $conn);
   425     $db->sql_query("DROP TABLE $table;", $conn);
   322   }
   426   }
   323   return true;
   427   return true;
   324 }
   428 }
   325 
   429 
   326 function stg_decrypt_admin_pass($act_get = false)
   430 function stg_decrypt_admin_pass($act_get = false)
   368 {
   472 {
   369   static $schema;
   473   static $schema;
   370   if ( $act_get )
   474   if ( $act_get )
   371     return $schema;
   475     return $schema;
   372   
   476   
       
   477   global $db;
       
   478   
   373   $admin_pass = stg_decrypt_admin_pass(true);
   479   $admin_pass = stg_decrypt_admin_pass(true);
   374   $key = stg_generate_aes_key(true);
   480   $key = stg_generate_aes_key(true);
   375   $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
   481   $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
   376   $key = $aes->hextostring($key);
   482   $key = $aes->hextostring($key);
   377   $admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX);
   483   $admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX);
   378   
   484   
   379   $cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0';
   485   $cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0';
   380   
   486   
   381   $admin_user = $_POST['admin_user'];
   487   $admin_user = $_POST['admin_user'];
   382   $admin_user = str_replace('_', ' ', $admin_user);
   488   $admin_user = str_replace('_', ' ', $admin_user);
   383   $admin_user = mysql_real_escape_string($admin_user);
   489   $admin_user = $db->escape($admin_user);
   384   
   490   
   385   $schema = file_get_contents('schema.sql');
   491   switch ( $_POST['db_driver'] )
   386   $schema = str_replace('{{SITE_NAME}}',    mysql_real_escape_string($_POST['sitename']   ), $schema);
   492   {
   387   $schema = str_replace('{{SITE_DESC}}',    mysql_real_escape_string($_POST['sitedesc']   ), $schema);
   493     case 'mysql':
   388   $schema = str_replace('{{COPYRIGHT}}',    mysql_real_escape_string($_POST['copyright']  ), $schema);
   494       $schema_file = 'schema.sql';
       
   495       break;
       
   496     case 'postgresql':
       
   497       $schema_file = 'schema-pg.sql';
       
   498       break;
       
   499   }
       
   500   
       
   501   if ( !isset($schema_file) )
       
   502     die('insanity');
       
   503   
       
   504   $schema = file_get_contents($schema_file);
       
   505   $schema = str_replace('{{SITE_NAME}}',    $db->escape($_POST['sitename']   ), $schema);
       
   506   $schema = str_replace('{{SITE_DESC}}',    $db->escape($_POST['sitedesc']   ), $schema);
       
   507   $schema = str_replace('{{COPYRIGHT}}',    $db->escape($_POST['copyright']  ), $schema);
   389   $schema = str_replace('{{ADMIN_USER}}',   $admin_user                                    , $schema);
   508   $schema = str_replace('{{ADMIN_USER}}',   $admin_user                                    , $schema);
   390   $schema = str_replace('{{ADMIN_PASS}}',   mysql_real_escape_string($admin_pass          ), $schema);
   509   $schema = str_replace('{{ADMIN_PASS}}',   $db->escape($admin_pass          ), $schema);
   391   $schema = str_replace('{{ADMIN_EMAIL}}',  mysql_real_escape_string($_POST['admin_email']), $schema);
   510   $schema = str_replace('{{ADMIN_EMAIL}}',  $db->escape($_POST['admin_email']), $schema);
   392   $schema = str_replace('{{ENABLE_CACHE}}', mysql_real_escape_string($cacheonoff          ), $schema);
   511   $schema = str_replace('{{ENABLE_CACHE}}', $db->escape($cacheonoff          ), $schema);
   393   $schema = str_replace('{{REAL_NAME}}',    '',                                              $schema);
   512   $schema = str_replace('{{REAL_NAME}}',    '',                                              $schema);
   394   $schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'],                          $schema);
   513   $schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'],                          $schema);
   395   $schema = str_replace('{{VERSION}}',      ENANO_VERSION,                                   $schema);
   514   $schema = str_replace('{{VERSION}}',      ENANO_VERSION,                                   $schema);
   396   $schema = str_replace('{{ADMIN_EMBED_PHP}}', $_POST['admin_embed_php'],                    $schema);
   515   $schema = str_replace('{{ADMIN_EMBED_PHP}}', $_POST['admin_embed_php'],                    $schema);
   397   // Not anymore!! :-D
   516   // Not anymore!! :-D
   668   $cv = not($cv);
   787   $cv = not($cv);
   669   $val = eval($code);
   788   $val = eval($code);
   670   if($val)
   789   if($val)
   671   {
   790   {
   672     if($cv) $color='CCFFCC'; else $color='AAFFAA';
   791     if($cv) $color='CCFFCC'; else $color='AAFFAA';
   673     echo "<tr><td style='background-color: #$color; width: 500px;'>$desc</td><td style='padding-left: 10px;'><img alt='Test passed' src='images/good.gif' /></td></tr>";
   792     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc</td><td style='padding-left: 10px;'><img alt='Test passed' src='images/good.gif' /></td></tr>";
   674   } elseif(!$val && $warn) {
   793   } elseif(!$val && $warn) {
   675     if($cv) $color='FFFFCC'; else $color='FFFFAA';
   794     if($cv) $color='FFFFCC'; else $color='FFFFAA';
   676     echo "<tr><td style='background-color: #$color; width: 500px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test passed with warning' src='images/unknown.gif' /></td></tr>";
   795     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test passed with warning' src='images/unknown.gif' /></td></tr>";
   677     $warned = true;
   796     $warned = true;
   678   } else {
   797   } else {
   679     if($cv) $color='FFCCCC'; else $color='FFAAAA';
   798     if($cv) $color='FFCCCC'; else $color='FFAAAA';
   680     echo "<tr><td style='background-color: #$color; width: 500px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
   799     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
   681     $failed = true;
   800     $failed = true;
   682   }
   801   }
   683 }
   802 }
   684 function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
   803 function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
   685 
   804 
   812     $v = mysql_get_server_info();
   931     $v = mysql_get_server_info();
   813     if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
   932     if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
   814     mysql_close($conn);
   933     mysql_close($conn);
   815     die('good');
   934     die('good');
   816     break;
   935     break;
       
   936   case 'pgsql_test':
       
   937     error_reporting(0);
       
   938     $dbhost     = rawurldecode($_POST['host']);
       
   939     $dbname     = rawurldecode($_POST['name']);
       
   940     $dbuser     = rawurldecode($_POST['user']);
       
   941     $dbpass     = rawurldecode($_POST['pass']);
       
   942     $dbrootuser = rawurldecode($_POST['root_user']);
       
   943     $dbrootpass = rawurldecode($_POST['root_pass']);
       
   944     if($dbrootuser != '')
       
   945     {
       
   946       $conn = @pg_connect("host=$dbhost port=5432 user=$dbuser password=$dbpass dbname=$dbname");
       
   947       if(!$conn)
       
   948       {
       
   949         $e = pg_last_error();
       
   950         if(strstr($e, "Lost connection"))
       
   951           die('host'.$e);
       
   952         else
       
   953           die('root'.$e);
       
   954       }
       
   955       $rsp = 'good';
       
   956       $q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
       
   957       if(!$q)
       
   958       {
       
   959         $e = mysql_error();
       
   960         if(strstr($e, 'Unknown database'))
       
   961         {
       
   962           $rsp .= '_creating_db';
       
   963         }
       
   964       }
       
   965       mysql_close($conn);
       
   966       $conn = mysql_connect($dbhost, $dbuser, $dbpass);
       
   967       if(!$conn)
       
   968       {
       
   969         $e = mysql_error();
       
   970         if(strstr($e, "Lost connection"))
       
   971           die('host'.$e);
       
   972         else
       
   973           $rsp .= '_creating_user';
       
   974       }
       
   975       mysql_close($conn);
       
   976       die($rsp);
       
   977     }
       
   978     else
       
   979     {
       
   980       $conn = mysql_connect($dbhost, $dbuser, $dbpass);
       
   981       if(!$conn)
       
   982       {
       
   983         $e = mysql_error();
       
   984         if(strstr($e, "Lost connection"))
       
   985           die('host'.$e);
       
   986         else
       
   987           die('auth'.$e);
       
   988       }
       
   989       $q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
       
   990       if(!$q)
       
   991       {
       
   992         $e = mysql_error();
       
   993         if(strstr($e, 'Unknown database'))
       
   994         {
       
   995           die('name'.$e);
       
   996         }
       
   997         else
       
   998         {
       
   999           die('perm'.$e);
       
  1000         }
       
  1001       }
       
  1002     }
       
  1003     $v = mysql_get_server_info();
       
  1004     if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
       
  1005     mysql_close($conn);
       
  1006     die('good');
       
  1007     break;  
   817   case 'pophelp':
  1008   case 'pophelp':
   818     $topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
  1009     $topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
   819     switch($topic)
  1010     switch($topic)
   820     {
  1011     {
   821       case 'admin_embed_php':
  1012       case 'admin_embed_php':
   897 
  1088 
   898 $modestrings = Array(
  1089 $modestrings = Array(
   899               'welcome' => 'Welcome',
  1090               'welcome' => 'Welcome',
   900               'license' => 'License Agreement',
  1091               'license' => 'License Agreement',
   901               'sysreqs' => 'Server requirements',
  1092               'sysreqs' => 'Server requirements',
   902               'database'=> 'Database information',
  1093               'database' => 'Select database driver',
       
  1094               'database_mysql'=> 'Database information',
       
  1095               'database_pgsql'=> 'Database information',
   903               'website' => 'Website configuration',
  1096               'website' => 'Website configuration',
   904               'login'   => 'Administration login',
  1097               'login'   => 'Administration login',
   905               'confirm' => 'Confirm installation',
  1098               'confirm' => 'Confirm installation',
   906               'install' => 'Database installation',
  1099               'install' => 'Database installation',
   907               'finish'  => 'Installation complete',
  1100               'finish'  => 'Installation complete',
   997      <p>Enano has several requirements that must be met before it can be installed. If all is good then note any warnings and click Continue below.</p>
  1190      <p>Enano has several requirements that must be met before it can be installed. If all is good then note any warnings and click Continue below.</p>
   998     <table border="0" cellspacing="0" cellpadding="0">
  1191     <table border="0" cellspacing="0" cellpadding="0">
   999     <?php
  1192     <?php
  1000     run_test('return version_compare(\'4.3.0\', PHP_VERSION, \'<\');', 'PHP Version >=4.3.0', 'It seems that the version of PHP that your server is running is too old to support Enano properly. If this is your server, please upgrade to the most recent version of PHP, remembering to use the --with-mysql configure option if you compile it yourself. If this is not your server, please contact your webhost and ask them if it would be possible to upgrade PHP. If this is not possible, you will need to switch to a different webhost in order to use Enano.');
  1193     run_test('return version_compare(\'4.3.0\', PHP_VERSION, \'<\');', 'PHP Version >=4.3.0', 'It seems that the version of PHP that your server is running is too old to support Enano properly. If this is your server, please upgrade to the most recent version of PHP, remembering to use the --with-mysql configure option if you compile it yourself. If this is not your server, please contact your webhost and ask them if it would be possible to upgrade PHP. If this is not possible, you will need to switch to a different webhost in order to use Enano.');
  1001     run_test('return version_compare(\'5.2.0\', PHP_VERSION, \'<\');', 'PHP 5.2.0 or later', 'Your server does not have support for PHP 5.2.0. While you may continue installing Enano, please be warned that as of December 31, 2007, all support for Enano on PHP 4 servers is discontinued. If you have at least PHP 5.0.0, support will still be available, but there are many security problems in PHP versions under 5.2.0 that Enano cannot effectively prevent.', true);
  1194     run_test('return version_compare(\'5.2.0\', PHP_VERSION, \'<\');', 'PHP 5.2.0 or later', 'Your server does not have support for PHP 5.2.0. While you may continue installing Enano, please be warned that as of December 31, 2007, all support for Enano on PHP 4 servers is discontinued. If you have at least PHP 5.0.0, support will still be available, but there are many security problems in PHP versions under 5.2.0 that Enano cannot effectively prevent.', true);
  1002     run_test('return function_exists(\'mysql_connect\');', 'MySQL extension for PHP', 'It seems that your PHP installation does not have the MySQL extension enabled. If this is your own server, you may need to just enable the "libmysql.so" extension in php.ini. If you do not have the MySQL extension installed, you will need to either use your distribution\'s package manager to install it, or you will have to compile PHP from source. If you compile PHP from source, please remember to use the "--with-mysql" configure option, and you will have to have the MySQL development files installed (they usually are). If this is not your server, please contact your hosting company and ask them to install the PHP MySQL extension.');
  1195     run_test('return function_exists(\'mysql_connect\');', 'MySQL extension for PHP', 'It seems that your PHP installation does not have the MySQL extension enabled. The MySQL database driver will be unavailable. In many cases this is OK if you have another supported database type available. If this is your own server, you may need to just enable the "libmysql.so" extension in php.ini. If you do not have the MySQL extension installed, you will need to either use your distribution\'s package manager to install it, or you will have to compile PHP from source. If you compile PHP from source, please remember to use the "--with-mysql" configure option, and you will have to have the MySQL development files installed (they usually are). If this is not your server, please contact your hosting company and ask them to install the PHP MySQL extension.', true);
       
  1196     run_test('return function_exists(\'pg_connect\');', 'PostgreSQL extension for PHP', 'It seems that your PHP installation does not have the PostgreSQL extension enabled. Because of this, you won\'t be able to use the PostgreSQL database driver. This is OK in the majority of cases. If you want to use PostgreSQL support, you\'ll need to either compile the PHP extension for Postgres or install the extension with your distribution\'s package manager. Windows administrators will need enable php_pgsql.dll in their php.ini.', true);
  1003     run_test('return @ini_get(\'file_uploads\');', 'File upload support', 'It seems that your server does not support uploading files. Enano *requires* this functionality in order to work properly. Please ask your server administrator to set the "file_uploads" option in php.ini to "On".');
  1197     run_test('return @ini_get(\'file_uploads\');', 'File upload support', 'It seems that your server does not support uploading files. Enano *requires* this functionality in order to work properly. Please ask your server administrator to set the "file_uploads" option in php.ini to "On".');
  1004     run_test('return is_apache();', 'Apache HTTP Server', 'Apparently your server is running a web server other than Apache. Enano will work nontheless, but there are some known bugs with non-Apache servers, and the "fancy" URLs will not work properly. The "Standard URLs" option will be set on the website configuration page, only change it if you are absolutely certain that your server is running Apache.', true);
  1198     run_test('return is_apache();', 'Apache HTTP Server', 'Apparently your server is running a web server other than Apache. Enano will work nontheless, but there are some known bugs with non-Apache servers, and the "fancy" URLs will not work properly. The "Standard URLs" option will be set on the website configuration page, only change it if you are absolutely certain that your server is running Apache.', true);
  1005     //run_test('return function_exists(\'finfo_file\');', 'Fileinfo PECL extension', 'The MIME magic PHP extension is used to determine the type of a file by looking for a certain "magic" string of characters inside it. This functionality is used by Enano to more effectively prevent malicious file uploads. The MIME magic option will be disabled by default.', true);
  1199     //run_test('return function_exists(\'finfo_file\');', 'Fileinfo PECL extension', 'The MIME magic PHP extension is used to determine the type of a file by looking for a certain "magic" string of characters inside it. This functionality is used by Enano to more effectively prevent malicious file uploads. The MIME magic option will be disabled by default.', true);
  1006     run_test('return is_writable(ENANO_ROOT.\'/config.new.php\');', 'Configuration file writable', 'It looks like the configuration file, config.new.php, is not writable. Enano needs to be able to write to this file in order to install.<br /><br /><b>If you are installing Enano on a SourceForge web site:</b><br />SourceForge mounts the web partitions read-only now, so you will need to use the project shell service to symlink config.php to a file in the /tmp/persistent directory.');
  1200     run_test('return is_writable(ENANO_ROOT.\'/config.new.php\');', 'Configuration file writable', 'It looks like the configuration file, config.new.php, is not writable. Enano needs to be able to write to this file in order to install.<br /><br /><b>If you are installing Enano on a SourceForge web site:</b><br />SourceForge mounts the web partitions read-only now, so you will need to use the project shell service to symlink config.php to a file in the /tmp/persistent directory.');
  1007     run_test('return file_exists(\'/usr/bin/convert\');', 'ImageMagick support', 'Enano uses ImageMagick to scale images into thumbnails. Because ImageMagick was not found on your server, Enano will use the width= and height= attributes on the &lt;img&gt; tag to scale images. This can cause somewhat of a performance increase, but bandwidth usage will be higher, especially if you use high-resolution images on your site.<br /><br />If you are sure that you have ImageMagick, you can set the location of the "convert" program using the administration panel after installation is complete.', true);
  1201     run_test('return file_exists(\'/usr/bin/convert\');', 'ImageMagick support', 'Enano uses ImageMagick to scale images into thumbnails. Because ImageMagick was not found on your server, Enano will use the width= and height= attributes on the &lt;img&gt; tag to scale images. This can cause somewhat of a performance increase, but bandwidth usage will be higher, especially if you use high-resolution images on your site.<br /><br />If you are sure that you have ImageMagick, you can set the location of the "convert" program using the administration panel after installation is complete.', true);
  1008     run_test('return is_writable(ENANO_ROOT.\'/cache/\');', 'Cache directory writable', 'Apparently the cache/ directory is not writable. Enano will still work, but you will not be able to cache thumbnails, meaning the server will need to re-render them each time they are requested. In some cases, this can cause a significant slowdown.', true);
  1202     run_test('return is_writable(ENANO_ROOT.\'/cache/\');', 'Cache directory writable', 'Apparently the cache/ directory is not writable. Enano will still work, but you will not be able to cache thumbnails, meaning the server will need to re-render them each time they are requested. In some cases, this can cause a significant slowdown.', true);
  1009     run_test('return is_writable(ENANO_ROOT.\'/files/\');', 'File uploads directory writable', 'It seems that the directory where uploaded files are stored (' . ENANO_ROOT . '/files) cannot be written by the server. Enano will still function, but file uploads will not function, and will be disabled by default.', true);
  1203     run_test('return is_writable(ENANO_ROOT.\'/files/\');', 'File uploads directory writable', 'It seems that the directory where uploaded files are stored (' . ENANO_ROOT . '/files) cannot be written by the server. Enano will still function, but file uploads will not function, and will be disabled by default.', true);
       
  1204     if ( !function_exists('mysql_connect') && !function_exists('pg_connect') )
       
  1205     {
       
  1206       run_test('return false;', 'No database drivers are available.', 'You need to have at least one database driver working to install Enano. See the warnings on MySQL and PostgreSQL above for more information on installing these database drivers.', false);
       
  1207     }
  1010     echo '</table>';
  1208     echo '</table>';
  1011     if(!$failed)
  1209     if(!$failed)
  1012     {
  1210     {
  1013       ?>
  1211       ?>
  1014       
  1212       
  1042     }
  1240     }
  1043     ?>
  1241     ?>
  1044     <?php
  1242     <?php
  1045     break;
  1243     break;
  1046   case "database":
  1244   case "database":
       
  1245     echo '<h3>Choose a database driver</h3>';
       
  1246     echo '<p>The next step is to choose the database driver that Enano will use. In most cases this is MySQL, but there are certain
       
  1247              advantages to PostgreSQL, which is made available only experimentally.</p>';
       
  1248     if ( @file_exists('/etc/enano-is-virt-appliance') )
       
  1249     {
       
  1250       echo '<p><b>You\'re using the Enano virtual appliance.</b><br />Unless you configured the appliance manually, PostgreSQL support is not available. In 99% of cases you\'ll want to click MySQL below.</p>';
       
  1251     }
       
  1252     
       
  1253     $mysql_disable_reason = '';
       
  1254     $pgsql_disable_reason = '';
       
  1255     $mysql_disable = '';
       
  1256     $pgsql_disable = '';
       
  1257     if ( !function_exists('mysql_connect') )
       
  1258     {
       
  1259       $mysql_disable = ' disabled="disabled"';
       
  1260       $mysql_disable_reason = 'You don\'t have the MySQL PHP extension installed.';
       
  1261     }
       
  1262     if ( !function_exists('pg_connect') )
       
  1263     {
       
  1264       $pgsql_disable = ' disabled="disabled"';
       
  1265       $pgsql_disable_reason = 'You don\'t have the PostgreSQL PHP extensnion installed.';
       
  1266     }
       
  1267     if ( function_exists('pg_connect') && version_compare(PHP_VERSION, '5.0.0', '<') )
       
  1268     {
       
  1269       $pgsql_disable = ' disabled="disabled"';
       
  1270       $pgsql_disable_reason = 'You need to have at least PHP 5 to use the PostgreSQL database driver.';
       
  1271     }
       
  1272     
       
  1273     echo '<form action="install.php" method="get">';
       
  1274     ?>
       
  1275     <table border="0" cellspacing="5">
       
  1276       <tr>
       
  1277         <td>
       
  1278           <input type="image" name="mode" value="database_mysql" src="images/about-powered-mysql.png"<?php echo $mysql_disable; ?>/>
       
  1279         </td>
       
  1280         <td<?php if ( $mysql_disable ) echo ' style="opacity: 0.5; filter: alpha(opacity=50);"'; ?>>
       
  1281           <b>MySQL</b><br />
       
  1282           Click this button to use MySQL as the database backend for your site. Most web hosts support MySQL, and if you have
       
  1283           administrative access to your MySQL server, you can create a new database and user during this installation process if you
       
  1284           haven't done so already.
       
  1285           <?php
       
  1286           if ( $mysql_disable )
       
  1287           {
       
  1288             echo "<br /><br /><b>$mysql_disable_reason</b>";
       
  1289           }
       
  1290           ?>
       
  1291         </td>
       
  1292       </tr>
       
  1293       <tr>
       
  1294         <td>
       
  1295           <input type="image" name="mode" value="database_pgsql" src="images/about-powered-pgsql.png"<?php echo $pgsql_disable; ?> />
       
  1296         </td>
       
  1297         <td<?php if ( $pgsql_disable ) echo ' style="opacity: 0.5; filter: alpha(opacity=50);"'; ?>>
       
  1298           <b>PostgreSQL</b><br />
       
  1299           Click this button to use PostgreSQL as the database backend for your site. While not as widely supported, PostgreSQL has more
       
  1300           liberal licensing conditions and when properly configured is faster than MySQL. Some plugins may not work with the PostgreSQL
       
  1301           driver.
       
  1302           <?php
       
  1303           if ( $pgsql_disable )
       
  1304           {
       
  1305             echo "<br /><br /><b>$pgsql_disable_reason</b>";
       
  1306           }
       
  1307           ?>
       
  1308         </td>
       
  1309       </tr>
       
  1310     </table>
       
  1311     <?php
       
  1312     echo '</form>';
       
  1313     break;
       
  1314   case "database_mysql":
  1047     ?>
  1315     ?>
  1048     <script type="text/javascript">
  1316     <script type="text/javascript">
  1049       function ajaxGet(uri, f) {
  1317       function ajaxGet(uri, f) {
  1050         if (window.XMLHttpRequest) {
  1318         if (window.XMLHttpRequest) {
  1051           ajax = new XMLHttpRequest();
  1319           ajax = new XMLHttpRequest();
  1249     {
  1517     {
  1250       echo '<p><b>MySQL login information for this virtual appliance:</b><br /><br />Database hostname: localhost<br />Database login: username "enano", password: "clurichaun" (without quotes)<br />Database name: enano_www1</p>';
  1518       echo '<p><b>MySQL login information for this virtual appliance:</b><br /><br />Database hostname: localhost<br />Database login: username "enano", password: "clurichaun" (without quotes)<br />Database name: enano_www1</p>';
  1251     }
  1519     }
  1252     ?>
  1520     ?>
  1253     <form name="dbinfo" action="install.php?mode=website" method="post">
  1521     <form name="dbinfo" action="install.php?mode=website" method="post">
       
  1522       <input type="hidden" name="db_driver" value="mysql" />
  1254       <table border="0">
  1523       <table border="0">
  1255         <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
  1524         <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
  1256         <tr><td><b>Database hostname</b><br />This is the hostname (or sometimes the IP address) of your MySQL server. In many cases, this is "localhost".<br /><span style="color: #993300" id="e_db_host"></span></td><td><input onkeyup="verify();" name="db_host" size="30" type="text" /></td><td><img id="s_db_host" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1525         <tr><td><b>Database hostname</b><br />This is the hostname (or sometimes the IP address) of your MySQL server. In many cases, this is "localhost".<br /><span style="color: #993300" id="e_db_host"></span></td><td><input onkeyup="verify();" name="db_host" size="30" type="text" /></td><td><img id="s_db_host" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1257         <tr><td><b>Database name</b><br />The name of the actual database. If you don't already have a database, you can create one here, if you have the username and password of a MySQL user with administrative rights.<br /><span style="color: #993300" id="e_db_name"></span></td><td><input onkeyup="verify();" name="db_name" size="30" type="text" /></td><td><img id="s_db_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1526         <tr><td><b>Database name</b><br />The name of the actual database. If you don't already have a database, you can create one here, if you have the username and password of a MySQL user with administrative rights.<br /><span style="color: #993300" id="e_db_name"></span></td><td><input onkeyup="verify();" name="db_name" size="30" type="text" /></td><td><img id="s_db_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1258         <tr><td rowspan="2"><b>Database login</b><br />These fields should be the username and password of a user with "select", "insert", "update", "delete", "create table", and "replace" privileges for your database.<br /><span style="color: #993300" id="e_db_auth"></span></td><td><input onkeyup="verify();" name="db_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_auth" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1527         <tr><td rowspan="2"><b>Database login</b><br />These fields should be the username and password of a user with "select", "insert", "update", "delete", "create table", and "replace" privileges for your database.<br /><span style="color: #993300" id="e_db_auth"></span></td><td><input onkeyup="verify();" name="db_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_auth" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
  1267       </table>
  1536       </table>
  1268       <div class="pagenav">
  1537       <div class="pagenav">
  1269        <table border="0">
  1538        <table border="0">
  1270        <tr>
  1539        <tr>
  1271        <td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />&bull; Check your MySQL connection using the "Test Connection" button.<br />&bull; Be aware that your database information will be transmitted unencrypted several times.</p></td>
  1540        <td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />&bull; Check your MySQL connection using the "Test Connection" button.<br />&bull; Be aware that your database information will be transmitted unencrypted several times.</p></td>
       
  1541        </tr>
       
  1542        </table>
       
  1543      </div>
       
  1544     </form>
       
  1545     <?php
       
  1546     break;
       
  1547   case "database_pgsql":
       
  1548     ?>
       
  1549     <script type="text/javascript">
       
  1550       function ajaxGet(uri, f) {
       
  1551         if (window.XMLHttpRequest) {
       
  1552           ajax = new XMLHttpRequest();
       
  1553         } else {
       
  1554           if (window.ActiveXObject) {           
       
  1555             ajax = new ActiveXObject("Microsoft.XMLHTTP");
       
  1556           } else {
       
  1557             alert('Enano client-side runtime error: No AJAX support, unable to continue');
       
  1558             return;
       
  1559           }
       
  1560         }
       
  1561         ajax.onreadystatechange = f;
       
  1562         ajax.open('GET', uri, true);
       
  1563         ajax.send(null);
       
  1564       }
       
  1565       
       
  1566       function ajaxPost(uri, parms, f) {
       
  1567         if (window.XMLHttpRequest) {
       
  1568           ajax = new XMLHttpRequest();
       
  1569         } else {
       
  1570           if (window.ActiveXObject) {           
       
  1571             ajax = new ActiveXObject("Microsoft.XMLHTTP");
       
  1572           } else {
       
  1573             alert('Enano client-side runtime error: No AJAX support, unable to continue');
       
  1574             return;
       
  1575           }
       
  1576         }
       
  1577         ajax.onreadystatechange = f;
       
  1578         ajax.open('POST', uri, true);
       
  1579         ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
       
  1580         ajax.setRequestHeader("Content-length", parms.length);
       
  1581         ajax.setRequestHeader("Connection", "close");
       
  1582         ajax.send(parms);
       
  1583       }
       
  1584       function ajaxTestConnection()
       
  1585       {
       
  1586         v = verify();
       
  1587         if(!v)
       
  1588         {
       
  1589           alert('One or more of the form fields is incorrect. Please correct any information in the form that has an "X" next to it.');
       
  1590           return false;
       
  1591         }
       
  1592         var frm = document.forms.dbinfo;
       
  1593         db_host      = escape(frm.db_host.value.replace('+', '%2B'));
       
  1594         db_name      = escape(frm.db_name.value.replace('+', '%2B'));
       
  1595         db_user      = escape(frm.db_user.value.replace('+', '%2B'));
       
  1596         db_pass      = escape(frm.db_pass.value.replace('+', '%2B'));
       
  1597         db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
       
  1598         db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
       
  1599         
       
  1600         parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
       
  1601         ajaxPost('<?php echo scriptPath; ?>/install.php?mode=pgsql_test', parms, function() {
       
  1602             if(ajax.readyState==4)
       
  1603             {
       
  1604               s = ajax.responseText.substr(0, 4);
       
  1605               t = ajax.responseText.substr(4, ajax.responseText.length);
       
  1606               if(s.substr(0, 4)=='good')
       
  1607               {
       
  1608                 document.getElementById('s_db_host').src='images/good.gif';
       
  1609                 document.getElementById('s_db_name').src='images/good.gif';
       
  1610                 document.getElementById('s_db_auth').src='images/good.gif';
       
  1611                 document.getElementById('s_db_root').src='images/good.gif';
       
  1612                 if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = '<b>Warning:<\/b> The database you specified does not exist. It will be created during installation.';
       
  1613                 if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = '<b>Warning:<\/b> The specified regular user does not exist or the password is incorrect. The user will be created during installation. If the user already exists, the password will be reset.';
       
  1614                 document.getElementById('s_mysql_version').src='images/good.gif';
       
  1615                 document.getElementById('e_mysql_version').innerHTML = 'Your version of PostgreSQL meets Enano requirements.';
       
  1616               }
       
  1617               else
       
  1618               {
       
  1619                 switch(s)
       
  1620                 {
       
  1621                 case 'host':
       
  1622                   document.getElementById('s_db_host').src='images/bad.gif';
       
  1623                   document.getElementById('s_db_name').src='images/unknown.gif';
       
  1624                   document.getElementById('s_db_auth').src='images/unknown.gif';
       
  1625                   document.getElementById('s_db_root').src='images/unknown.gif';
       
  1626                   document.getElementById('e_db_host').innerHTML = '<b>Error:<\/b> The database server "'+document.forms.dbinfo.db_host.value+'" couldn\'t be contacted.<br \/>'+t;
       
  1627                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
       
  1628                   break;
       
  1629                 case 'auth':
       
  1630                   document.getElementById('s_db_host').src='images/good.gif';
       
  1631                   document.getElementById('s_db_name').src='images/unknown.gif';
       
  1632                   document.getElementById('s_db_auth').src='images/bad.gif';
       
  1633                   document.getElementById('s_db_root').src='images/unknown.gif';
       
  1634                   document.getElementById('e_db_auth').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
       
  1635                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
       
  1636                   break;
       
  1637                 case 'perm':
       
  1638                   document.getElementById('s_db_host').src='images/good.gif';
       
  1639                   document.getElementById('s_db_name').src='images/bad.gif';
       
  1640                   document.getElementById('s_db_auth').src='images/good.gif';
       
  1641                   document.getElementById('s_db_root').src='images/unknown.gif';
       
  1642                   document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> Access to the specified database using those login credentials was denied.<br \/>'+t;
       
  1643                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
       
  1644                   break;
       
  1645                 case 'name':
       
  1646                   document.getElementById('s_db_host').src='images/good.gif';
       
  1647                   document.getElementById('s_db_name').src='images/bad.gif';
       
  1648                   document.getElementById('s_db_auth').src='images/good.gif';
       
  1649                   document.getElementById('s_db_root').src='images/unknown.gif';
       
  1650                   document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> The specified database does not exist<br \/>'+t;
       
  1651                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
       
  1652                   break;
       
  1653                 case 'root':
       
  1654                   document.getElementById('s_db_host').src='images/good.gif';
       
  1655                   document.getElementById('s_db_name').src='images/unknown.gif';
       
  1656                   document.getElementById('s_db_auth').src='images/unknown.gif';
       
  1657                   document.getElementById('s_db_root').src='images/bad.gif';
       
  1658                   document.getElementById('e_db_root').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
       
  1659                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
       
  1660                   break;
       
  1661                 case 'vers':
       
  1662                   document.getElementById('s_db_host').src='images/good.gif';
       
  1663                   document.getElementById('s_db_name').src='images/good.gif';
       
  1664                   document.getElementById('s_db_auth').src='images/good.gif';
       
  1665                   document.getElementById('s_db_root').src='images/good.gif';
       
  1666                   if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = '<b>Warning:<\/b> The database you specified does not exist. It will be created during installation.';
       
  1667                   if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = '<b>Warning:<\/b> The specified regular user does not exist or the password is incorrect. The user will be created during installation. If the user already exists, the password will be reset.';
       
  1668                   
       
  1669                   document.getElementById('e_mysql_version').innerHTML = '<b>Error:<\/b> Your version of MySQL ('+t+') is older than 4.1.17. Enano will still work, but there is a known bug with the comment system and MySQL 4.1.11 that involves some comments not being displayed, due to an issue with the PHP function mysql_fetch_row().';
       
  1670                   document.getElementById('s_mysql_version').src='images/bad.gif';
       
  1671                 default:
       
  1672                   alert(t);
       
  1673                   break;
       
  1674                 }
       
  1675               }
       
  1676             }
       
  1677           });
       
  1678       }
       
  1679       function verify()
       
  1680       {
       
  1681         document.getElementById('e_db_host').innerHTML = '';
       
  1682         document.getElementById('e_db_auth').innerHTML = '';
       
  1683         document.getElementById('e_db_name').innerHTML = '';
       
  1684         document.getElementById('e_db_root').innerHTML = '';
       
  1685         var frm = document.forms.dbinfo;
       
  1686         ret = true;
       
  1687         if(frm.db_host.value != '')
       
  1688         {
       
  1689           document.getElementById('s_db_host').src='images/unknown.gif';
       
  1690         }
       
  1691         else
       
  1692         {
       
  1693           document.getElementById('s_db_host').src='images/bad.gif';
       
  1694           ret = false;
       
  1695         }
       
  1696         if(frm.db_name.value.match(/^([a-z0-9_-]+)$/g))
       
  1697         {
       
  1698           document.getElementById('s_db_name').src='images/unknown.gif';
       
  1699         }
       
  1700         else
       
  1701         {
       
  1702           document.getElementById('s_db_name').src='images/bad.gif';
       
  1703           ret = false;
       
  1704         }
       
  1705         if(frm.db_user.value != '')
       
  1706         {
       
  1707           document.getElementById('s_db_auth').src='images/unknown.gif';
       
  1708         }
       
  1709         else
       
  1710         {
       
  1711           document.getElementById('s_db_auth').src='images/bad.gif';
       
  1712           ret = false;
       
  1713         }
       
  1714         if(frm.table_prefix.value.match(/^([a-z0-9_]*)$/g))
       
  1715         {
       
  1716           document.getElementById('s_table_prefix').src='images/good.gif';
       
  1717         }
       
  1718         else
       
  1719         {
       
  1720           document.getElementById('s_table_prefix').src='images/bad.gif';
       
  1721           ret = false;
       
  1722         }
       
  1723         if(frm.db_root_user.value == '')
       
  1724         {
       
  1725           document.getElementById('s_db_root').src='images/good.gif';
       
  1726         }
       
  1727         else if(frm.db_root_user.value != '' && frm.db_root_pass.value == '')
       
  1728         {
       
  1729           document.getElementById('s_db_root').src='images/bad.gif';
       
  1730           ret = false;
       
  1731         }
       
  1732         else
       
  1733         {
       
  1734           document.getElementById('s_db_root').src='images/unknown.gif';
       
  1735         }
       
  1736         if(ret) frm._cont.disabled = false;
       
  1737         else    frm._cont.disabled = true;
       
  1738         return ret;
       
  1739       }
       
  1740       window.onload = verify;
       
  1741     </script>
       
  1742     <p>Now we need some information that will allow Enano to contact your database server. Enano uses PostgreSQL as a data storage backend,
       
  1743        and we need to have access to a PostgreSQL server in order to continue.</p>
       
  1744     <p>If you do not have access to a PostgreSQL server, and you are using your own server, you can download PostgreSQL for free from
       
  1745        <a href="http://www.postgresql.org/">PostgreSQL.org</a>.</p>
       
  1746     <form name="dbinfo" action="install.php?mode=website" method="post">
       
  1747       <input type="hidden" name="db_driver" value="postgresql" />
       
  1748       <table border="0">
       
  1749         <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
       
  1750         <tr><td><b>Database hostname</b><br />This is the hostname (or sometimes the IP address) of your Postgres server. In many cases, this is "localhost".<br /><span style="color: #993300" id="e_db_host"></span></td><td><input onkeyup="verify();" name="db_host" size="30" type="text" /></td><td><img id="s_db_host" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
       
  1751         <tr><td><b>Database name</b><br />The name of the actual database. If you don't already have a database, you can create one here, if you have the username and password of a PostgreSQL superuser.<br /><span style="color: #993300" id="e_db_name"></span></td><td><input onkeyup="verify();" name="db_name" size="30" type="text" /></td><td><img id="s_db_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
       
  1752         <tr><td rowspan="2"><b>Database login</b><br />These fields should be the username and password for a role that has permission to create and alter tables, select data, insert data, update data, and delete data. You may or may not choose to allow dropping tables.<br /><span style="color: #993300" id="e_db_auth"></span></td><td><input onkeyup="verify();" name="db_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_auth" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
       
  1753         <tr><td><input name="db_pass" size="30" type="password" /></td></tr>
       
  1754         <tr><td colspan="3" style="text-align: center"><h3>Optional information</h3></td></tr>
       
  1755         <tr><td><b>Table prefix</b><br />The value that you enter here will be added to the beginning of the name of each Enano table. You may use lowercase letters (a-z), numbers (0-9), and underscores (_).</td><td><input onkeyup="verify();" name="table_prefix" size="30" type="text" /></td><td><img id="s_table_prefix" alt="Good/bad icon" src="images/good.gif" /></td></tr>
       
  1756         <tr><td rowspan="2"><b>Database administrative login</b><br />If the Postgres database or role that you entered above does not exist yet, you can create them here, assuming that you have the login information for a PostgreSQL superuser. Leave these fields blank unless you need to use them.<br /><span style="color: #993300" id="e_db_root"></span></td><td><input onkeyup="verify();" name="db_root_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_root" alt="Good/bad icon" src="images/good.gif" /></td></tr>
       
  1757         <tr><td><input onkeyup="verify();" name="db_root_pass" size="30" type="password" /></td></tr>
       
  1758         <tr><td><b>PostgreSQL version</b></td><td id="e_mysql_version">PostgreSQL version information will<br />be checked when you click "Test<br />Connection". You need to have at<br />least PostgreSQL 8.2.0 to install Enano.</td><td><img id="s_mysql_version" alt="Good/bad icon" src="images/unknown.gif" /></td></tr>
       
  1759         <tr><td><b>Delete existing tables?</b><br />If this option is checked, all the tables that will be used by Enano will be dropped (deleted) before the schema is executed. Do NOT use this option unless specifically instructed to.</td><td><input type="checkbox" name="drop_tables" id="dtcheck" />  <label for="dtcheck">Drop existing tables</label></td></tr>
       
  1760         <tr><td colspan="3" style="text-align: center"><input type="button" value="Test connection" onclick="ajaxTestConnection();" /></td></tr>
       
  1761       </table>
       
  1762       <div class="pagenav">
       
  1763        <table border="0">
       
  1764        <tr>
       
  1765        <td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />&bull; Check your PostgreSQL connection using the "Test Connection" button.<br />&bull; Be aware that your database information will be transmitted unencrypted several times.</p></td>
  1272        </tr>
  1766        </tr>
  1273        </table>
  1767        </table>
  1274      </div>
  1768      </div>
  1275     </form>
  1769     </form>
  1276     <?php
  1770     <?php
  1575   case "install":
  2069   case "install":
  1576     if(!isset($_POST['db_host']) ||
  2070     if(!isset($_POST['db_host']) ||
  1577        !isset($_POST['db_name']) ||
  2071        !isset($_POST['db_name']) ||
  1578        !isset($_POST['db_user']) ||
  2072        !isset($_POST['db_user']) ||
  1579        !isset($_POST['db_pass']) ||
  2073        !isset($_POST['db_pass']) ||
       
  2074        !isset($_POST['db_driver']) ||
  1580        !isset($_POST['sitename']) ||
  2075        !isset($_POST['sitename']) ||
  1581        !isset($_POST['sitedesc']) ||
  2076        !isset($_POST['sitedesc']) ||
  1582        !isset($_POST['copyright']) ||
  2077        !isset($_POST['copyright']) ||
  1583        !isset($_POST['admin_user']) ||
  2078        !isset($_POST['admin_user']) ||
  1584        !isset($_POST['admin_pass']) ||
  2079        !isset($_POST['admin_pass']) ||
  1585        !isset($_POST['admin_embed_php']) || ( isset($_POST['admin_embed_php']) && !in_array($_POST['admin_embed_php'], array('2', '4')) ) ||
  2080        !isset($_POST['admin_embed_php']) || ( isset($_POST['admin_embed_php']) && !in_array($_POST['admin_embed_php'], array('2', '4')) ) ||
  1586        !isset($_POST['urlscheme'])
  2081        !isset($_POST['urlscheme'])
  1587        )
  2082        )
  1588     {
  2083     {
  1589       echo 'The installer has detected that one or more required form values is not set. Please <a href="install.php?mode=sysreqs">restart the installation</a>.';
  2084       echo 'The installer has detected that one or more required form values is not set. Please <a href="install.php?mode=sysreqs">restart the installation</a>.';
       
  2085       $template->footer();
       
  2086       exit;
       
  2087     }
       
  2088     if ( !in_array($_POST['db_driver'], array('mysql', 'postgresql')) )
       
  2089     {
       
  2090       echo 'Invalid database driver.';
  1590       $template->footer();
  2091       $template->footer();
  1591       exit;
  2092       exit;
  1592     }
  2093     }
  1593     switch($_POST['urlscheme'])
  2094     switch($_POST['urlscheme'])
  1594     {
  2095     {