<?php
function chkIsPaswordAreSame($password_field, $confirm_password_field, $err_tip = "")
{
    global $san_arr;
    global $err_msg;
    $is_ok = $san_arr[$password_field] != "" && $san_arr[$confirm_password_field] != "" && $san_arr[$password_field] == $san_arr[$confirm_password_field] ? true : false;
    if (!$is_ok) {
        $err_msg .= "<li>" . $err_tip . "</li>";
    }
    return $is_ok;
}

function updateAdminPassword($password)
{
    global $san_arr;
    global $CFG;
    $db = mysql_connect($CFG['db']['hostname'], $CFG['db']['username'], $CFG['db']['password']);
    mysql_select_db($CFG['db']['name']);
    $sql = "UPDATE " . $CFG['db']['tbl']['users'] . " SET password = '" . addslashes(md5($password)) . "' WHERE user_id = 1";
    $rs  = mysql_query($sql);
    if (!$rs) {
        trigger_error($db->ErrorNo() . " " . $db->ErrorMsg(), E_USER_ERROR);
    }
    $_SESSION['admin_password'] = $password;
}

require_once("./common/configs/config.inc.php");
require_once("./common/configs/config_developer.inc.php");
require_once("./common/configs/config_templates.inc.php");
require_once("./common/classes/swiftmailer/lib/EasySwift.php");
require_once("./common/installFunctions.php");
session_start();
setPageBlockNames(array(
    "msg_form_error",
    "msg_error",
    "form_index",
    "form_password",
    "form_access",
    "form_access_err",
    "form_db_setup",
    "form_api_setup",
    "msg_form_success",
    "form_finished"
));
$installObj = new installHandler();
setAllPageBlocksHide();
setPageBlockShow("form_index");
if (isset($_POST['submit_req']) && $_POST['submit_req']) {
    sanitizeFormInputs($_POST);
    setAllPageBlocksHide();
    setPageBlockShow("form_access");
} else if (isset($_POST['submit_index']) && $_POST['submit_index']) {
    sanitizeFormInputs($_POST);
    if (is_writable("./common/configs/config_db.inc.php")) {
        setAllPageBlocksHide();
        setPageBlockShow("form_db_setup");
    } else {
        setAllPageBlocksHide();
        $err_msg = "Error found! Write permission missing for some files/folders";
        setPageBlockShow("msg_form_error");
        setPageBlockShow("form_access");
    }
}
if (isset($_POST['submit_db']) && $_POST['submit_db']) {
    sanitizeFormInputs($_POST);
    $sql = "Create database " . $san_arr['dbname'];
    chkIsNotEmpty("dbname", "Database Name Empty");
    chkIsNotEmpty("dbhost", "Host Name Empty");
    if ($san_arr['default_sql'] == "Yes") {
        if (chkIsNotEmpty("dbuser", "Database User Name Empty") && ($rs = connectDB())) {
            parse_mysql_dump();
        }
    } else {
        if (chkIsNotEmpty("dbuser", "Database User Name Empty") && ($rs = connectDB())) {
            checkDB();
        }
    }
    chkIsNotEmpty("default_sql", "Select an option for Execute sql");
    if ($err_msg == "") {
        setAllPageBlocksHide();
        writeDBConfig();
        setPageBlockShow("form_password");
    } else {
        setAllPageBlocksHide();
        setPageBlockShow("msg_error");
        setPageBlockShow("form_db_setup");
    }
} else if (isset($_POST['submit_password']) && $_POST['submit_password']) {
    $san_arr = array();
    sanitizeFormInputs($_POST);
    if (chkIsNotEmpty("password", "Enter password and confirm password") && chkIsNotEmpty("confirm_password", "Enter password and confirm password")) {
        chkispaswordaresame("password", "confirm_password", "Passwords must be the same");
    }
    setAllPageBlocksHide();
    if ($err_msg == "") {
        updateadminpassword($san_arr['password']);
        setPageBlockShow("form_api_setup");
    } else {
        setPageBlockShow("msg_error");
        setPageBlockShow("form_password");
    }
} else if (isset($_POST['submit_api']) && $_POST['submit_api']) {
    sanitizeFormInputs($_POST);
    WriteConfigEmailApi();
    if ($CFG['feature']['msn']) {
        WriteMSNApplication();
    }
    setAllPageBlocksHide();
    setPageBlockShow("form_finished");
} else if (isset($_POST['skip_api']) && $_POST['skip_api']) {
    sanitizeFormInputs($_POST);
    setAllPageBlocksHide();
    setPageBlockShow("form_finished");
}
echo "<?xml version=\"1.0\"?>\r\n" . "\n";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html lang=\"en-US\" dir=\"ltr\" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n\t<head>\r\n\t\t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=UTF-8\" />\r\n\t\t<meta http-equiv=\"content-Language\" content=\"en-US\" />\r\n\t\t<meta name=\"keywords\" content=\"";
echo $CFG['admin']['product_name'];
echo ", , Answers Over Video and Audio, Yahoo Answers, Wiki Answers, Video, Audio, Agriya, Text, Share, Knowledge, Rayzz, Online Community\" />\r\n\t\t<meta name=\"description\" content=\"";
echo $CFG['admin']['product_name'];
echo " - Answers Over Video and Audio. Anova is the first answers script to feature Text, Audio and Video. Making knowledge and learning fun, Anova brings a whole new concept to Answers sites.\" />\r\n";
if ($CFG['html']['meta']['MSSmartTagsPreventParsing']) {
    echo "\t\t<!-- Disable MSSmartTags -->\r\n\t\t<meta name=\"MSSmartTagsPreventParsing\" content=\"true\" />\r\n";
}
if (!$CFG['html']['meta']['imagetoolbar']) {
    echo "\t\t<!-- Disable IE6 image toolbar -->\r\n\t\t<meta http-equiv=\"imagetoolbar\" content=\"no\" />\r\n";
}
echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"";
echo $CFG['site']['url'];
echo "design/templates/";
echo $CFG['html']['template']['default'];
echo "/root/css/";
echo $CFG['html']['stylesheet']['screen']['default'];
echo "/general.css\" media=\"screen\" title=\"Default\" />\r\n";
echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"";
echo $CFG['site']['url'];
echo "design/css/print.css\" media=\"print\" />\r\n\t\t<link rel=\"shortcut icon\" href=\"";
echo $CFG['site']['url'];
echo "design/templates/";
echo $CFG['html']['template']['default'];
echo "/favicon.ico\" type=\"image/x-icon\" />\r\n\t\t<!-- for link bar -->\r\n\t\t<link rel=\"Home\"     href=\"";
echo $CFG['site']['url'];
echo "\" title=\"Home page\" />\r\n\t\t<link rel=\"Index\"    href=\"";
echo $CFG['site']['url'];
echo "\" title=\"Index\" />\r\n\t\t<link rel=\"search\"   href=\"#\" title=\"Search this site\" />\r\n\t\t<link rel=\"contents\" href=\"#\" title=\"Site map\" />\r\n\t\t<title>";
echo $CFG['admin']['product_name'];
echo "</title>\r\n\t</head>\r\n\t<body>\r\n\t\t<div id=\"selWrapper\" class=\"clsWrapper\">\r\n\t\t\t<div class=\"clsBodyBackground\">\r\n\t\t\t\t<div id=\"";
echo $CFG['html']['page_id'];
echo "\" class=\"clsBodyContent\">\r\n  \t\t\t\t\t<div id=\"hideScreen\" style=\"z-index: 100; display: none;\" class=\"VeilStyle1c\">&nbsp;</div>\r\n  \t\t\t\t\t<!-- Accessibility Links -->\r\n  \t\t\t\t\t<div id=\"top\">\r\n    \t\t\t\t\t<ul>\r\n      \t\t\t\t\t\t<li><a href=\"#main\">Skip to main content</a></li>\r\n\t\t\t\t\t\t    <li><a href=\"#selSubHeader\">Skip to Navigation Links</a></li>\r\n\t\t\t\t\t\t    <li><a href=\"#footer\">Skip to Footer</a></li>\r\n    \t\t\t\t\t</ul>\r\n  \t\t\t\t\t</";
echo "div>\r\n  \t\t\t\t\t<!-- Header -->\r\n  \t\t\t\t\t<div id=\"header\">\r\n \t\t\t\t\t\t<div class=\"clsHeaderOverAll\" style=\"margin:0; padding:0\">\r\n   \t\t\t\t\t\t\t<div class=\"clsHeaderLeft\">\r\n\t\t\t\t\t\t\t   \t<h1 style=\"margin:2em 0 0 2em; padding:0; float:none;\">\r\n\t\t\t\t\t\t\t\t   \t<a href=\"";
echo $_SERVER['REQUEST_URI'];
echo "\" title=\"Browse to homepage\">";
echo $CFG['admin']['product_name'];
echo "</a>\r\n\t\t\t\t\t\t\t\t</h1>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n  \t\t\t\t\t</div>\r\n\r\n  \t\t\t\t\t<!--SIDEBAR-->\r\n  \t\t\t\t\t\t<div class=\"sideBar1\" id=\"sideBar\">\r\n\t\t\t\t\t\t  \t<div class=\"clsInnerContainer\">\r\n\t\t\t\t\t\t\t<div class=\"\">\r\n\t\t\t\t\t\t\t  <div><h2>Steps</h2></div>\r\n                                           <div class=\"lbsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t  <div class=\"rbsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t   <div class=\"bbsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t";
echo "\t<div class=\"blcsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div class=\"brcsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t  <div class=\"tbsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"tlcsidebarsections\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t <div class=\"trcsidebarsections\">\r\n                                                                            <div class=\"\">\r\n                                                                                <div class=";
echo "\"\">\r\n\r\n                                                                                    <div class=\"\">\r\n                                                                                        <div class=\"clsInstallSteps\">\r\n                                                                                            <ul class=\"clsInstall\">\r\n                                                            ";
echo "                                    <li ";
if (isShowPageBlock("form_index")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">1. Pre-installation Check</li>\r\n                                                                                                <li ";
if (isShowPageBlock("form_access")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">2. Write permission</li>\r\n                                                                                                <li ";
if (isShowPageBlock("form_db_setup")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">3. Database</li>\r\n                                                                                                <li ";
if (isShowPageBlock("form_password")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">4. Admin Password</li>\r\n                                                                                                <li ";
if (isShowPageBlock("form_api_setup")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">5. External API setup</li>\r\n                                                                                                <li ";
if (isShowPageBlock("form_finished")) {
    echo "class=\"clsActiveInstallLink\"";
}
echo ">7. Finish</li>\r\n                                                                                            </ul>\r\n                                                                                        </div>\r\n                                                                                    </div>\r\n                                                                                </div>\r\n             ";
echo "                                                               </div>\r\n                                                                        </div>\r\n                                                                    </div>\r\n                                                                </div>\r\n                                                            </div>\r\n                                      ";
echo "                  </div>\r\n                                                    </div>\r\n                                                </div>\r\n                                            </div>\r\n                                        </div>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n  \t\t\t\t\t<!--end of SIDEBAR-->\r\n\r\n  \t\t\t\t\t<!-- Main -->\r\n  \t\t\t\t\t<div id=\"main\" class=\"clsMain\">\r\n                  \t<div class=\"clsInstallPageC";
echo "ont clsClearFix\">\r\n                            <div class=\"clsInstalRight\">\r\n\t\t\t\t\t\t\t <div class=\"clsPageHeading\"><h2>";
echo $CFG['admin']['product_name'];
echo " Installation</h2></div>\r\n                                     <div class=\"lbindex\">\r\n                                                <div class=\"rbindex\">\r\n                                                    <div class=\"bbindex\">\r\n                                                        <div class=\"blcindex\">\r\n                                                            <div class=\"brcindex\">\r\n           ";
echo "                                                     <div class=\"tbindex\">\r\n                                                                    <div class=\"tlcindex\">\r\n                                                                        <div class=\"trcindex\">\r\n                                                                <div id=\"selLogin\" class=\"clsClearfix\">\r\n\r\n        ";
if (isShowPageBlock("msg_form_error")) {
    echo "                                                                        <div id=\"selMsgError\">\r\n                                                                            <p>";
    echo $err_msg;
    echo "</p>\r\n                                                                        </div>\r\n        ";
}
if (isShowPageBlock("msg_form_success")) {
    echo "                                                                        <div id=\"selMsgSuccess\">\r\n                                                                            <p>";
    echo $err_msg;
    echo "</p>\r\n                                                                        </div>\r\n        ";
}
if (isShowPageBlock("form_index")) {
    echo "                                                                        <div class=\"clsLoginSignup\">\r\n                                                                            <h3 class=\"clsStepHd\">Step 1: Pre-installation Check</h3>\r\n                                                                            <div class=\"clsDataTable\">\r\n                                                               ";
    echo "                 <table class=\"clsInstallTable\">\r\n                                                                                    <tr><th>";
    echo $CFG['admin']['product_name'];
    echo " Requirements</th></tr>\r\n                                                                                    <tr><td>If any of these items are not supported (marked as No), your system does not meet the minimum requirements for installation. Please take appropriate actions to correct the errors. Failure to do so could lead to your ";
    echo $CFG['admin']['product_name'];
    echo "! installation not functioning properly.</td></tr>\r\n                                                                                </table>\r\n                                                                            </div>\r\n                                                                            <div class=\"clsDataTable\">\r\n                                                                           ";
    echo "     <table class=\"clsInstallTable\">\r\n                                                                                    <tr>\r\n                                                                                        <th>Requirements</th>\r\n                                                                                        <th>You have</th>\r\n                                                            ";
    echo "                            <th>Status</th>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>PHP ver 5</td>\r\n                                                                        ";
    echo "                <td><p ";
    $phpversion = phpversion();
    if (( integer ) $phpversion < 5) {
        echo "class=\"clsRequirementsNotOK\"";
    } else {
        echo "class=\"clsRequirementsOK\"";
    }
    echo ">PHP ver ";
    echo $phpversion;
    echo "</p></td>\r\n                                                                                        <td>\r\n        ";
    if (( integer ) $phpversion < 5) {
        echo "<span class=\"clsRequirementsNotOK\">Error</span>";
        $err_msg = "Error found! " . $CFG['admin']['product_name'] . " requirement missing.";
    } else {
        echo "<span class=\"clsRequirementsOK\">Ok</span>";
    }
    echo "                                                                                        </td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>GD</td>\r\n                            ";
    echo "                                                            <td>\r\n        ";
    if (function_exists("imagecreatetruecolor")) {
        echo "<span class=\"clsRequirementsOK\">GD2</span>";
    } else if (function_exists("imagecreate")) {
        echo "<span class=\"clsRequirementsOK\">GD</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Not installed</span>";
        $gd_err = "Error";
    }
    echo "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td>\r\n                                                                                        <td>\r\n        ";
    if (isset($gd_err) && $gd_err != "") {
        echo "<span class=\"clsRequirementsNotOK\">Error</span>";
        $err_msg = "Error found! " . $CFG['admin']['product_name'] . " requirement missing.";
    } else {
        echo "<span class=\"clsRequirementsOK\">Ok</span>";
    }
    echo "                                                                                        </td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>CURL</td>\r\n                          ";
    echo "                                                              <td>\r\n        ";
    if (function_exists("curl_init")) {
        echo "<span class=\"clsRequirementsOK\">CURL</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Not installed</span>";
        $curl_err = "Error";
    }
    echo "                                                                                        </td>\r\n                                                                                        <td>\r\n        ";
    if (isset($curl_err) && $curl_err != "") {
        echo "<span class=\"clsRequirementsNotOK\">Error</span>";
        $err_msg = "Error found! " . $CFG['admin']['product_name'] . " requirement missing.";
    } else {
        echo "<span class=\"clsRequirementsOK\">Ok</span>";
    }
    echo "                                                                                        </td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>JSON</td>\r\n                          ";
    echo "                                                              <td>\r\n        ";
    if (function_exists("json_encode")) {
        echo "<span class=\"clsRequirementsOK\">JSON</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Not installed</span>";
        $json_error = "Error";
    }
    echo "                                                                                        </td>\r\n                                                                                        <td>\r\n        ";
    if (isset($json_error) && $json_error != "") {
        echo "<span class=\"clsRequirementsNotOK\">Error</span>";
        $err_msg = "Error found! " . $CFG['admin']['product_name'] . " requirement missing.";
    } else {
        echo "<span class=\"clsRequirementsOK\">Ok</span>";
    }
    echo "                                                                                        </td>\r\n                                                                                    </tr>\r\n                                                                                </table>\r\n                                                                            </div>\r\n                                            ";
    echo "                                <div class=\"clsDataTable\">\r\n                                                                                <table class=\"clsInstallTable\">\r\n                                                                                    <tr><th>Recommended Settings</th></tr>\r\n                                                                                    <tr><td>These are the recom";
    echo "mended settings for PHP in order to ensure full compatibility with ";
    echo $CFG['admin']['product_name'];
    echo "!.</td></tr>\r\n                                                                                </table>\r\n                                                                            </div>\r\n                                                                            <div class=\"clsDataTable\">\r\n                                                                                <table class=\"clsInstallTable\">\r\n ";
    echo "                                                                                   <tr>\r\n                                                                                        <th>Settings</th>\r\n                                                                                        <th>Recommended</th>\r\n                                                                                        <th>You have";
    echo "</th>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>safe_mode</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">Off</span></td>\r\n                                                                                        <td>";
    if (ini_get("safe_mode")) {
        echo "<span class=\"clsRequirementsNotOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>register_globals</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">Off</span></td>\r\n                                                                                        <td>";
    if (ini_get("register_globals")) {
        echo "<span class=\"clsRequirementsNotOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>open_basedir</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">no value</span></td>\r\n                                                                                        <td>";
    if ($open_basedir = ini_get("open_basedir")) {
        echo "<span class=\"clsRequirementsNotOK\">" . $open_basedir . "</span>";
    } else {
        echo "<span class=\"clsRequirementsOK\">no value</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>output_buffering</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">On</span></td>\r\n                                                                                        <td>";
    if (ini_get("output_buffering")) {
        echo "<span class=\"clsRequirementsOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>file_uploads</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">On</span></td>\r\n                                                                                        <td>";
    if (ini_get("file_uploads")) {
        echo "<span class=\"clsRequirementsOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>upload_max_filesize</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">";
    $avail_upload_size = substr(ini_get("upload_max_filesize"), 0, 0 - 1);
    echo $req_upload_size = 200;
    echo "M (or more)</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($req_upload_size <= $avail_upload_size) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_upload_size;
    echo "M</span></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>post_max_size</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">";
    $avail_post_size = substr(ini_get("post_max_size"), 0, 0 - 1);
    echo $req_post_size = 200;
    echo "M (or more)</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($req_post_size <= $avail_post_size) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_post_size;
    echo "M</span></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>max_execution_time</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">";
    $avail_req_exec_time = ini_get("max_execution_time");
    echo $req_max_exec_time = "0";
    echo "</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($avail_req_exec_time == $req_max_exec_time) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_req_exec_time;
    echo "</span></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>max_input_time</td>\r\n                                                                                        <td>";
    echo "<s";
    echo "pan class=\"clsRequirementsOK\">";
    $avail_req_max_input_time = ini_get("max_input_time");
    echo $req_max_max_input_time = "6000";
    echo "</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($req_max_max_input_time <= $avail_req_max_input_time) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_req_max_input_time;
    echo "</span></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>magic_gpc_quotes</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">Off</span></td>\r\n                                                                                        <td>";
    if (ini_get("magic_quotes_gpc")) {
        echo "<span class=\"clsRequirementsNotOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>memory_limit</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">";
    $avail_memory_limit = substr(ini_get("memory_limit"), 0, 0 - 1);
    echo $req_memory_limit = 32;
    echo "M (or more)</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($req_memory_limit <= $avail_memory_limit) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_memory_limit;
    echo "M</span></td>\r\n\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>display_errors</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">On</span></td>\r\n                                                                                        <td>";
    if (ini_get("display_errors")) {
        echo "<span class=\"clsRequirementsOK\">On</span>";
    } else {
        echo "<span class=\"clsRequirementsNotOK\">Off</span>";
    }
    echo "</td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td>session.gc_maxlifetime</td>\r\n                                                                                        <td>";
    echo "<span class=\"clsRequirementsOK\">";
    $avail_session_gc_max = ini_get("session.gc_maxlifetime");
    echo $req_session_gc_max = "14000";
    echo " (or more)</span></td>\r\n                                                                                        <td>";
    echo "<span ";
    if ($req_session_gc_max <= $avail_session_gc_max) {
        echo "class=\"clsRequirementsOK\">";
    } else {
        echo "class=\"clsRequirementsNotOK\">";
    }
    echo $avail_session_gc_max;
    echo "</span></td>\r\n                                                                                    </tr>\r\n                                                                                </table>\r\n                                                                            </div>\r\n                                                                        </div>\r\n        ";
    if ($err_msg == "") {
        echo "                                                                        <table class=\"clsInstallTable\">\r\n                                                                            <tr>\r\n                                                                                <td>\r\n                                                                                    <form id=\"selFormIndex\" method=\"post\" action=\"";
        echo $_SERVER['PHP_SELF'];
        echo "\">\r\n                                                                                        <div class=\"clsSubmitLeft\">\r\n                                                                                            <div class=\"clsSubmitRight\">\r\n                                                                                                <input type=\"submit\" class=\"clsInstalBtn\" name=\"submit_req\" id=\"";
        echo "submit_req\" value=\"Next\" />\r\n                                                                                            </div>\r\n                                                                                        </div>\r\n                                                                                    </form>\r\n                                                                                </td>\r";
        echo "\n                                                                            </tr>\r\n                                                                        </table>\r\n        ";
    } else {
        setStepsErrorMsg($err_msg);
    }
}
if (isShowPageBlock("form_access")) {
    echo "\r\n                                                                        <div class=\"clsDataTable\">\r\n                                                                        \t<div class=\"clsLoginSignup\">\r\n\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<table class=\"clsInstallTable\">\r\n                                                                                <tr><th><h3>Step 2: Write permission</h3></th></tr>\r\n               ";
    echo "                                                                 <tr><td>Following files/folders and sub-folders needs to set to be 777</td></tr>\r\n                                                                            </table>\r\n                                                                            <table class=\"clsInstallTable\">\r\n                                                                ";
    echo "                <tr>\r\n                                                                                    <th>Name</th><th>File/Folder</th><th>Status</th>\r\n                                                                                </tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
    chkIsWritableAll("./admin/cache/");
    chkIsWritableAll("./cache/");
    chkIsWritableAll("./answers/cache/");
    chkIsWritableAll("./admin/answers/cache/");
    chkIsWritableAll("./common/configs/", true);
    chkIsWritableAll("./common/configs/anova_configs/", true);
    chkIsWritableAll("./files/");
    chkIsWritableAll("./answers/files/");
    chkIsWritableAll("./languages/", true);
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/admin/cache");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/admin/templates_c");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/admin/answers/templates_c");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/members/cache");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/members/templates_c");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/root/cache");
    chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/root/templates_c");
    chkIsWritableAll("./answers/design/templates/" . $CFG['html']['template']['default'] . "/members/cache");
    chkIsWritableAll("./answers/design/templates/" . $CFG['html']['template']['default'] . "/members/templates_c");
    chkIsWritableAll("./answers/design/templates/" . $CFG['html']['template']['default'] . "/root/cache");
    chkIsWritableAll("./answers/design/templates/" . $CFG['html']['template']['default'] . "/root/templates_c");
    if (!$CFG['admin']['module']['lite_version']) {
        if ($CFG['admin']['module']['blog']) {
            chkIsWritableAll("./blog/cache/");
            chkIsWritableAll("./admin/blog/cache/");
            chkIsWritableAll("./blog/design/templates/" . $CFG['html']['template']['default'] . "/members/cache");
            chkIsWritableAll("./blog/design/templates/" . $CFG['html']['template']['default'] . "/members/templates_c");
            chkIsWritableAll("./blog/design/templates/" . $CFG['html']['template']['default'] . "/root/cache");
            chkIsWritableAll("./blog/design/templates/" . $CFG['html']['template']['default'] . "/root/templates_c");
            chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/admin/blog/templates_c");
        }
        if ($CFG['admin']['module']['forums']) {
            chkIsWritableAll("./forums/cache/");
            chkIsWritableAll("./admin/forums/cache/");
            chkIsWritableAll("./forums/design/templates/" . $CFG['html']['template']['default'] . "/members/cache");
            chkIsWritableAll("./forums/design/templates/" . $CFG['html']['template']['default'] . "/members/templates_c");
            chkIsWritableAll("./forums/design/templates/" . $CFG['html']['template']['default'] . "/root/cache");
            chkIsWritableAll("./forums/design/templates/" . $CFG['html']['template']['default'] . "/root/templates_c");
            chkIsWritableAll("./design/templates/" . $CFG['html']['template']['default'] . "/admin/forums/templates_c");
        }
    }
    echo "                                                                            </table>\r\n                                                                        </div></div>\r\n        ";
    if ($err_msg == "") {
        echo "                                                                        <table class=\"clsInstallTable\">\r\n                                                                            <tr>\r\n                                                                                <td>\r\n                                                                                    <form id=\"selFormIndex\" method=\"post\" action=\"";
        echo $_SERVER['PHP_SELF'];
        echo "\">\r\n                                                                                        <div class=\"clsSubmitLeft\">\r\n                                                                                            <div class=\"clsSubmitRight\">\r\n                                                                                                <input type=\"submit\" class=\"clsInstalBtn\" name=\"submit_index\" id";
        echo "=\"submit_index\" value=\"Next\" />\r\n                                                                                            </div>\r\n                                                                                        </div>\r\n                                                                                    </form>\r\n                                                                                </";
        echo "td>\r\n                                                                            </tr>\r\n                                                                        </table>\r\n        ";
    } else {
        setStepsErrorMsg($err_msg);
    }
}
if (isShowPageBlock("form_access_err")) {
    echo "                                                                    <div>\r\n                                                                        <h2>Step 2: Write permission</h2>\r\n                                                                        <form id=\"selFormIndex\" method=\"post\" action=\"";
    echo $_SERVER['PHP_SELF'];
    echo "\">\r\n                                                                            <div>\r\n                                                                                <ul>";
    echo $loginfrm->file_err_msg;
    echo "</ul>\r\n                                                                            </div>\r\n                                                                            <div>\r\n                                                                                <input type=\"submit\" class=\"clsInstalBtn\" name=\"submit_index\" id=\"submit_index\" value=\"Next\" />\r\n                                                     ";
    echo "                       </div>\r\n                                                                        </form>\r\n                                                                    </div>\r\n        ";
}
if (isShowPageBlock("form_db_setup")) {
    echo "\r\n                                                                        <div class=\"clsDataTable\">\r\n                                                                            <table class=\"clsInstallTable\">\r\n                                                                                <tr><th><h3>Step 3: Database Setup</h3></th></tr>\r\n                                                                  ";
    echo "          </table>\r\n                                                                        </div>\r\n        ";
    if (isShowPageBlock("msg_error")) {
        echo "                                                                        <div class=\"clsInstallRequiredFields\" id=\"selMsgError\">\r\n                                                                            <ul>";
        echo $err_msg;
        echo "</ul>\r\n                                                                        </div>\r\n        ";
    }
    echo "                                                                        <form name=\"form_dbSetup\" id=\"selFormdbSetup\" method=\"post\" action=\"";
    echo $_SERVER['PHP_SELF'];
    echo "\" autocomplete=\"off\">\r\n                                                                            <div class=\"clsDataTable clsLoginSignup\">\r\n                                                                                <table class=\"clsInstallTable\">\r\n                                                                                    <tr>\r\n                                                          ";
    echo "                              <td class=\"form_label_cell_default\"><label for=\"dbhost\">";
    echo "Database Host";
    echo "</label></td>\r\n                                                                                        <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"dbhost\" id=\"dbhost\" tabindex=\"1000\" value=\"";
    if (getFormField("dbhost") != "") {
        echo getFormField("dbhost");
    } else {
        echo $CFG['db']['hostname'];
    }
    echo "\" /></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td class=\"form_label_cell_default\"><label for=\"dbuser\">";
    echo "Database User name";
    echo "</label></td>\r\n                                                                                        <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"dbuser\" id=\"dbuser\" tabindex=\"1005\" value=\"";
    if (getFormField("dbuser") != "") {
        echo getFormField("dbuser");
    }
    echo "\" /></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td class=\"form_label_cell_default\"><label for=\"dbpass\">";
    echo "Database Password";
    echo "</label></td>\r\n                                                                                        <td class=\"form_field_cell_default\"><input type=\"password\" class=\"clsTextBox\" name=\"dbpass\" id=\"dbpass\" tabindex=\"1010\" value=\"\" /></td>\r\n                                                                                    </tr>\r\n                                                                          ";
    echo "          <tr>\r\n                                                                                        <td class=\"form_label_cell_default\"><label for=\"dbname\">";
    echo "Database name";
    echo "</label></td>\r\n                                                                                        <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"dbname\" id=\"dbname\" tabindex=\"1015\" value=\"";
    if (getFormField("dbname") != "") {
        echo getFormField("dbname");
    } else {
        echo $CFG['db']['name'];
    }
    echo "\" /></td>\r\n                                                                                    </tr>\r\n                                                                                    <tr>\r\n                                                                                        <td class=\"form_label_cell_default\"><label for=\"default_sql\">";
    echo "Execute sql";
    echo "</label></td>\r\n                                                                                        <td class=\"form_field_cell_default\">\r\n                                                                                            ";
    echo "<select name=\"default_sql\" id=\"default_sql\" tabindex=\"1020\">\r\n                                                                                             <option value=\"\"";
    if (getFormField("default_sql") == "") {
        echo " selected=\"selected\" ";
    }
    echo ">-Choose-</option>\r\n                                                                                             <option value=\"Yes\"";
    if (getFormField("default_sql") == "Yes") {
        echo " selected=\"selected\" ";
    }
    echo ">Yes</option>\r\n                                                                                            <option value=\"No\"";
    if (getFormField("default_sql") == "No") {
        echo " selected=\"selected\" ";
    }
    echo ">&nbsp;No</option>\r\n                                                                                            </select>\r\n                                                                                        </td>\r\n                                                                                    </tr>\r\n                                                                                </table>\r\n      ";
    echo "                                                                      </div>\r\n                                                                        <div>\r\n                                                                            <table class=\"clsInstallTable\">\r\n                                                                                <tr>\r\n                                                    ";
    echo "                                <td><div class=\"clsSubmitLeft\"><div class=\"clsSubmitRight\"><input type=\"submit\" class=\"clsInstalBtn\" name=\"submit_db\" id=\"submit_db\" value=\"Next\" /></div></div></td>\r\n                                                                                </tr>\r\n                                                                            </table>\r\n                                     ";
    echo "                                   </div>\r\n                                                                    </form>\r\n        ";
}
if ($show_block['form_password']) {
    echo "\t    <div class=\"clsDataTable\">\r\n\t        <table class=\"clsInstallTable\">\r\n\t            <tr><th><h3>Step 4: Admin Password</h3></th></tr>\r\n\t        </table>\r\n\t    </div>\r\n\r\n";
    if (isset($show_block['msg_error']) && $show_block['msg_error']) {
        echo "\t\t\t  <div class=\"clsInstallRequiredFields\" id=\"selMsgError\">\r\n\t\t\t    \t<ul>\r\n\t\t\t\t\t\t";
        echo $err_msg;
        echo "\t\t\t\t\t</ul>\r\n\t\t\t  </div>\r\n";
    }
    echo "      <form name=\"selFormDefaultSettings\" id=\"selFormDefaultSettings\" method=\"post\" action=\"";
    echo $_SERVER['PHP_SELF'];
    echo "\" autocomplete=\"off\">\r\n\t\t<div class=\"clsDataTable clsLoginSignup\">\r\n\t\t<table class=\"clsInstallTable\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td class=\"form_label_cell_default\">\r\n\t\t\t\t\t<label for=\"cat_id\" style=\"font-size:12px; line-height:18px;\">";
    echo "Password";
    echo "</label>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td class=\"form_field_cell_default\">\r\n\t\t\t\t\t<input type=\"password\" name=\"password\" id=\"password\" tabindex=\"20\" maxlength=\"10\" style=\"width:200px;margin-right:10px;\" />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td class=\"form_label_cell_default\">\r\n\t\t\t\t\t<label for=\"cat_id\" style=\"font-size:12px; line-height:18px;\">";
    echo "Confirm Password";
    echo "</label>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td class=\"form_field_cell_default\">\r\n\t\t\t\t\t<input type=\"password\" name=\"confirm_password\" id=\"confirm_password\" tabindex=\"21\" maxlength=\"10\" style=\"width:200px;margin-right:10px;\" />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table></div>\r\n\t\t<div>\r\n\t\t\t<table class=\"clsInstallTable\">\r\n<tr><td><div class=\"clsSubmitLeft\"><div class=\"clsSubmitRight\"><input type=\"submit\" class=\"clsInstalBtn\" name=\"submit_pass";
    echo "word\" id=\"submit_password\" value=\"Next\" /></div></div></td></tr>\r\n</table>\r\n\t\t</div>\r\n\t  </form>\r\n\r\n    </div>\r\n    ";
}
if (isShowPageBlock("form_api_setup")) {
    echo "                                                                <div class=\"\">\r\n                                                                    <form name=\"form_apiSetup\" id=\"selFormapiSetup\" method=\"post\" action=\"";
    echo $_SERVER['REQUEST_URI'];
    echo "\" autocomplete=\"off\">\r\n                                                                        <table class=\"clsInstallTable\">\r\n                                                                            <tr>\r\n                                                                                <td colspan=\"2\">\r\n                                                                                    <h2>Yahoo Co";
    echo "ntact Import Api</h2>\r\n                                                                                    <p>To Generate Yahoo API key <a href=\"https://developer.yahoo.com/wsregapp/\" target=\"_blank\">click here</a></p>\r\n                                                                                </td>\r\n                                                                            </tr>\r\n                 ";
    echo "                                                           <tr>\r\n                                                                                <td class=\"form_label_cell_default\"><label for=\"yahoo_secret\">yahoo Secret Key</label></td>\r\n                                                                                <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"yahoo_sec";
    echo "ret\" id=\"yahoo_secret\" tabindex=\"1000\" value=\"";
    echo getFormField("yahoo_secret");
    echo "\" /></td>\r\n                                                                            </tr>\r\n                                                                            <tr>\r\n                                                                                <td class=\"form_label_cell_default\"><label for=\"yahoo_consumer\">yahoo Consumer Key</label></td>\r\n                                                      ";
    echo "                          <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"yahoo_consumer\" id=\"yahoo_consumer\" tabindex=\"1000\" value=\"";
    echo getFormField("yahoo_consumer");
    echo "\" /></td>\r\n                                                                            </tr>\r\n                                                                            <tr>\r\n                                                                                <td class=\"form_label_cell_default\"><label for=\"yahoo_appid\">Yahoo Application ID</label></td>\r\n                                                       ";
    echo "                         <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"yahoo_appid\" id=\"yahoo_appid\" tabindex=\"1005\" value=\"";
    echo getFormField("yahoo_appid");
    echo "\" /></td>\r\n                                                                            </tr>\r\n                                                                            ";
    if ($CFG['feature']['msn']) {
        echo "\t                                                                            <tr>\r\n\t                                                                                <td colspan=\"2\">\r\n\t                                                                                    <h2>MSN Contact Import Api</h2>\r\n\t                                                                                    <p>To Generate MSN A";
        echo "PI key <a href=\"http://msdn.microsoft.com/en-us/library/cc287659.aspx\" target=\"_blank\">click here<a></p>\r\n\t                                                                                </td>\r\n\t                                                                            </tr>\r\n\t                                                                            <tr>\r\n\t                                            ";
        echo "                                    <td class=\"form_label_cell_default\"><label for=\"appid\">MSN API ID</label></td>\r\n\t                                                                                <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"appid\" id=\"appid\" tabindex=\"1010\" value=\"";
        echo getFormField("appid");
        echo "\" /></td>\r\n\t                                                                            </tr>\r\n\t                                                                            <tr>\r\n\t                                                                                <td class=\"form_label_cell_default\"><label for=\"secret_key\">MSN Secret Key</label></td>\r\n\t                                                          ";
        echo "                      <td class=\"form_field_cell_default\"><input type=\"text\" class=\"clsTextBox\" name=\"secret_key\" id=\"secret_key\" tabindex=\"1010\" value=\"";
        echo getFormField("secret_key");
        echo "\" /></td>\r\n\t                                                                            </tr>\r\n\t                                                                        ";
    }
    echo "                                                                        </table>\r\n                                                                        <div class=\"clsSubmitLeft\"><div class=\"clsSubmitRight\">\r\n                                                                            <input type=\"submit\" name=\"submit_api\" id=\"submit_api\" class=\"clsInstalBtn\"  value=\"Next\" />\r\n                       ";
    echo "                                                 </div></div>\r\n                                                                        <div class=\"clsSubmitLeft\"><div class=\"clsSubmitRight\">\r\n                                                                            <input type=\"submit\" name=\"skip_api\" id=\"skip_api\" class=\"clsInstalBtn\" value=\"Skip\" />\r\n                                                ";
    echo "                        </div></div>\r\n                                                                    </form>\r\n                                                                </div>\r\n        ";
}
if (isShowPageBlock("form_finished")) {
    echo "                                                                <div class=\"clsInstallSuccess\">\r\n                                                                    <p class=\"clsCongratulations\">Congratulations! ";
    echo $CFG['admin']['product_name'];
    echo " installed successfully!!!</p>\r\n                                                                    <div class=\"clsNote\">\r\n                                                                        ";
    echo "<span>Admin details:</span>\r\n                                                                        <ul class=\"clsInstallNote\">\r\n                                                                            <li>Username: webmaster</li>\r\n                                                                            <li>Password: ";
    echo $_SESSION['admin_password'];
    echo "</li>\r\n                                                                        </ul>\r\n                                                                    </div>\r\n                                                                    <p class=\"clsDeleteFile\">";
    echo "<span>PLEASE REMEMBER TO DELETE THE \"install.php\" FILE.</span></p>\r\n                                                                    <h2><a href=\"";
    echo $CFG['site']['url'] . "index.php";
    echo "\">Go to the Site</a></h2>\r\n                                                                    <br />\r\n                                                                </div>\r\n        ";
}
echo "                                                            </div>\r\n                                                        </div>\r\n                                                    </div>\r\n                                                </div>\r\n                                            </div>\r\n                                        </div>\r\n                                    </div>\r\n               ";
echo "                 </div>\r\n                            </div>\r\n                    </div>\r\n                    </div>\r\n                    </div>\r\n</div>\r\n\r\n\t\t  \t\t\t<!-- Footer -->\r\n\t\t\t\t  \t<div id=\"footer\">\r\n\t\t\t\t    \t<div class=\"clsInstallFooter\">\r\n\t\t\t\t\t\t\t<div class=\"lb-footer\">\r\n\t\t\t\t  \t\t\t\t<div class=\"rb-footer\">\r\n\t\t\t\t    \t\t\t\t<div class=\"bb-footer\">\r\n\t\t\t\t      \t\t\t\t\t<div class=\"blc-footer\">\r\n\t\t\t\t        \t\t\t\t\t<div c";
echo "lass=\"brc-footer\">\r\n\t\t\t\t          \t\t\t\t\t\t<div class=\"tb-footer\">\r\n\t\t\t\t            \t\t\t\t\t\t<div class=\"tlc-footer\">\r\n\t\t\t\t              \t\t\t\t\t\t\t<div class=\"trc-footer\">\r\n                                                            <div class=\"clsInstallFooterContent\">\r\n                                                                <table>\r\n                                                                    <t";
echo "r>\r\n                                                                        <td class=\"clsPoweredByAgriya\"/>\r\n                                                                        <td style=\"text-align: center;\" class=\"clsCopyright\"><p>&copy; ";
echo $CFG['admin']['copy_right_year'] . " " . $CFG['site']['name'] . ". All rights reserved.";
echo "</p></td>\r\n                                                                        <td class=\"clsPoweredByAgriya\">";
echo "<span class=\"clsPoweredText\" style=\"color:#ccc;\">Powered By <a href=\"";
echo $CFG['dev']['url'];
echo "\">";
echo $CFG['dev']['name'];
echo "</a></span></td>\r\n                                                                    </tr>\r\n                                                                </table>\r\n                                                            </div>\r\n\t\t\t\t    \t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t            \t\t\t\t\t</div>\r\n\t\t\t\t          \t\t\t\t\t</div>\r\n\t\t\t\t        \t\t\t\t</div>\r\n\t\t\t\t      \t\t\t\t</div>\r\n\t\t\t\t    \t\t\t</div>\r\n\t\t\t\t  \t\t\t</d";
echo "iv>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t  \t</div>\r\n                     <div class=\"clsInnerContainerBtm\"></div>\r\n                     </div>\r\n\r\n\t\t\t\t</div>\r\n\r\n\t</body>\r\n</html>";
?>