<?php 
function db_info(){
    $server = strtolower($_SERVER['SERVER_NAME']);
    if (strpos($server,".org") !==false){
        $username ="zxzjdain_tnm";
        $password = "XQk5hnixc3ZdiPt";
        $database = "zxzjdain_tnm";
        $server="localhost"; 
    }else{
        $username ="root";
        $password = "";
        $database = "j_thenewminds";
        $server="localhost";
    }
        
    $db_info = array("$server", "$username", "$password","$database");
    return $db_info;
}


function runSQL($sql)
{
$db_info = db_info();
$server=$db_info[0];
$username =$db_info[1]; 
$password = $db_info[2];
$database = $db_info[3];
//connection
$con=mysqli_connect($server, $username, $password,$database);
$result = mysqli_query($con,$sql);
mysqli_close($con);
return $result;
}



function RMC($data)
{
$db_info = db_info();
$server=$db_info[0];
$username =$db_info[1]; 
$password = $db_info[2];
$database = $db_info[3];
//connection
$data = strip_tags($data);
$data = stripslashes($data);   //remove this later
//$data = urlencode($data);   //add this
$con=mysqli_connect($server, $username, $password,$database);
$data = mysqli_real_escape_string($con, $data);
//$data = htmlspecialchars($data);
$data = trim($data);
return $data;   
}


    function RMC2($data)
    {
    $db_info = db_info();
    $server=$db_info[0];
    $username =$db_info[1]; 
    $password = $db_info[2];
    $database = $db_info[3];
    //connection
    $data = urlencode($data);   //add this
    $data = strip_tags($data);
    $data = stripslashes($data);   //remove this later
    $con=mysqli_connect($server, $username, $password,$database);
    $data = mysqli_real_escape_string($con, $data);
    $data = trim($data);
    return $data;  
    }


//display RMC2 content
function DRMC($data) { //display
	$data = urldecode($data);
	//$data = htmlspecialchars($data);   //remove this later
    $data = trim($data);
    $data = nl2br($data);
   return $data;
}




function RMC_MSG($data)
{
$db_info = db_info();
$server=$db_info[0];
$username =$db_info[1]; 
$password = $db_info[2];
$database = $db_info[3];
//connection
$con=mysqli_connect($server, $username, $password,$database);
$data = mysqli_real_escape_string($con, $data);
$data = trim($data);
return $data;   
}
 

function DRMC_MSG($data) { //display
    $data = str_replace("\\'","'",$data);
    $data = str_replace('\\"','"',$data);
    $data = str_replace('\r\n',' ',$data);
   return $data;
}

function DRMC_NOTIFY($data) { //display
    $data = str_replace("\\'","'",$data);
    $data = str_replace('\\"','"',$data);
    $data = str_replace('\r\n','<br>',$data);
   return $data;
}
?>