dainik rajeev times

<html>
<head>
 <href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css”>
    <link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”>
</head>
<body>
<div class=”row”>
    <div style=”width: 100%; height: 20px;”></div>
    <div class=”container” align=”center”>
        <img src=”logo.png” width=”150″><br><br>
        <h6>EpaperDesk Installation.</h6>
    </div><br><br>
    <div style=”width: 100%; height: 17px;”></div>
    <div class=”container” align=”center”>
<?php
$sqlFile = ‘assets/sql/epaper.sql’;
$gHost = ”; if(isset($_POST[‘host’])){ $gHost = $_POST[‘host’]; }
$gUser = ”; if(isset($_POST[‘user’])){ $gUser = $_POST[‘user’]; }
$gPass = ”; if(isset($_POST[‘pass’])){ $gPass = $_POST[‘pass’]; }
$gDBnm = ”; if(isset($_POST[‘db’])){ $gDBnm = $_POST[‘db’]; }
$adminUser = ”; if(isset($_POST[‘admin_user’])){ $adminUser = $_POST[‘admin_user’]; }
$adminEmail = ”; if(isset($_POST[‘admin_email’])){ $adminEmail = $_POST[‘admin_email’]; }
$adminPass = ”; if(isset($_POST[‘admin_pass’])){ $adminPass = $_POST[‘admin_pass’]; }
$environnement = ‘production’; if(isset($_POST[‘environnement’])){ $env = $_POST[‘environnement’]; }
$pathFromRoot = ”; if(isset($_POST[‘path_from_root’])){ $pathFromRoot = $_POST[‘path_from_root’]; }
$hideErrors = ‘false’; if(isset($_POST[‘hide_errors’])){ $hideErrors = $_POST[‘hide_errors’]; }
if (checkUploadsPermission()) {
    $folderStd = ‘<h6><i class=”fa fa-folder-open text-primary”></i> <b>Upload</b> Folder Permission (777) : <span class=”text-success”>Done</span></h6>’;
}else{
    $folderStd = ‘<h6><i class=”fa fa-folder-open text-primary”></i> <b>Upload</b> Folder Permission (777) : <span class=”text-danger”>Not Done</span></h6>’;
}
$phpVersion =  substr_replace(PHP_VERSION, “”, 3);
if ($phpVersion==’7.4′) {
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></b>’;
}else if ($phpVersion==’7.3′) {
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></b>’;
}else if ($phpVersion==’7.2′){
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></b>’;
}else if ($phpVersion==’7.1′){
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></span></b>’;
}else if ($phpVersion==’7.0′){
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></b>’;
}else if ($phpVersion==’5.6′){
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-success”>Version Supported</span></b>’;
}else{
    $phpV = ‘<i class=”fa fa-code text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-danger”>Version Not Supported</span></b>’;
}
if (!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] != ‘off’) {
    $SSLcheck = ‘<br><i class=”fa fa-lock text-primary font-weight-bold”></i> <b>SSL Status: <span class=”text-success”>Active</span></b>’;
}else{
    $SSLcheck = ‘<br><i class=”fa fa-lock text-primary font-weight-bold”></i> <b>PHP version ‘.$phpVersion.’: <span class=”text-danger”>Inactive (SSL Recommended.)</span></b>’;
}
echo ‘
<style>td{padding:10px 3px;}</style>
<h5 style=”color: green”>Settings & Permissions.</h5><br>
<div style=”width: 540px;” align=”left”>
‘.$folderStd.’
‘.$phpV.’
‘.$SSLcheck.’
<div><br>
<form action=”” method=”post”>
    <table style=”width: 100%” align=”center”>
        <tr>
            <td colspan=”2″ align=”center”><h3>Database config</h3></td>
        </tr>
        <tr>
            <td><b class=”text-success”><h6>HOST</h6></b><input class=”form-control” type=”text” name=”host” value=”localhost” ></td>
            <td><b class=”text-success”><h6>USER NAME</h6></b><input class=”form-control” type=”text” name=”user” value=”‘. $gUser .'” ></td>
        </tr>
        <tr style=”height: 20px;”></tr>
        <tr>
            <td><b class=”text-success”><h6>PASSWORD</h6></b><input class=”form-control” type=”text” name=”pass” value=”‘. $gPass .'” ></td>
            <td><b class=”text-success”><h6>DATABASE NAME</h6></b><input class=”form-control” type=”text” name=”db” value=”‘. $gDBnm .'” ></td>
        </tr>
        <tr style=”height: 20px;”></tr>
        <tr>
            <td colspan=”2″ align=”center”><h3>Admin account</h3></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Admin username</h6></b><input class=”form-control” type=”text” name=”admin_user” value=”‘.$adminUser.'” ></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Admin email</h6></b><input class=”form-control” type=”text” name=”admin_email” value=”‘.$adminEmail.'” ></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Admin password</h6></b><input class=”form-control” type=”text” name=”admin_pass” value=”‘.$adminPass.'” ></td>
        </tr>
        <tr style=”height: 20px;”></tr>
        <tr>
            <td colspan=”2″ align=”center”><h3>App settings</h3></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Environnement</h6></b><select class=”form-control” name=”environnement” id=”environnement”><option value=”production”‘.(($environnement == ‘production’) ? ‘ selected=”selected”‘ : ”).’>Production</option><option value=”development”‘.(($environnement == ‘development’) ? ‘ selected=”selected”‘ : ”).’>Development</option></select></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Path from Root: ‘.$_SERVER[‘DOCUMENT_ROOT’].'</h6></b><input class=”form-control” type=”text” name=”path_from_root” value=”‘.$pathFromRoot.'” ></td>
        </tr>
        <tr>
            <td colspan=”2″ align=”left”><b class=”text-success”><h6>Hide php errors</h6></b><select class=”form-control” name=”hide_errors” id=”hide_errors”><option value=”true”‘.(($hideErrors == ‘true’) ? ‘ selected=”selected”‘ : ”).’>Yes</option><option value=”false”‘.(($hideErrors == ‘false’) ? ‘ selected=”selected”‘ : ”).’>No</option></select></td>
        </tr>
        <tr style=”height: 20px;”></tr>
        <tr>
            <td colspan=”2″ align=”right”><BR><button class=”btn btn-primary font-weight-bold” type=”submit” name=”install” style=”width: 100%;”>INSTALL NOW</button></td>
        </tr>
    </table>
</form>
‘;
if(isset($_POST[‘install’]) && checkUploadsPermission()){
    if(dbConfig() && envConfig($environnement, $pathFromRoot, $hideErrors)){
        $connection = @mysqli_connect($gHost,$gUser,$gPass,$gDBnm);
        if($connection){
            $q = sqlData($connection, $adminUser, $adminEmail, $adminPass, $sqlFile);
            if($q){
                file_put_contents(‘installed’,time());
                echo ‘<script>window.location.href=”admin”;</script>’;
            }else{
                echo ‘<span style=”color:red;”>Database information upload failed.</span>’;
            }
        }else{
            echo ‘<span style=”color:red;”>Mysql connection error.</span>’;
        }
    }else{
        echo ‘<span style=”color:red;”>Database config file is not updated.</span>’;
    }
}
function dbConfig(){
    $return = false;
    if(!empty($_POST[‘host’]) && !empty($_POST[‘user’]) && !empty($_POST[‘db’])){
        $dbFileUpdate = ‘
        <?php
        return array(
            “connectionString” => “mysql:host=’. $_POST[‘host’] .’;port=;dbname=’. $_POST[‘db’] .'”,
            “emulatePrepare” => true,
            “username” => “‘. $_POST[‘user’] .'”,
            “password” => “‘. $_POST[‘pass’] .'”,
            “charset” => “utf8”,
            “schemaCachingDuration”=>3600
        );
        ?>
        ‘;
        $dbConfigFile = “protected/config/db.php”;
        $f = file_put_contents($dbConfigFile,$dbFileUpdate);
        if($f){
            $return = true;
        }
    }
    return $return;
}
function envConfig($env=’production’, $pathFromRoot=’/epaperdesk’, $hideErrors=false){
    $content  = ‘<?php ‘.”\n”;
    $content .= ‘define(\’PHPCORE_ENVIRONMENT\’, \”.$env.’\’);//or development’.”\n”;
    $content .= ‘define(\’PHPCORE_FULL_PATH\’, $_SERVER[\’DOCUMENT_ROOT\’].\”.$pathFromRoot.’\’);’.”\n”;
    $content .= ‘define(\’PHPCORE_HIDE_ERRORS\’, ‘.$hideErrors.’);’.”\n”;
    $content .= ‘$phpcore_base_url = ((isset($_SERVER[\’HTTPS\’]) && $_SERVER[\’HTTPS\’] == “on”) ? “https” : “http”);’.”\n”;
    $content .= ‘$phpcore_base_url .= “://”.$_SERVER[\’HTTP_HOST\’];’.”\n”;
    $content .= ‘$phpcore_base_url .= \”.$pathFromRoot.’\’;’.”\n”;
    $content .= ‘define(\’PHPCORE_BASE_URL\’, $phpcore_base_url);’.”\n”;
    $content .= “\n”;
    if(file_put_contents(‘env.php’,$content) !== false) return true;
    else return false;
}
function sqlData($connection, $adminUser, $adminEmail, $adminPass, $sqlFile){
    if(!file_exists($sqlFile)) return false;
    $search = array(‘{user_name}’,'{user_email}’,'{user_password}’);
    $replace = array($adminUser,$adminEmail,md5($adminPass));
    $sql = file_get_contents($sqlFile);
    $sql = str_replace($search, $replace, $sql);
    $sqlFile = str_replace(‘.sql’,’_tmp.sql’, $sqlFile);
    file_put_contents($sqlFile, $sql);
    $errors = 0;
    $sql = file($sqlFile);
    @unlink($sqlFile);
    foreach ($sql as $line) {
        $startWith = substr(trim($line), 0 ,2);
        $endWith = substr(trim($line), -1 ,1);
        if (empty($line) || $startWith == ‘–‘ || $startWith == ‘/*’ || $startWith == ‘//’) {
            continue;
        }
        $query = $query . $line;
        if ($endWith == ‘;’) {
            $q = mysqli_query($connection,$query);
            if(!$q) $errors++;
            $query= ”;
        }
    }
    if($errors > 0) return false;
    else return true;
}
function checkUploadsPermission(){
    $fp = fileperms(‘uploads’);
    if($fp){
        if(substr(sprintf(‘%o’, $fp), -4) == “0777”) {
            return true;
        }else {
            return false;
        }
    }else{
        return false;
    }
}
?>
    </div>
</div>
<hr>
<div class=”container” align=”center”>
    <h6><i class=”fa fa-phone-square”></i> For any query or issue contact epaperdesk team <a href=”https://epaperdesk.com/contact” target=”_blank”>Visit</a></h6>
</div><br>
<style>
    body, html{width:  100%; height: 100%; padding: 0px; margin: 0px; background: #f0f0f0; overflow-x: hidden; font-family: sans-serif}
    h6{font-weight: bold;
    color: currentColor;}
</style>
</body>
</html>