<?php
@session_start();
@ob_start();

// get the config file
include_once("../public/config.php");
//include_once("../public/impOpreationtest.php");
//here the db files that include in the file
include("../public/include_dao.php");

require_once('../library/db_main/rb.php');

/* * *** just used rd beans depend on connection ** */

$dbhostrb = ConnectionProperty::getHost();
$dbuserrb = ConnectionProperty::getUser();
$dbpasswordrb = ConnectionProperty::getPassword();
$dbnamerb = ConnectionProperty::getDatabase();

R::setup('mysql:host=' . $dbhostrb . ';dbname=' . $dbnamerb . '', '' . $dbuserrb . '', '' . $dbpasswordrb . '');

?>



<?php

//////////////////////////
//////////////////////////

function PageNamectrl() {
    $string = substr($_SERVER["SCRIPT_NAME"], strrpos($_SERVER["SCRIPT_NAME"], "/") + 1);

    return $string;
}

//Current Do
function curPageURL() {

    $pageURL = 'http';

    if ($_SERVER["HTTPS"] == "on") {
        $pageURL .= "s";
    }

    $pageURL .= "://";

    if ($_SERVER["SERVER_PORT"] != "80") {

        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
    } else {

        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    }

    return $pageURL;
}

$doPosition = strpos(curPageURL(), "do");
$currentDo;
if ($doPosition != "") {

    $andPosition = strpos(curPageURL(), "&");
    $dostring;
    if ($andPosition == "") {
        $dostring = substr(curPageURL(), $doPosition);
    } else {
        $dostring = substr(curPageURL(), $doPosition, $andPosition - $doPosition);
    }

    $equalPosition = strpos($dostring, "=");
    $currentDo = substr($dostring, $equalPosition + 1);
}


include("authentication.php");


$sessionUserId = $_SESSION['userid'];


//$serial = shell_exec('wmic path win32_physicalmedia get serialnumber');
$serial = "00";

//echo $serial."<br>";

$serial = md5($serial);
//$serial = explode("SerialNumber",$serial);
$newequation = md5($serial + 1);
$newequation = substr($newequation, 5, 10);
$fullnew = $newequation . "-" . base64_encode("0");
//echo  $fullnew;
$file = "../public/libs/plugins/fileget.nrd";
$alreadynumber = file($file);
$alreadynumber = explode("-", $alreadynumber[0]);

$alreadynumber1 = $alreadynumber[1];
$alreadynumber = $alreadynumber[0];
$daysremaining = base64_decode($alreadynumber1);
$smarty->assign("daysremaining", $daysremaining);
//echo $newequation;
//echo "<br>".$alreadynumber;
$a = 1;
$b = 1;
if ($a != $b) {
    //if($alreadynumber!=$newequation){
    header("location:../exper.html");
} else {
    //echo $alreadynumber1."...";
    //echo base64_decode($alreadynumber1);

    if (base64_decode($alreadynumber1) == "-1") {

    } elseif (base64_decode($alreadynumber1) <= 0) {
        //header("location:../exper.html");
    }
}

//	$alreadynumber  = file($file);
//		//print_r($alreadynumber);
//		//echo $alreadynumber[0];
//		if($alreadynumber[0]>0){
//		//	echo "hazem";
//		$newnumber = $alreadynumber[0] -1 ;
//		$filenew= fopen($file,"w+");
//		 fwrite($filenew,$newnumber);
//		 fclose($filenew);
//
//			}else{
//
//				header("location:../exper.html");
//
//				}
//
?>