install.php
changeset 331 03850e101d7f
parent 330 c94af5b5c40f
child 332 000773138650
equal deleted inserted replaced
330:c94af5b5c40f 331:03850e101d7f
    62 function is_page($p)
    62 function is_page($p)
    63 {
    63 {
    64   return true;
    64   return true;
    65 }
    65 }
    66 
    66 
       
    67 function microtime_float()
       
    68 {
       
    69   list($usec, $sec) = explode(" ", microtime());
       
    70   return ((float)$usec + (float)$sec);
       
    71 }
       
    72 
    67 require('includes/wikiformat.php');
    73 require('includes/wikiformat.php');
    68 require('includes/constants.php');
    74 require('includes/constants.php');
    69 require('includes/rijndael.php');
    75 require('includes/rijndael.php');
    70 require('includes/functions.php');
    76 require('includes/functions.php');
    71 require('includes/dbal.php');
    77 require('includes/dbal.php');
    72 require('includes/lang.php');
    78 require('includes/lang.php');
    73 require('includes/json.php');
    79 require('includes/json.php');
       
    80 
       
    81 // Initialize language support
       
    82 $lang = new Language('eng');
       
    83 $lang->load_file('./language/english/install.json');
    74 
    84 
    75 strip_magic_quotes_gpc();
    85 strip_magic_quotes_gpc();
    76 
    86 
    77 //
    87 //
    78 // INSTALLER LIBRARY
    88 // INSTALLER LIBRARY
   821 }
   831 }
   822 function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
   832 function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
   823 
   833 
   824 function show_license($fb = false)
   834 function show_license($fb = false)
   825 {
   835 {
       
   836   global $lang;
   826   ?>
   837   ?>
   827   <div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
   838   <div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
   828   <?php
   839   <?php
   829     if ( !file_exists('./GPL') || !file_exists('./language/english/install/license-deed.html') )
   840     if ( !file_exists('./GPL') || !file_exists('./language/english/install/license-deed.html') )
   830     {
   841     {
  1073     exit;
  1084     exit;
  1074     break;
  1085     break;
  1075   default:
  1086   default:
  1076     break;
  1087     break;
  1077 }
  1088 }
  1078 
       
  1079 // Initialize language support
       
  1080 $lang = new Language('eng');
       
  1081 $lang->load_file('./language/english/install.json');
       
  1082 
  1089 
  1083 $template = new template_nodb();
  1090 $template = new template_nodb();
  1084 $template->load_theme('stpatty', 'shamrock', false);
  1091 $template->load_theme('stpatty', 'shamrock', false);
  1085 
  1092 
  1086 $modestrings = Array(
  1093 $modestrings = Array(
  1687               </p>
  1694               </p>
  1688             </td>
  1695             </td>
  1689           </tr>
  1696           </tr>
  1690         </table>
  1697         </table>
  1691       </div>
  1698       </div>
       
  1699       <?php
       
  1700       break;
       
  1701     case 'database_pgsql':
       
  1702       ?>
       
  1703     <script type="text/javascript">
       
  1704       function ajaxGet(uri, f) {
       
  1705         if (window.XMLHttpRequest) {
       
  1706           ajax = new XMLHttpRequest();
  1692         } else {
  1707         } else {
  1693           if (window.ActiveXObject) {           
  1708           if (window.ActiveXObject) {           
  1694             ajax = new ActiveXObject("Microsoft.XMLHTTP");
  1709             ajax = new ActiveXObject("Microsoft.XMLHTTP");
  1695           } else {
  1710           } else {
  1696             alert('Enano client-side runtime error: No AJAX support, unable to continue');
  1711             alert('Enano client-side runtime error: No AJAX support, unable to continue');
  1723       function ajaxTestConnection()
  1738       function ajaxTestConnection()
  1724       {
  1739       {
  1725         v = verify();
  1740         v = verify();
  1726         if(!v)
  1741         if(!v)
  1727         {
  1742         {
  1728           alert('One or more of the form fields is incorrect. Please correct any information in the form that has an "X" next to it.');
  1743           alert($lang.get('meta_msg_err_verification'));
  1729           return false;
  1744           return false;
  1730         }
  1745         }
  1731         var frm = document.forms.dbinfo;
  1746         var frm = document.forms.dbinfo;
  1732         db_host      = escape(frm.db_host.value.replace('+', '%2B'));
  1747         db_host      = escape(frm.db_host.value.replace('+', '%2B'));
  1733         db_name      = escape(frm.db_name.value.replace('+', '%2B'));
  1748         db_name      = escape(frm.db_name.value.replace('+', '%2B'));
  1735         db_pass      = escape(frm.db_pass.value.replace('+', '%2B'));
  1750         db_pass      = escape(frm.db_pass.value.replace('+', '%2B'));
  1736         db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
  1751         db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
  1737         db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
  1752         db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
  1738         
  1753         
  1739         parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
  1754         parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
  1740         ajaxPost('<?php echo scriptPath; ?>/install.php?mode=pgsql_test', parms, function() {
  1755         ajaxPost('<?php echo scriptPath; ?>/install.php?mode=mysql_test', parms, function() {
  1741             if(ajax.readyState==4)
  1756             if(ajax.readyState==4)
  1742             {
  1757             {
  1743               s = ajax.responseText.substr(0, 4);
  1758               s = ajax.responseText.substr(0, 4);
  1744               t = ajax.responseText.substr(4, ajax.responseText.length);
  1759               t = ajax.responseText.substr(4, ajax.responseText.length);
  1745               if(s.substr(0, 4)=='good')
  1760               if(s.substr(0, 4)=='good')
  1746               {
  1761               {
  1747                 document.getElementById('s_db_host').src='images/good.gif';
  1762                 document.getElementById('s_db_host').src='images/good.gif';
  1748                 document.getElementById('s_db_name').src='images/good.gif';
  1763                 document.getElementById('s_db_name').src='images/good.gif';
  1749                 document.getElementById('s_db_auth').src='images/good.gif';
  1764                 document.getElementById('s_db_auth').src='images/good.gif';
  1750                 document.getElementById('s_db_root').src='images/good.gif';
  1765                 document.getElementById('s_db_root').src='images/good.gif';
  1751                 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.';
  1766                 if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_warn_creating_db');
  1752                 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.';
  1767                 if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_warn_creating_user');
  1753                 document.getElementById('s_mysql_version').src='images/good.gif';
  1768                 document.getElementById('s_mysql_version').src='images/good.gif';
  1754                 document.getElementById('e_mysql_version').innerHTML = 'Your version of PostgreSQL meets Enano requirements.';
  1769                 document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_info_mysql_good');
  1755               }
  1770               }
  1756               else
  1771               else
  1757               {
  1772               {
  1758                 switch(s)
  1773                 switch(s)
  1759                 {
  1774                 {
  1760                 case 'host':
  1775                 case 'host':
  1761                   document.getElementById('s_db_host').src='images/bad.gif';
  1776                   document.getElementById('s_db_host').src='images/bad.gif';
  1762                   document.getElementById('s_db_name').src='images/unknown.gif';
  1777                   document.getElementById('s_db_name').src='images/unknown.gif';
  1763                   document.getElementById('s_db_auth').src='images/unknown.gif';
  1778                   document.getElementById('s_db_auth').src='images/unknown.gif';
  1764                   document.getElementById('s_db_root').src='images/unknown.gif';
  1779                   document.getElementById('s_db_root').src='images/unknown.gif';
  1765                   document.getElementById('e_db_host').innerHTML = '<b>Error:<\/b> The database server "'+document.forms.dbinfo.db_host.value+'" couldn\'t be contacted.<br \/>'+t;
  1780                   document.getElementById('e_db_host').innerHTML = $lang.get('database_msg_err_mysql_connect', { db_host: document.forms.dbinfo.db_host.value, mysql_error: t });
  1766                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
  1781                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
  1767                   break;
  1782                   break;
  1768                 case 'auth':
  1783                 case 'auth':
  1769                   document.getElementById('s_db_host').src='images/good.gif';
  1784                   document.getElementById('s_db_host').src='images/good.gif';
  1770                   document.getElementById('s_db_name').src='images/unknown.gif';
  1785                   document.getElementById('s_db_name').src='images/unknown.gif';
  1771                   document.getElementById('s_db_auth').src='images/bad.gif';
  1786                   document.getElementById('s_db_auth').src='images/bad.gif';
  1772                   document.getElementById('s_db_root').src='images/unknown.gif';
  1787                   document.getElementById('s_db_root').src='images/unknown.gif';
  1773                   document.getElementById('e_db_auth').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
  1788                   document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_err_mysql_auth', { mysql_error: t });
  1774                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
  1789                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
  1775                   break;
  1790                   break;
  1776                 case 'perm':
  1791                 case 'perm':
  1777                   document.getElementById('s_db_host').src='images/good.gif';
  1792                   document.getElementById('s_db_host').src='images/good.gif';
  1778                   document.getElementById('s_db_name').src='images/bad.gif';
  1793                   document.getElementById('s_db_name').src='images/bad.gif';
  1779                   document.getElementById('s_db_auth').src='images/good.gif';
  1794                   document.getElementById('s_db_auth').src='images/good.gif';
  1780                   document.getElementById('s_db_root').src='images/unknown.gif';
  1795                   document.getElementById('s_db_root').src='images/unknown.gif';
  1781                   document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> Access to the specified database using those login credentials was denied.<br \/>'+t;
  1796                   document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_err_mysql_dbperm', { mysql_error: t });
  1782                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
  1797                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
  1783                   break;
  1798                   break;
  1784                 case 'name':
  1799                 case 'name':
  1785                   document.getElementById('s_db_host').src='images/good.gif';
  1800                   document.getElementById('s_db_host').src='images/good.gif';
  1786                   document.getElementById('s_db_name').src='images/bad.gif';
  1801                   document.getElementById('s_db_name').src='images/bad.gif';
  1787                   document.getElementById('s_db_auth').src='images/good.gif';
  1802                   document.getElementById('s_db_auth').src='images/good.gif';
  1788                   document.getElementById('s_db_root').src='images/unknown.gif';
  1803                   document.getElementById('s_db_root').src='images/unknown.gif';
  1789                   document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> The specified database does not exist<br \/>'+t;
  1804                   document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_err_mysql_dbexist', { mysql_error: t });
  1790                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
  1805                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
  1791                   break;
  1806                   break;
  1792                 case 'root':
  1807                 case 'root':
  1793                   document.getElementById('s_db_host').src='images/good.gif';
  1808                   document.getElementById('s_db_host').src='images/good.gif';
  1794                   document.getElementById('s_db_name').src='images/unknown.gif';
  1809                   document.getElementById('s_db_name').src='images/unknown.gif';
  1795                   document.getElementById('s_db_auth').src='images/unknown.gif';
  1810                   document.getElementById('s_db_auth').src='images/unknown.gif';
  1796                   document.getElementById('s_db_root').src='images/bad.gif';
  1811                   document.getElementById('s_db_root').src='images/bad.gif';
  1797                   document.getElementById('e_db_root').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
  1812                   document.getElementById('e_db_root').innerHTML = $lang.get('database_msg_err_mysql_auth', { mysql_error: t });
  1798                   document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
  1813                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
  1799                   break;
  1814                   break;
  1800                 case 'vers':
  1815                 case 'vers':
  1801                   document.getElementById('s_db_host').src='images/good.gif';
  1816                   document.getElementById('s_db_host').src='images/good.gif';
  1802                   document.getElementById('s_db_name').src='images/good.gif';
  1817                   document.getElementById('s_db_name').src='images/good.gif';
  1803                   document.getElementById('s_db_auth').src='images/good.gif';
  1818                   document.getElementById('s_db_auth').src='images/good.gif';
  1804                   document.getElementById('s_db_root').src='images/good.gif';
  1819                   document.getElementById('s_db_root').src='images/good.gif';
  1805                   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.';
  1820                   if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_warn_creating_db');
  1806                   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.';
  1821                   if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_warn_creating_user');
  1807                   
  1822                   
  1808                   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().';
  1823                   document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_err_mysql_version', { mysql_version: t });
  1809                   document.getElementById('s_mysql_version').src='images/bad.gif';
  1824                   document.getElementById('s_mysql_version').src='images/bad.gif';
  1810                 default:
  1825                 default:
  1811                   alert(t);
  1826                   alert(t);
  1812                   break;
  1827                   break;
  1813                 }
  1828                 }
  1876         else    frm._cont.disabled = true;
  1891         else    frm._cont.disabled = true;
  1877         return ret;
  1892         return ret;
  1878       }
  1893       }
  1879       window.onload = verify;
  1894       window.onload = verify;
  1880     </script>
  1895     </script>
  1881     <p>Now we need some information that will allow Enano to contact your database server. Enano uses PostgreSQL as a data storage backend,
  1896     <p><?php echo $lang->get('database_blurb_needdb'); ?></p>
  1882        and we need to have access to a PostgreSQL server in order to continue.</p>
  1897     <p><?php echo $lang->get('database_blurb_howtomysql'); ?></p>
  1883     <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
  1898     <?php
  1884        <a href="http://www.postgresql.org/">PostgreSQL.org</a>.</p>
  1899     if ( file_exists('/etc/enano-is-virt-appliance') )
       
  1900     {
       
  1901       echo '<p>
       
  1902               ' . $lang->get('database_vm_login_info', array( 'host' => 'localhost', 'user' => 'enano', 'pass' => 'clurichaun', 'name' => 'enano_www1' )) . '
       
  1903             </p>';
       
  1904     }
       
  1905     ?>
  1885     <form name="dbinfo" action="install.php?mode=website" method="post">
  1906     <form name="dbinfo" action="install.php?mode=website" method="post">
  1886       <input type="hidden" name="db_driver" value="postgresql" />
  1907       <input type="hidden" name="db_driver" value="postgresql" />
  1887       <table border="0">
  1908       <table border="0">
  1888         <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
  1909         <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
  1889         <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>
  1910         <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>
  2354       start_install_table();
  2375       start_install_table();
  2355       
  2376       
  2356       // Are we just trying to auto-rename the config files? If so, skip everything else
  2377       // Are we just trying to auto-rename the config files? If so, skip everything else
  2357       if ( !isset($_GET['stage']) || ( isset($_GET['stage']) && $_GET['stage'] != 'renameconfig' ) )
  2378       if ( !isset($_GET['stage']) || ( isset($_GET['stage']) && $_GET['stage'] != 'renameconfig' ) )
  2358       {
  2379       {
  2359       
       
  2360         // The stages connect, decrypt, genkey, and parse are preprocessing and don't do any actual data modification.
  2380         // The stages connect, decrypt, genkey, and parse are preprocessing and don't do any actual data modification.
  2361         // Thus, they need to be run on each retry, e.g. never skipped.
  2381         // Thus, they need to be run on each retry, e.g. never skipped.
  2362         run_installer_stage('connect', $lang->get('install_stg_connect_title'), 'stg_mysql_connect', $lang->get('install_stg_connect_body'), false);
  2382         run_installer_stage('connect', $lang->get('install_stg_connect_title'), 'stg_mysql_connect', $lang->get('install_stg_connect_body'), false);
  2363         if ( isset($_POST['drop_tables']) )
  2383         if ( isset($_POST['drop_tables']) )
  2364         {
  2384         {