<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2011 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Easyindex                     |
// +----------------------------------------------------------------------+
// | Authors: Aswin<aswin.j@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php
session_start();
ini_set('display_errors', '0');
error_reporting(0);
function isValidUsername($str)
{
    if (trim($str) !="" ) {
          if ( preg_match ( "/[^0-9a-zA-Z+_]/", $str ) ) {
                         return false;
             }else{
                    return true;
         }
    }else{
                return false;
    }

}
function splitsqlfile($sql, $delimiter)
{
    // Split up our string into "possible" SQL statements.
    $tokens = explode($delimiter, $sql);
    // try to save mem.
    $sql = "";
    $output = array();
    // we don't actually care about the matches preg gives us.
    $matches = array();
    // this is faster than calling count($oktens) every time thru the loop.
    $token_count = count($tokens);
    for ($i = 0; $i < $token_count; $i++) {
        // Don't wanna add an empty string as the last thing in the array.
        if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0))) {
            // This is the total number of single quotes in the token.
            $total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
            // Counts single quotes that are preceded by an odd number of backslashes,
            // which means they're escaped quotes.
            $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);

            $unescaped_quotes = $total_quotes - $escaped_quotes;
            // If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
            if (($unescaped_quotes % 2) == 0) {
                // It's a complete sql statement.
                $output[] = $tokens[$i];
                // save memory.
                $tokens[$i] = "";
            } else {
                // incomplete sql statement. keep adding tokens until we have a complete one.
                // $temp will hold what we have so far.
                $temp = $tokens[$i] . $delimiter;
                // save memory..
                $tokens[$i] = "";
                // Do we have a complete statement yet?
                $complete_stmt = false;

                for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++) {
                    // This is the total number of single quotes in the token.
                    $total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
                    // Counts single quotes that are preceded by an odd number of backslashes,
                    // which means they're escaped quotes.
                    $escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);

                    $unescaped_quotes = $total_quotes - $escaped_quotes;

                    if (($unescaped_quotes % 2) == 1) {
                        // odd number of unescaped quotes. In combination with the previous incomplete
                        // statement(s), we now have a complete statement. (2 odds always make an even)
                        $output[] = $temp . $tokens[$j];
                        // save memory.
                        $tokens[$j] = "";
                        $temp = "";
                        // exit the loop.
                        $complete_stmt = true;
                        // make sure the outer loop continues at the right point.
                        $i = $j;
                    } else {
                        // even number of unescaped quotes. We still don't have a complete statement.
                        // (1 odd and 1 even always make an odd)
                        $temp .= $tokens[$j] . $delimiter;
                        // save memory.
                        $tokens[$j] = "";
                    }
                } // for..
            } // else
        }
    }
    return $output;
}
function isValidTableName($str)
{
    if (trim($str) != "") {
        if (preg_match ("/[^a-zA-Z+_]/", $str)) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
function isValidEmail($email)
{
    $email = trim($email);
    if ($email == "")
        return false;
//    if (!eregi("^" . "[a-z0-9]+([_\\.-][a-z0-9]+)*" . // user
//            "@" . "([a-z0-9]+([\.-][a-z0-9]+)*)+" . // domain
//            "\\.[a-z]{2,}" . // sld, tld
//            "$", $email, $regs)
//            ) {
    if (!preg_match("/^" . "[a-z0-9]+([_\\.-][a-z0-9]+)*" . // user
            "@" . "([a-z0-9]+([\.-][a-z0-9]+)*)+" . // domain
            "\\.[a-z]{2,}" . // sld, tld
            "$/i", $email, $regs)
            ) {
        return false;
    } else {
        return true;
    }
}
function isNotNull($value)
{
    if (is_array($value)) {
        if (sizeof($value) > 0) {
            return true;
        } else {
            return false;
        }
    } else {
        if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
            return true;
        } else {
            return false;
        }
    }
}

function isValidWebImageType($mimetype,$filename,$tempname)
{
	$blacklist = array("php", "phtml", "php3", "php4", "js", "shtml", "pl" ,"py", "exe");
	foreach ($blacklist as $file)
	{
		if(preg_match("/\.$file\$/i", "$filename"))
		{
			return false;
		}
	}
	//check if its image file
	if (!getimagesize($tempname))
	{
		return false;
	}

    if (($mimetype == "image/pjpeg") || ($mimetype == "image/jpeg") || ($mimetype == "image/x-png") || ($mimetype == "image/png") || ($mimetype == "image/gif") ||
            ($mimetype == "image/x-windows-bmp") || ($mimetype == "image/bmp")) {
        return true;
    } else {
        return false;
    }
}

function isValidWMImageType($mimetype,$filename,$tempname)
{
	$blacklist = array("php", "phtml", "php3", "php4", "js", "shtml", "pl" ,"py", "exe");
	foreach ($blacklist as $file)
	{
		if(preg_match("/\.$file\$/i", "$filename"))
		{
			return false;
		}
	}
	//check if its image file
	if (!getimagesize($tempname))
	{
		return false;
	}
	if ($mimetype == "image/gif") {
        return true;
    } else {
        return false;
    }
}

function getFilePermission($file){
	$perm = fileperms($file);
	if($perm === false){
		return "0000";
	}else{
		return substr(sprintf('%o', $perm), -4);
	}

}
function stripslashes_deep($value){
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
}
function getServerOS()
{
	return strtoupper(substr(PHP_OS, 0, 3));
}

//deprecated in php 5.3
//@set_magic_quotes_runtime(0);

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

function file_writable($file){
    $permission = substr(sprintf('%o', fileperms($file)), -4);
    if($permission == '0777' || $permission == '0666'){
        return true;
    }
    else{
        return false;
    }
}

$schemafile = "schema.sql";
$schemafile_forum = "schema_forum.sql";
$datafile = "data.sql";
$datafile_forum = "data_forum.sql";
$configfile = "../easyindex_config.php";

/*
 * check if application has been installed
 */
$configcontents = @fread(@fopen($configfile, 'r'), @filesize($configfile));
$pos = strpos($configcontents, "INSTALLED");
if ($pos === false) {;
} else {
    header("Location: ../index");
}

$fullurl = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if($_SERVER['HTTPS']=='on'){
	$http = "https://";
}else {
	$http = "http://";
}
$pos = strrpos($fullurl, "/");
if ($pos === false) { // note: three equal signs
    // not found...
} else {
    $fullurl = substr($fullurl, 0, $pos);
}

$installed = false;
$txtDBServerName        =       "localhost";
$txtTablePrefix		=	"EasyIndex_";

$settingsfile           =       "../config/settings.php";
$globalfile             =       "../config/globals.php";

$txtSiteURL             =       "http://".$fullurl;
$txtSecureSiteURL       =       "https://" . $fullurl;
$txtSiteURLt            =       "http://".$fullurl;
$txtSecureSiteURLt      =       "https://" . $fullurl;

/* *********************************check server configuration *****************************************************/

  $server_flag      = true;
  $server_warning   = true;

  //$val1 = ini_get("safe_mode");
  $val2 = ini_get("file_uploads");
  $val3 = ini_get("open_basedir");

  $gd           = function_exists('gd_info');
  $curl         = function_exists('curl_init');
  $mysql        = function_exists('mysqli_connect');
  $exec         = strpos(ini_get("disable_functions"), "exec");

  $ffmpeg       = trim(@exec('which ffmpeg'));
  
  /*if(!empty($val1) || $val1==1){
      $server_flag = false;
  }*/
  if((empty($val2) || $val2 !=1)){
      $server_flag = false;
  }
  elseif((!empty($val3) || $val3==1)){
      $server_flag = false;
  }
  elseif(!$gd){
      $server_flag = false;
  }
  elseif(!$curl){
      $server_flag = false;
  }
  elseif(!$mysql){
      $server_flag = false;
  }
  elseif($exec){
      $server_warning = false;
  }
  elseif(empty($ffmpeg)){
      $server_warning = false;
  }

  $openbasedircheck =   "0" ;
  if($_POST["submittest"] == "Upload"){
        $uploadpath=substr($_FILES['testupload']['tmp_name'],0,strlen($_FILES['testupload']['tmp_name'])-strlen(basename($_FILES['testupload']['tmp_name']))-1);

        $val3=$val3.":"."  ";
        $openbasedirarray=explode(":",$val3);

        if(in_array($uploadpath,$openbasedirarray)){
           $openbasedircheck="1";
        }
        $_SESSION['sess_openbasedircheck']=$openbasedircheck;
  }


   $mysqlsupport=true;
   if (!function_exists('mysqli_connect')) {

        $mysqlsupport = false;
    }

  if(!$server_flag){
       $serverconfiguration =   "FAILURE";
  }else{
       $serverconfiguration =   "OK";
  }

/*--------------------Check server PHP configuration---------------------------*/
$sapi_type = php_sapi_name();
$chmodstatus = '000';
if (substr($sapi_type, 0, 3) == 'cgi'){
	$chmodstatus = '755';
        $write = 'WRITABLE';
}else{
    if(substr(@php_uname(s),0,7) == "Windows"){
	$chmodstatus = '000';
    }
    else{
	$chmodstatus = '777';
    }
    $write = 'UNWRITABLE';
}

$directories = array("/uploads/image/", "/uploads/video/", "/uploads/doc/", "/public/images/default/", "/config/settings.php", "/config/globals.php",
                     "/public/images/default/mainlogo.png", "/public/images/default/mainlogo_disp.png", "/public/images/default/mainbanner.gif", "/public/images/default/mainbanner_disp.gif", "/easyindex_config.php");

$perm_msg  = '';
$perm_flag = true;
$host_name = parse_url($_SERVER['HTTP_HOST']);

if($chmodstatus == '777'){
    if(isset($_POST["btnContinue"]) && !isset($_POST["auto_set"])){
        $txtFTPusername = $_POST['FTPusername'];
        $txtFTPpassword = $_POST['FTPpassword'];

        if(trim($txtFTPusername) == ''){
            $perm_msg .= '* Please enter FTP username <br/>';
        }
        if(trim($txtFTPpassword) == ''){
            $perm_msg .= '* Please enter FTP password <br/>';
        }
        else{
            $conn_id = @ftp_connect($host_name["path"]);
            $login_result = @ftp_login($conn_id, $txtFTPusername, $txtFTPpassword);
            if($login_result){
                $mode = 777;
                $np = '0'.$mode;

                $user_install = str_replace('/install', '', getcwd());

                //get the path staring from public_html
                $path_parts = explode('/public_html', $user_install);
                $user_install = '/public_html'.$path_parts[1];

                foreach($directories as $directory){
                    $edited_path = str_replace('..', '', $directory);
                    $directory = $user_install.$edited_path;
                    if($directory[strlen($directory) - 1] == '/'){
                        $directory  = substr($directory, 0, strlen($directory) - 1);
                    }
                    if(!@ftp_chmod($conn_id, eval("return({$np});"), $directory)){
                        $perm_flag = false;
                    }
                }

                if(!$perm_flag){
                    $perm_msg .= '* Sorry, an error occurred. Please try again or set the permissions manually <br/>';
                }
                else{
                    $perm_msg  = '<b>* File permissions successfuly set </b><br/>';
                }
            }
            else{
                $perm_msg .= '* Sorry, could not connect to the server. Please check the credentials <br/>';
            }
        }
    }
}
elseif($chmodstatus == '755'){
    //cgi handler requires 755 so no file permission change needed
}
elseif($chmodstatus == '000'){
    //ftp_chmod wont work on windows
}

/*-----------------------------------------------------------------------------*/

if($write == 'UNWRITABLE'){
    $imagedir                   = "../uploads/image/";
    $videodir                   = "../uploads/video/";
    $docdir                     = "../uploads/doc";
    $defaultdir 		= "../public/images/default/";
    $logo_file                  = "../public/images/default/mainlogo.png";
    $logo_tmb_file              = "../public/images/default/mainlogo_disp.png";
    $banner_file                = "../public/images/default/mainbanner.gif";
    $banner_tmb_file            = "../public/images/default/mainbanner_disp.gif";
    $settings_file              = "../config/settings.php";
    $globals_file               = "../config/globals.php";
    $config_file                = "../easyindex_config.php";
}//end if

$error = false;
$error_message = '';

//show alert only for non-cgi servers
if($chmodstatus == '777' || $chmodstatus == '000'){
    if(!file_writable($imagedir)){
        $error = true;
        $error_message .= " * Change the permission of 'uploads/image' folder to 777 <br>";
    }//end if

    if(!file_writable($videodir)){
        $error = true;
        $error_message .= " * Change the permission of 'uploads/video' folder to 777 <br>";
    }//end if

    if(!file_writable($docdir)){
        $error = true;
        $error_message .= " * Change the permission of 'uploads/doc' folder to 777 <br>";
    }//end if

    if(!file_writable($defaultdir)){
        $error = true;
        $error_message .= " * Change the permission of 'public/images/default' folder to 777 <br>";
    }//end if

    if(!file_writable($logo_file)){
        $error = true;
        $error_message .= " * Change the permission of 'public/images/default/mainlogo.png' to 777 <br>";
    }//end if

    if(!file_writable($logo_tmb_file)){
        $error = true;
        $error_message .= " * Change the permission of 'public/images/default/mainlogo_disp.png' to 777 <br>";
    }//end if

    if(!file_writable($banner_file)){
        $error = true;
        $error_message .= " * Change the permission of 'public/images/default/mainbanner.gif' to 777 <br>";
    }//end if

    if(!file_writable($banner_tmb_file)){
        $error = true;
        $error_message .= " * Change the permission of 'public/images/default/mainbanner_disp.gif' to 777 <br>";
    }//end if

    if(!file_writable($settings_file)){
        $error = true;
        $error_message .= " * Change the permission of 'config/settings.php' to 777 <br>";
    }//end if

    if(!file_writable($globals_file)){
        $error = true;
        $error_message .= " * Change the permission of 'config/globals.php' to 777 <br>";
    }//end if

    if(!file_writable($config_file)){
        $error = true;
        $error_message .= " * Change the permission of 'easyindex_config.php' to 777 <br>";
    }//end if
}

/*----------------------------------------------------------------------------------------------------------------*/
$post_flag = false;

if ($_POST["btnContinue"] == "Continue"  || $_POST['cldpack'] == 1) {
if ($_POST['cldpack'] == 1) {
$installPath = $_POST['returnurl'];
$txtDBServerName = 'localhost';
$txtDBName = $_POST["db_name"];
$txtDBUserName = $_POST["db_user"];
$txtDBPassword = $_POST["db_password"];
$txtSiteName = $_POST["store_name"];
$txtTablePrefix = "easyindex_";
$txtAdminName = "admin"; //$_POST["txtAdminName"];
$txtAdminPassword = "q1w2e3"; //$_POST["txtAdminPassword"];
$txtConfirmAdminPassword = "q1w2e3"; //$_POST["txtConfirmAdminPassword"];
$txtAdminEmail = $_POST['contactemail'];
$cmbCurrency = $_POST["cmbCurrency"];
$txtSiteURL = "http://" . $_POST["domain"];
$txtSecureSiteURL = "http://" . $_POST["domain"];
} else {
    $txtDBServerName         = $_POST["txtDBServerName"];
    $txtDBName               = $_POST["txtDBName"];
    $txtDBUserName           = $_POST["txtDBUserName"];
    $txtDBPassword           = $_POST["txtDBPassword"];
    $txtSiteName             = $_POST["txtSiteName"];
    $txtAdminName            = $_POST["txtAdminName"];
    $txtAdminPassword        = $_POST["txtAdminPassword"];
    $txtConfirmAdminPassword = $_POST["txtConfirmAdminPassword"];
    $txtLicenseKey           = $_POST["txtLicenseKey"];
    $txtAdminEmail           = $_POST["txtAdminEmail"];
    $txtTablePrefix          = $_POST["txtTablePrefix"];
}

    $post_flag = true;
    $message = "";
	 
if ($_POST['cldpack'] != 1) {
    if (!isNotNull($txtDBServerName)) {
        $message .= " * Database Server Name is empty!" . "<br>";
        $error = true;
    }
    if (!isNotNull($txtDBName)) {
        $message .= " * Database Name is empty!" . "<br>";
        $error = true;
    }
    if (!isNotNull($txtDBUserName)) {
        $message .= " * Database User Name is empty!" . "<br>";
        $error = true;
    }
    if (!isNotNull($txtSiteName)) {
        $message .= " * Site Name is empty!" . "<br>";
        $error = true;
    }
    if (!isNotNull($txtAdminEmail)) {
        $message .= " * Admin Email is empty!" . "<br>";
        $error = true;
    } else {
        if (!isValidEmail($txtAdminEmail)) {
            $message .= " * Invalid Admin Email!" . "<br>";
            $error = true;
        }
    }
 
}
    $connection = @mysqli_connect($txtDBServerName, $txtDBUserName, $txtDBPassword);
    if ($connection === false) {
        $error = true;
        $message .= " * Connection Not Successful! Please verify your database details!<br>";
    } else {
        $dbselected = @mysqli_select_db($connection, $txtDBName);
        @mysqli_query($connection, "SET SESSION sql_mode ='' ");
        if (!$dbselected) {
            $error = true;
            $message .= " * Database could not be selected! Please verify your database details!<br>";
        }
    }

    //exit;

    if ($error) {
        $message = "<u><b>Please correct the following errors to continue:</b></u>" . "<br><br>" . $message;
        // echo $message;
    } else {

        // writing to the config file....................
        $uniqueid = time() . mt_rand() . session_id();
        if (strlen($uniqueid) > 15) {
            $uniqueid = substr($uniqueid, 0, 15);
            $uniqueid = md5($uniqueid);
        }
        $fp = fopen($configfile, "w+");
        $configcontent = "<?php\n";
        $configcontent .= "define('INSTALLED', true); \n\n";
        $configcontent .= "define('VERSION', '2.0'); \n\n";
        $configcontent .= "define('VERSION', '2.1'); \n\n";
        $configcontent .= "ini_set('display_errors', '0'); \n\n";
        $configcontent .= "error_reporting(0); \n\n";
        $configcontent .= "\n?>";
        fwrite($fp, $configcontent);


        $fpp = fopen($settingsfile, "w+");
        $dbconfigcontent = "<?php\n";
if ($_POST['cldpack'] == 1) {
$dbconfigcontent .= "define('CLOUDINSTALLED', true); \n\n";
$dbconfigcontent .= "define('VERSION', '2.0'); \n\n";
$dbconfigcontent .= "define('SOURCE', 'SOURCE'); \n\n";
$dbconfigcontent .= "define('FIELD', 'vLookUp_Value'); \n\n";
$dbconfigcontent .= "define('CONDITION', \"vLookUp_Name = 'vLicenceKey'\"); \n\n";
$dbconfigcontent .= "define('PID',24); \n\n";
}
        $dbconfigcontent .= '$s = empty('.'$_SERVER["HTTPS"]'.") ? '' : (".'$_SERVER["HTTPS"]'." == 'on') ? 's' : ''; \n\n";
        $dbconfigcontent .= '$protocol = substr(strtolower('.'$_SERVER["SERVER_PROTOCOL"]'."), 0, strpos(strtolower(".'$_SERVER["SERVER_PROTOCOL"]'.'), "/")) .$s . "://";'." \n\n";
        $dbconfigcontent .= 'define("PROTOCOL", $protocol);'." \n\n";
        $dbconfigcontent .= "define('MYSQL_HOST', '".$txtDBServerName."'); \n\n";
        $dbconfigcontent .= "define('MYSQL_USERNAME','". $txtDBUserName ."'); \n\n";
        $dbconfigcontent .= "define('MYSQL_PASSWORD',  '". $txtDBPassword ."'); \n\n";
        $dbconfigcontent .= "define('MYSQL_DB', '". $txtDBName ."'); \n\n";
        $dbconfigcontent .= "define('MYSQL_TABLE_PREFIX',  '". $txtTablePrefix ."'); \n\n";
        //$dbconfigcontent .= "define('PAGE_LIST_COUNT', 5 ); \n\n";
        $dbconfigcontent .= "define('SANDBOX', 'no'); \n\n";
        $dbconfigcontent .= "define('USERNAME_LENGTH', '5'); \n\n";
        $dbconfigcontent .= "define('PASSWORD_LENGTH', '5'); \n\n";
        $dbconfigcontent .= "define('MAP_API_KEY', 'AIzaSyBbwNZ6-7t-rzbTwlPdiJAJiAEyL_t8aYA'); \n\n";
        $dbconfigcontent .= "\n?>";

        fwrite($fpp, $dbconfigcontent);

        $sqlquery = @fread(@fopen($schemafile, 'r'), @filesize($schemafile));
       	$sqlquery = preg_replace('/EasyIndex_/', $txtTablePrefix, $sqlquery);
        $sqlquery = splitsqlfile($sqlquery, ";");
        // creating the tables......................................
        for($i = 0; $i < sizeof($sqlquery); $i++) {
            mysqli_query($connection,$sqlquery[$i]);
        }

        $sqlquery = @fread(@fopen($schemafile_forum, 'r'), @filesize($schemafile_forum));
        $sqlquery = splitsqlfile($sqlquery, ";");
        // creating the tables......................................
        for($i = 0; $i < sizeof($sqlquery); $i++) {
            mysqli_query($connection,$sqlquery[$i]);
        }

        $dataquery = @fread(@fopen($datafile, 'r'), @filesize($datafile));
        $dataquery = preg_replace('/EasyIndex_/', $txtTablePrefix, $dataquery);
        $dataquery = splitsqlfile($dataquery, ";");
        // populating the tables with initial data......................................
        for($i = 0; $i < sizeof($dataquery); $i++) {
            mysqli_query($connection,$dataquery[$i]);
        }

        $dataquery = @fread(@fopen($datafile_forum, 'r'), @filesize($datafile_forum));
        $dataquery = splitsqlfile($dataquery, ";");
        // populating the tables with initial data......................................
        for($i = 0; $i < sizeof($dataquery); $i++) {
            mysqli_query($connection,$dataquery[$i]);
        }


        $adminusername = addslashes($txtAdminName);
        $adminpassword = md5($txtAdminPassword);
        $adminmailpword = $txtAdminPassword;

        //easyindex
        $sqladminsettings	=	"UPDATE ".$txtTablePrefix."admin SET  vAdminUsername = '".$adminusername."', vAdminPassword ='".$adminpassword."' WHERE vAdminUsername ='admin'";
        mysqli_query($connection,$sqladminsettings) or die(mysqli_error($connection));
        $sqlsettings		=	"UPDATE ".$txtTablePrefix."settings SET value = '".addslashes($txtSiteName)."' WHERE settingfield ='siteName'";
        mysqli_query($connection,$sqlsettings) or die(mysqli_error($connection));
        $sqlsettings1		=	"UPDATE ".$txtTablePrefix."settings SET value = '".addslashes($txtAdminEmail)."' WHERE settingfield ='adminEmail'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));
        $sqlsettings1		=	"UPDATE ".$txtTablePrefix."settings SET value = '".addslashes($txtLicenseKey)."' WHERE settingfield ='licenseKey'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));
        $sqlsettings1		=	"UPDATE ".$txtTablePrefix."settings SET value = '".$txtSecureSiteURL."' WHERE settingfield ='secureURL'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));
        
        //forum
        $sqlsettings1		=	"UPDATE data SET adminEmail = '".addslashes($txtAdminEmail)."' WHERE defaultTheme ='AbstractGreen'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));
        $sqlsettings1		=	"UPDATE data SET sitename = '".addslashes($txtSiteName)."' WHERE defaultTheme ='AbstractGreen'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));
        $sqlsettings1		=	"UPDATE users SET password = '".$adminpassword."', email = '".addslashes($txtAdminEmail)."' WHERE username ='admin'";
        mysqli_query($connection,$sqlsettings1) or die(mysqli_error($connection));

        $installed = true;

        /* -------------- /
        New code for install tracker, added by girish
        /------------------*/
        $string		= "";
        $pro		= urlencode("EasyIndex 2.0");
        $dom		= urlencode($txtSiteURL);
        $ipv		= urlencode($_SERVER['REMOTE_ADDR']);
        $mai		= urlencode($txtAdminEmail);
        $string		= "pro=$pro&dom=$dom&ipv=$ipv&mai=$mai";
        $contents	= "no";
        $file		= @fopen("http://www.iscripts.com/installtracker.php?$string", 'r');
        if ($file) {
                $contents = @fread($file, 8192);
        }
        /* -------------- /
        New code for install tracker, added by girish
        /------------------*/
        $subject 		= "Script Installed at ".$txtSiteName;
        $headers 		= "From: ".$txtSiteName."<".$txtAdminEmail.">\r\n";
        $headers 		.= "MIME-Version: 1.0\r\n";
        $headers 		.= "Content-type: text/html; charset=iso-8859-1\r\n";
        $path			=	"SiteLogo_disp.gif";
        $mcont			=	"<table width='90%'  border='0' cellspacing='2' cellpadding='2' align='center'>
<tr><td><a href='".$txtSiteURL."' target='_blank'><img src='".$txtSiteURL."/img/".$path."' border='0'></a></td></tr></table>";
        $mailcontent	=	$mcont."Hello , <br>";
        $mailcontent	.=  "EasyIndex has been successfully installed.<br> <a href='".$txtSiteURL."' target='_blank'>Click Here to Access the Public Site.</a>";
        $mailcontent	.=  "<br><a href='".$txtSiteURL."/admin' target='_blank'>Click Here to Access your Administration Control Panel</a> <br>";
        $mailcontent	.=  "Your Admin Username   :  ".$adminusername;
        $mailcontent	.=  "<br>Your Admin Password   :  ".$adminmailpword;
        $mailcontent	.=  "<br> Thanks and regards,<br> ".$txtSiteName." Team";
        $mailsent 		= mail(addslashes($txtAdminEmail),$subject,$mailcontent,$headers);
        // section to send details to admin...............................
}

}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
	case "text":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "''";
	  break;    
	case "long":
	case "int":
	  $theValue = ($theValue != "") ? intval($theValue) : "''";
	  break;
	case "double":
	  $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "''";
	  break;
	case "date":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "''";
	  break;
	case "defined":
	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
	  break;
  }
  return $theValue;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>EasyIndex Installer</title>
<link href="../public/styles/easyOrange/admin/admin_main.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript" src="../public/js/library/jquery.js"></script>
<script type="text/javascript">
    function divToggle(elem)
    {
        if($(elem).attr('checked')){
            $('#err_div').slideDown('slow');
        }
        else{
            $('#err_div').slideUp('slow');
        }
    }
</script>
<style type="text/css">

    /* Style for installer */
.installer_header_logo{
	float:left;
	margin:10px 0 0 0;
}



.installer_header_right{
	float:right;
	margin:30px 0 0 0;
	color:#CCCCCC;
	text-align:right;
}
.installer_header_right h4{
	font-size:25px;
	margin:0 0 10px 0;
	color:#000;
	font-weight:normal;
}
.installer_header_right a:link,
.installer_header_right a:visited,
.installer_header_right a:active
{
	font-size:12px;
	font-weight:bold;
	color:#E18600;
	text-decoration:none;
	padding:5px 10px 5px 10px;
}
.installer_header_right a:hover
{
	background-color:#E18600;
	color:#FFF;
}
.installer_input{
	border:#CCCCCC solid 1px;
	padding:5px;
	color:#000;
	font-family:Arial, Helvetica, sans-serif;
}
.installer_link{
	font-size:12px;
	font-weight:bold;
	color:#E18600;
	text-decoration:none;
	padding:5px 10px 5px 10px;
}
a.installer_link:hover{
	color:#CCC;
}
.padding_left{
    padding-left:0px !important;
    
}
.postad_div{
    width:850px;
    border:1px solid #C9C9C9;
    padding:25px 15px 25px 15px;
    background-color:#FBFBFB;
}
.install_option {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9pt; color: #333333}
.install_value_ok { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9pt; font-weight: bold; color: #009900 }
.install_value_fail { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-weight: bold; color: #CC0000}
.block_class{
color:#F4700E;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;}	

</style>
<body topmargin="0">
<div class="HeaderRow">
	<div class="HeaderContent sitewidth">
	
	
	<div class="installer_header_logo" align="left">
	<img src="../public/styles/easyOrange/images/installer_logo.png">
	</div>
		
		<div class="installer_header_right">
		<h4>iScripts EasyIndex Installer</h4>
		<!--items display area start -->
		<?php  			
		if(php_sapi_name() != 'apache2handler'){ ?>
		<div align="center" id="items_top_area">
		&nbsp;&nbsp;
		<a title="OnlineInstallationManual" href="#" onClick="window.open('<?php echo htmlentities($txtSiteURLt);?>/docs/Installation_Manual.pdf','OnlineInstallationManual','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd');">Installation manual</a>
		| <a title="Readme" href="#" onClick="window.open('<?php echo htmlentities($txtSiteURLt);?>/docs/Readme.txt','Readme','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd');">Readme</a> |
		<a title="If you have any difficulty, submit a ticket to the support department" href="#" onClick="window.open('http://www.iscripts.com/support/postticketbeforeregister.php','','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd,resizable=yes');">														
		Get Support</a>
		</div>
		<?php }else{ ?>
		<div align="center" id="items_top_area">
		&nbsp;&nbsp;
		<a title="OnlineInstallationManual" href="#" onClick="window.open('<?php echo htmlentities($txtSiteURL);?>/docs/Installation_Manual.pdf','OnlineInstallationManual','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd');">Installation manual</a>
		| <a title="Readme" href="#" onClick="window.open('<?php echo htmlentities($txtSiteURL);?>/docs/Readme.txt','Readme','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd');">Readme</a> |
		<a title="If you have any difficulty, submit a ticket to the support department" href="#" onClick="window.open('http://www.iscripts.com/support/postticketbeforeregister.php','','top=100,left=100,width=820,height=550,scrollbars=yes,toolbar=no,status=yrd,resizable=yes');">														
		Get Support</a>
		</div>
		<?php } ?>
		</div>
	

<div class="clear"></div>
</div>
</div>

<!-- Content Area Starts -->
<div class="ContentRow">
	<div class="ContentMaincontainer sitewidth">


<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
   
    <td width="76%" valign="top" height ="400">
	<!-- Here's where I want my views to be displayed -->
	<table width="80%" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td>
		<!--------Installer starts------------------------->

		
		<?php 
		if ($serverconfiguration=="FAILURE")
		{
		?>
			<table width="80%" border=0 align="center">
			<?php
			$ivo = "<span class='install_value_ok'>";
			$ivf = "<span class='install_value_fail'>";
			$sc = "</span>";
			echo "<tr><td class=maintext><b></b><br><br></td></tr>";
			echo "<tr><td class=maintext>Checking PHP Version... " . $ivo.PHP_VERSION.$sc . " ";
			if(version_compare(PHP_VERSION,"4.2.0") >=0 ) echo $ivo."".$sc; else {echo $ivf."(4.2.0 or higher required)".$sc; $fatal = true;}
			echo "</td></tr>";
			echo "<tr><td class=maintext>Checking System Information... " .$ivo. PHP_OS .$sc. "</td></tr>";
			echo "<tr><td class=maintext>Checking PHP Server API... " . $ivo. php_sapi_name().$sc . "</td></tr>";
			echo "<tr><td class=maintext>Checking Path to 'php.ini'... " . $ivo.PHP_CONFIG_FILE_PATH.$sc . "</td></tr>";
			$mysqlsupport=true;
			if (!function_exists('mysqli_connect')) {
				$mysqlsupport = false;
			}
			echo "<tr><td class=maintext>Checking Mysql support... ";
			echo $ivo . (( $mysqlsupport) ? "On" : " $ivf This program requires MYSQL support. Please recompile your PHP with MYSQL Support.") . $sc;
			echo "</td></tr>";
			/*echo "<tr><td class=maintext>Checking safe_mode... ";
			$val1 = ini_get("safe_mode");
			echo  ((!empty($val1) || $val1==1) ? $ivf ."On-Please turn off safe_mode in the php.ini" : $ivo ."Off") . $sc;
			echo "</td></tr>";*/
			echo "<tr><td class=maintext>Checking file_uploads...";
			$val2 = ini_get("file_uploads");
			echo ((!empty($val2) || $val2==1) ? $ivo . "On" : $ivf . "Off - Please turn on file_uploads in the php.ini file").$sc;
			echo "</td></tr>";
			echo "<tr><td class=maintext>Checking open base directory...";
			$val3 = ini_get("open_basedir");
			echo ((!empty($val3) || $val3==1) ? $ivf . "On - $ivf Please upload a test file " : $ivo . "Off ") . $sc."</td></tr>";
			
			if((!empty($val3) || $val3==1)  and  (!empty($val2) || $val2==1) ){
                            echo "<tr><td class=maintext>";
				if($_POST["submittest"] == "Upload"){
					$uploadpath=substr($_FILES['testupload']['tmp_name'],0,strlen($_FILES['testupload']['tmp_name'])-strlen(basename($_FILES['testupload']['tmp_name']))-1);
					$uploadpatharray=explode("/",$uploadpath);
					$openbasedirarray=explode(":",$val3);
					$existflag=0;
					$checkitem="";
					for($i=1;$i<count($uploadpatharray);$i++){
						$checkitem=$checkitem."/".$uploadpatharray[$i];
						if(! in_array($checkitem,$openbasedirarray)  and ! in_array($checkitem."/",$openbasedirarray) ){
							;
						}else{
							$existflag=1;
							break;
						}
					}
					if($existflag==1){
						$openbasedircheck="1";
					}else{
						echo "<br>&nbsp;&nbsp;".$ivf."Please add '$uploadpath' in openbase directory entry of your configuration file.[contact your hosting provider]";
					}
					$_SESSION['sess_openbasedircheck']=$openbasedircheck;
				}
				if($openbasedircheck !="1"){
				?>
					<form name=frmInstall method=post action="" enctype="multipart/form-data">
						file :&nbsp;
					<input type=file name=testupload class=textbox>
					<INPUT type="submit" name="submittest" value="Upload" class=button>
					</form>
			<?php }
                        echo "</td></tr>";
			}			
                        echo "<tr><td class=maintext>Checking CURL support... ";
			$val5 = function_exists('curl_init');
                        if($val5){
                            echo $ivo."On";
                        }
                        else{
                            echo $ivf."Off-Please re-compile php with CURL support" . $sc;
                        }
			echo "</td></tr>";
                        echo "<tr><td class=maintext>Checking GD support... ";
			$val6 = function_exists('gd_info');
                        if($val6){
                            echo $ivo."On";
                        }
                        else{
                            echo $ivf."Off-Please re-compile php with GD support" . $sc;
                        }
			echo "</td></tr>";
                        echo "<tr><td class=maintext>Checking EXEC function... ";
			$val7 = strpos(ini_get("disable_functions"), "exec");
                        if(!$val7){
                            echo $ivo."On";
                        }
                        else{
                            echo $ivf."Off-Please enable EXEC funtion the php.ini if you wish to use the video section" . $sc;
                        }
			echo "</td></tr>";
                        echo "<tr><td class=maintext>Checking FFMPEG support... ";
			$val8 = trim(@exec('which ffmpeg'));
                        if(!empty($val8)){
                            echo $ivo."On";
                        }
                        else{
                            echo $ivf."Off-Please re-compile php with FFMPEG support if you wish to use the video section" . $sc;
                        }
			echo "</td></tr>";
                        
			echo "<tr><td class=maintext>".$ivf."Fatal errors detected.  Please correct the above red items and reload.</td></tr>";			
			?>
		</table>

	<?php
	} else if (!$installed ) {
	
	?>
		<table width="80%" border="0" align="center">
			<tr>
				<td align="center" ><b><font size="1">
					<div align="justify" >
					<br>
					<font color="#F4700E" size="+1">Thank you for choosing EasyIndex&nbsp;</font> <br><br>
					<font color="#000000" size="2">To complete this installation please enter the details below.</font>
					</div>

				</font></b>
				</td>
			</tr>
                        <?php if($post_flag){ ?>
			<tr>
				<td align=center class="message" >
					<div align="left" class="text_information">
					<br>
                                        <font color="#FF0000"><?php echo $message;?></font><br>
                                        <font color="#FF0000"><?php echo $error_message; ?></font><br>
					</div>
				</td>
			</tr>
                        <?php } ?>
			<tr>
				<td class=maintext align="left" >
				Note: All Fields Are Mandatory.
				<br>
                                <form name="frmInstall" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" enctype="multipart/form-data">
					<br>

                                        <FIELDSET>
					<LEGEND class='block_class'>File Permissions</LEGEND>
					<table width=85% border="0" cellpadding="2" cellspacing="2" class=maintext>
                                                <tr>
                                                    <td colspan="2" align="left">
                                                        <b>
                                                        <?php if($chmodstatus == '777'){ ?>
                                                           EasyIndex requires that some of the folders have write permission. You can provide an FTP login so that this process is done automatically.<br/><br/>
                                                           For security reasons, it is best to create a separate FTP user account with access to the EasyIndex installation only and not the entire web server. Your host can assist you with this.
                                                           If you have difficulties completing installation without these credentials, please click "I would provide permissions manually" to do it yourself.<br/><br/>
                                                        <?php }elseif($chmodstatus == '000'){ ?>
                                                        EasyIndex requires that some of the folders have write permission. Please provide write permission for the following files :-<br/><br/>
                                                        <?php } elseif($chmodstatus == '755'){ ?>
                                                        EasyIndex requires that some of the folders have write permission.<br/><br/>
                                                        <?php } ?>
                                                        </b>
                                                    </td>
                                                </tr>
                                                <?php if($write == 'UNWRITABLE'){ ?>
						<tr>
							<td class=maintext align="left">FTP username</td>
							<td width="61%" align=left>
								<input name="FTPusername"  id="FTPusername" type="text" size="50" class="installer_input" value="<?php echo htmlentities($txtFTPusername);?>">								
							</td>
						</tr>
						<tr>
							<td class=maintext align="left">FTP password</td>
							<td width="61%" align=left>
								<input name="FTPpassword"  id="FTPpassword" class="installer_input" type="password" size="50" value="<?php echo htmlentities($txtFTPpassword);?>">
							</td>
						</tr>
                                                <?php if($chmodstatus == '777'){ ?>
                                                <tr>
                                                    <td colspan="2" align="left">
                                                        <input type="checkbox" name="auto_set" id="auto_set" onclick="divToggle(this)" /> &nbsp; I would provide permissions manually
                                                    </td>
                                                </tr>                                                
                                                <?php
                                                    }
                                                }else{
                                                ?>
                                                <tr>
                                                    <td colspan="2" align="left">
                                                        <b>File permissions are OK.</b>
                                                    </td>
                                                </tr>
                                                <?php } ?>
					</table>
                                        <?php if($write == 'UNWRITABLE'){ ?>
                                        <div id="err_div" style="<?php if($chmodstatus == '777'){ ?>display:none<?php } ?>">
                                                    <fieldset>
                                                        <legend>Directories/Files List</legend>
                                                        <?php echo $error_message; ?>
                                                    </fieldset>
                                        </div>
                                        <?php } ?>
					</FIELDSET>
					<br>
					<br>

                                        <FIELDSET>
					<LEGEND class='block_class'>Database Details</LEGEND>
					<table width=85% border=0 cellpadding="2" cellspacing="2" class=maintext>
						<tr>
							<td colspan="2" class=maintext align="left">Database Server</td>
							<td width="61%" align=left>
								<input type="text" class="installer_input" name="txtDBServerName" id="txtDBServerName" value="<?php echo htmlentities($txtDBServerName);?>">
							</td>
						</tr>
						<tr>
							<td colspan="2" class=maintext align="left">Database Name</td>
							<td width="61%" align=left>
								<input name="txtDBName" class="installer_input"   id="txtDBName" type="text"   class="textbox"  maxlength="100" size="50" value="<?php echo htmlentities($txtDBName);?>" >								
							</td>
						</tr>
						<tr>
							<td colspan="2" class=maintext align="left">Database User Name</td>
							<td width="61%" align=left>
								<input name="txtDBUserName" class="installer_input"  id="txtDBUserName" type="text" maxlength="100" size="50" value="<?php echo htmlentities($txtDBUserName);?>">
							</td>
						</tr>
						<tr>
							<td colspan="2" class=maintext align="left">Database Password</td>
							<td width="61%" align=left>
								<input name="txtDBPassword" class="installer_input"  id="txtDBPassword" type="password"  maxlength="100" size="50" value="<?php echo htmlentities($txtDBPassword);?>">
								</td>
						</tr>
						<tr>
							<td colspan="2" class=maintext align="left">Table Prefix</td>
							<td width="61%" align=left>
								<input name="txtTablePrefix" class="installer_input"  id="txtTablePrefix" type="text"  maxlength="100" size="50" value="<?php echo htmlentities($txtTablePrefix);?>">
							</td>
						</tr>
						
					</table>
					</FIELDSET><br><br>
					<FIELDSET>
					<LEGEND class='block_class'>Site Details</LEGEND>
					<table width=85% border=0 cellpadding="2" cellspacing="2" class=maintext>
						<tr>
							<td colspan="2" class=maintext align="left">Site Name</td>
							<td width="61%" align=left>
								<input name="txtSiteName"  id="txtSiteName" type="text" class="installer_input" maxlength="100" size="50" value="<?php echo htmlentities($txtSiteName);?>">
								<input name="txtSiteURL"  id="txtSiteURL" type="hidden" class="installer_input" maxlength="100" value="<?php echo htmlentities($txtSiteURL);?>" readonly >
							</td>
						</tr>
						<tr>
							<td colspan="2" class=maintext align="left">License Key</td>
							<td width="61%" align=left>
								<input name="txtLicenseKey" class="installer_input"  id="txtLicenseKey" type="text" maxlength="100" size="50" value="<?php echo htmlentities($txtLicenseKey);?>">
							</td>
						</tr>
					</table>
					</FIELDSET>
					<br>
					<br>
					<FIELDSET>
					<LEGEND class="block_class">Administration Details</LEGEND>
					<table width=85% border=0 cellpadding="2" cellspacing="2" class=maintext>							
					<tr>
						<td colspan="2" class=maintext  align="left">Admin Email</td>
						<td width="61%" align=left>
                                                        <input name="txtAdminName"  id="txtAdminName" type="hidden" maxlength="100" size="50" value="admin">
						
							<input name="txtAdminPassword"  id="txtAdminPassword" type="hidden" maxlength="100" size="50" value="admin">
											
							<input name="txtConfirmAdminPassword"  id="txtConfirmAdminPassword" type="hidden" maxlength="100" size="50" value="admin">
						
							<input name="txtAdminEmail"  id="txtAdminEmail" type="text"  class="installer_input" maxlength="100" size="50" value="<?php echo htmlentities($txtAdminEmail);?>">
						</td>
					</tr>
				</table>
				</FIELDSET>
				<br>
				<table width=85% border=0 cellpadding="2" cellspacing="2" class=maintext>
					<tr><td>&nbsp;</td></tr>
					<tr>
						<td align="center">
							<input type="submit" name="btnContinue" value="Continue" class="btn_styles">
						</td>
					</tr>
				</table>
			</form>	
			</td>
		</tr>
	</table>
	<?php
	}
	else
	{
	?>
	<table width="80%" border="0" align="center">
		<tr>
			<td>
				<table width=85% border=0 cellpadding="2" cellspacing="2" class=maintext align="center">
					<br>
					<tr>
						<td align="center" class="maintext" >
							<font color="#F4700E" size="+1">Congratulations! The Installation Process was completed successfully!</font>
						</td>
					</tr>
					<tr>
						<td align="center" class="maintext" height="20" >&nbsp;</td>
					</tr>
					<?php 
					$request_uri = explode('/',$_SERVER['REQUEST_URI']);
					
					$script_filename = explode('/',$_SERVER['SCRIPT_FILENAME']);
					$build_path = "http://".$_SERVER['HTTP_HOST']."/".$request_uri[1]."/admin/login.php";
					$build_path_home = "http://".$_SERVER['HTTP_HOST']."/".$request_uri[1]."/index.php";
					?> 						
					<tr>
						<td align="center">
						<br>
						<fieldset>
						<legend class="block_class">Site Login Details</legend>
							<table cellpadding="0" cellspacing="0" width="80%" class="maintext" align="center">
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
								<?php								
								if(php_sapi_name() == 'apache2handler'){
									$apach	=	true;
								}else{
									$apach	=	false;
								}
								?>
									<tr>
										<td width="24%" valign="top"><b><font size="-1">Admin URL&nbsp;:</font></b></td>
										<td width="76%" valign="top"><a class="installer_link padding_left" style="cursor:pointer" href="<?php echo $txtSiteURL."/admin/"?>"><?php echo $txtSiteURL."/admin/"?>&nbsp;&nbsp;<img align="absmiddle" src="../public/styles/easyOrange/images/install_admin_link.png"></a></td>
									</tr>
									<tr>
										<td colspan="2">&nbsp;</td>
									</tr>
                                                                        <tr>
                                                                            <td width="24%" valign="top"><b><font size="-1">Admin Credentials&nbsp;:</font></b></td>
                                                                            <td width="76%" valign="top">
                                                                                <font size="-1">Username&nbsp;:&nbsp;admin</font><br/>
                                                                                <font size="-1">Password&nbsp;:&nbsp;admin</font>
                                                                            </td>
									</tr>
									<tr>
										<td colspan="2">&nbsp;</td>
									</tr>
									<tr>
										<td width="24%" valign="top"><b><font size="-1">Home URL&nbsp;:</font></b></td>
										<td width="76%" valign="top"><a class="installer_link padding_left" style="cursor:pointer" href="<?php echo $txtSiteURL;?>/"><?php echo $txtSiteURL;?>/&nbsp;&nbsp;<img align="absmiddle" src="../public/styles/easyOrange/images/install_home_link.png"></a></td>
									</tr>
															</table>
						</fieldset>	
						</td>
					</tr>
                        <?php
                            echo "<tr><td class=maintext>";
                            $val7 = strpos(ini_get("disable_functions"), "exec");
                            if($val7){
                                echo "<span style='color:#FF0000; font-size:12px; font-weight:bold;'>Please enable EXEC funtion the php.ini if you wish to use the video section</span>";
                            }
                            echo "</td></tr>";
                            echo "<tr><td class=maintext>";
                            $val8 = trim(@exec('which ffmpeg'));
                            if(empty($val8)){
                                echo "<span style='color:#FF0000; font-size:12px; font-weight:bold;'>Please re-compile php with FFMPEG support if you wish to use the video section</span>";
                            }
                            echo "</td></tr>";
                        ?>
					<tr>
						<td align="center" class="maintext" height="20" >&nbsp;</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<?php 
	
	}
	
	?>
	</td>
	</tr>
	</table>
      </td>
  </tr>
</table>

</div>
</div>


<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="10">
      <tr>
        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="3">
              <tr>
                <td height="43" class="bigfont1" align="center"><div align="center" class="copyright"><!-- footr links comes here --></div></td>
              </tr>
            </table>
</td>
          </tr>
        </table></td>
      </tr>
    </table>      
      </td>
  </tr>
</table>
</body>
</html>