Location: PHPKode > projects > Web Application Gateway > wagateway/install/inst_20_inc.php
<?

/*************************************************************************************

    COPYRIGHT NOTICE

    This copyright notice must appear at the top of all scripts which are part of
    the Web Application Gateway package.

    Copyright (C) 2001-2008 Gregory Engel
    
    All rights reserved
    
    8547 E Arapahoe Rd, #J-504
    Greenwood Village, CO  80112 USA
    hide@address.com

    This program is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free Software
    Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

    The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
    A copy is included with the WAG package and is found in the text file gpl.txt

    You should have received a copy of the GNU General Public License (gpl.txt, gpl.html)
    along with the WAG distribution package; if not, the GNU General Public License can
    be found at http://www.gnu.org/copyleft/gpl.html, or by writing to:
    
    Free Software Foundation, Inc.
    59 Temple Place - Suite 330
    Boston, MA  02111-1307, USA.

    This script is part of the Web Application Gateway (WAG) Project. The WAG software
    is free, subject to the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 2 of the License, or (at your option) any
    later version.
    
    $Revision: 49 $
    $LastChangedDate: 2008-01-14 14:21:17 -0700 (Mon, 14 Jan 2008) $
    $LastChangedBy: gpeangel $
 
*************************************************************************************/

if (isset($_REQUEST["usr_first_name"]))
    {
    $usr_first_name = trim(strip_tags($_REQUEST["usr_first_name"]));
    
    if (strlen($usr_first_name) == 0)
        {
        $usr_first_name = "Site";
        }
    }
else
    {
    $usr_first_name = "Site";
    }

if (isset($_REQUEST["usr_last_name"]))
    {
    $usr_last_name = trim(strip_tags($_REQUEST["usr_last_name"]));
    
    if (strlen($usr_last_name) == 0)
        {
        $usr_last_name = "Administrator";
        }
    }
else
    {
    $usr_last_name = "Administrator";
    }

if (isset($_REQUEST["usr_last_name"]))
    {
    $usr_last_name = trim(strip_tags($_REQUEST["usr_last_name"]));
    
    if (strlen($usr_last_name) == 0)
        {
        $usr_last_name = "Administrator";
        }
    }
else
    {
    $usr_last_name = "Administrator";
    }



if (!isset($site_name) || strlen(strip_tags($site_name)) == 0)
    {
    $site_name = "Web Applications (".$_SERVER["HTTP_HOST"].")";
    }

if (!isset($usr_logon_id) || strlen(strip_tags($usr_logon_id)) == 0)
    {
    $usr_logon_id = "admin";
    }

if (!isset($db_server) || strlen(strip_tags($db_server)) == 0)
    {
    $db_server = "localhost";
    }

if (!isset($db_table_prefix) || strlen(strip_tags($db_table_prefix)) == 0)
    {
    $db_table_prefix = "wagateway_";
    }
        
?>

<br>

<table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid black 1px; padding-left: 15px; padding-right: 15px;" width="600px">
    <tr>
        <td>
        
            <p>The install script has discovered the following software installed on the server:</p>
            
            <ul>
            
                <?
                
                $ary_temp = split(" ", $_SERVER['SERVER_SOFTWARE']);
                
                sort($ary_temp);
                
                foreach ($ary_temp as $value)
                    {
                    echo "<li>".$value."</li>";
                    }

                ?>
            
            </ul>
        
            <p>WAG is currently installed in the following directory:</p>
            
            <ul><li><? echo $_SERVER['DOCUMENT_ROOT'].preg_replace("/\/(install|INSTALL)$/","", dirname($_SERVER['SCRIPT_NAME'])); ?></li></ul>
        
        </td>
    </tr>
</table>

<?

// A custom error handler is used in this script to report php errors in a more
// user friendly manner.

error_reporting(0);

$old_error_handler = set_error_handler("wagErrorHandler");

$_SESSION["WAGATEWAY"]["system_error_message"] = "";

/* Check again if the config file exists. */

if (!file_exists("../config.php"))
    {
    /* Attempt to create the config file. */
    if ($config_file = fopen("../config.php", "a+"))
        {
        fclose($config_file);
        unlink("../config.php");
        }
    else
        {
        trigger_error("config_file_permission_denied", E_USER_ERROR);
        }
    }
else
    {
    if(!is_writable("../config.php"))
        {
        trigger_error("config_file_write_denied", E_USER_ERROR);
        }
    }
    
if(strlen($_SESSION["WAGATEWAY"]["system_error_message"]) > 0)
    {
    ?>
    
    <br>
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid red 2px; padding-left: 15px; padding-right: 15px;" width="600px">
        <tr>
            <td>
            
                <p><b>The following error conditions exist.  These must be corrected before configuration can proceed.</b></p>
                
                <ul>
                
                <? echo $_SESSION["WAGATEWAY"]["system_error_message"]; ?>
                
                </ul>
            
            </td>
        </tr>
    </table>
    
    <br>
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="20" cellspacing="0" style="border: solid black 1px;" width="600px">
        <tr>
            <td align="center">
                <form action="<? echo $_SERVER["PHP_SELF"]; ?>" id="recheck" method="post" name="recheck" target="_top">
                    <input type="hidden" name="inst_step" value=20 />
                    <input name="btn_recheck" type="submit" style="width: 150px;" value="Retry">
                </form>
            </td>
        </tr>
    </table>

    <?
    }
else
    {
    
    if (is_array($_SESSION["WAGATEWAY"]["data_error"]))
        {
        if (count($_SESSION["WAGATEWAY"]["data_error"]) > 0)
            {
            ?>
            
            <br>
            
            <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid red 2px; padding-left: 15px; padding-right: 15px;" width="600px">
                <tr>
                    <td>
                    
                        <p><b>The following error conditions exist.  These must be corrected before configuration can proceed.</b></p>
                        
                        <ul>
                        
                            <?
                            foreach ($_SESSION["WAGATEWAY"]["data_error"] as $error_value)
                                {
                                echo $_SESSION["WAGATEWAY"]["data_error"][$error_value];
                                } 
                            ?>
                        
                        </ul>
                    
                    </td>
                </tr>
            </table>
        
            <?
            }
        }
        
    ?>
    
    <br>
    
    <form action="<? echo $_SERVER["PHP_SELF"]; ?>" id="accept" method="post" name="accept" target="_top">
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid black 1px; padding-left: 15px; padding-right: 15px;" width="600px">
        <tr>
            <td align="left" colspan="2" style="border-bottom: solid black 1px;"><b>Site Information</b></td>
        </tr>
        <tr>
            <td align="right" width="175px">Site Name:</td>
            <td align="left"><input id="site_name" name="site_name" style="font-family: courier; width: 350px;" type="text" value="<? echo $site_name; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">Require SSL:</td>
            <td align="left"><input id="require_ssl" name="require_ssl" type="checkbox" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">Setup as Demo Site:</td>
            <td align="left"><input id="demo_mode" name="demo_mode" type="checkbox" /></td>
        </tr>
    </table>
    
    <br>
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid black 1px; padding-left: 15px; padding-right: 15px;" width="600px">
        <tr>
            <td align="left" colspan="2" style="border-bottom: solid black 1px;"><b>Site Administrator</b></td>
        </tr>
        <tr>
            <td align="right" width="175px">First Name:</td>
            <td align="left"><input id="usr_first_name" name="usr_first_name" style="font-family: courier;" type="text" value="<? echo $usr_first_name; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">Last Name:</td>
            <td align="left"><input id="usr_last_name" name="usr_last_name" style="font-family: courier;" type="text" value="<? echo $usr_last_name; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("usr_logon_id", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>Login Name:</td>
            <td align="left"><input id="usr_logon_id" name="usr_logon_id" style="font-family: courier;" type="text" value="<? echo $usr_logon_id; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("usr_password", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>Password:</td>
            <td align="left"><input id="usr_password" name="usr_password" style="font-family: courier;" type="text" value="<? echo $usr_password; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">E-mail:</td>
            <td align="left"><input id="usr_email" name="usr_email" style="font-family: courier;" type="text" value="<? echo $usr_email; ?>" /></td>
        </tr>
    </table>
    
    <br>
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="4" cellspacing="0" style="border: solid black 1px; padding-left: 15px; padding-right: 15px;" width="600px">
        <tr>
            <td align="left" colspan="2" style="border-bottom: solid black 1px;"><b>MySQL Database</b></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("db_server", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>Server Name/IP:</td>
            <td align="left"><input id="db_server" name="db_server" style="font-family: courier;" type="text" value="<? echo $db_server; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("db_name", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>Database Name:</td>
            <td align="left"><input id="db_name" name="db_name" style="font-family: courier;" type="text" value="<? echo $db_name; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("db_user_name", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>User Name:</td>
            <td align="left"><input id="db_user_name" name="db_user_name" style="font-family: courier;" type="text" value="<? echo $db_user_name; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px" <? if (is_array($_SESSION["WAGATEWAY"]["data_error"])) { if (in_array("db_user_password", $_SESSION["WAGATEWAY"]["data_error"])) { echo "style=\"color: #ff0033;\""; } } ?>>User Password:</td>
            <td align="left"><input id="db_user_password" name="db_user_password" style="font-family: courier;" type="text" value="<? echo $db_user_password; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">Table Name Prefix:</td>
            <td align="left"><input id="db_table_prefix" name="db_table_prefix" style="font-family: courier;" type="text" value="<? echo $db_table_prefix; ?>" /></td>
        </tr>
        <tr>
            <td align="right" width="175px">Delete Existing Tables:</td>
            <td align="left"><input id="overwrite_tables" name="overwrite_tables" type="checkbox" /><label for="overwrite_tables">(<font style="color: red;">Check this box for first time installations.</font>)</td>
        </tr>
    </table>
    
    <br>
    
    <table align="center" bgcolor="#f5f5f5" border="0" cellpadding="20" cellspacing="0" style="border: solid black 1px;" width="600px">
        <tr>
            <td align="center">
                <input type="hidden" name="inst_step" value=30 />
                <input name="btn_install" type="submit" style="width: 150px;" value="Install">
            </td>
        </tr>
    </table>
    
    </form>
    
    <?
    }

error_reporting(E_ALL ^ E_NOTICE);

?>

Return current item: Web Application Gateway