<?php
// website configuration constants 
DEFINE('sitename', 'Total Transfer');
DEFINE('sitemail',  'support@ttransfer.click');
DEFINE('sitelink', 'https://ttransfer.click');
DEFINE('siteurl', 'ttransfer.click');
 
DEFINE('siteaddress', 'Ohio United States');
DEFINE('sitenumber', 'N/A');

// DEFINE('siteaddress', '908 Radic Road, NewYork, USA');
// DEFINE('sitenumber', '+5 (87) 8695-312');



function purify($dat){
$dats = htmlspecialchars(trim(addslashes($dat)));
$data = filter_var($dats, FILTER_SANITIZE_STRING);
if ($data) {
return $data;
}else{
return FALSE;
}
}
function v_email($data){
$vmail = filter_var($data, FILTER_SANITIZE_EMAIL);
$v_email = filter_var($data, FILTER_VALIDATE_EMAIL);
if ($v_email) {
return $v_email;
} else {
return FALSE;
}
}

function preg_string($data){
$string = preg_match("/^['A-Z a-z']*$/", $data);
if ($string) {
return $string;
} else {
return FALSE;
}

}

function preg_string1($data){
$string = preg_match("/^['A-Za-z']*$/", $data);
if ($string) {
return $string;
} else {
return FALSE;
}

}

function getIPAddress() {  
//whether ip is from the share internet  
if(!empty($_SERVER['HTTP_CLIENT_IP'])) {  
$ip = $_SERVER['HTTP_CLIENT_IP'];  
}  
//whether ip is from the proxy  
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {  
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];  
}  
//whether ip is from the remote address  
else{  
$ip = $_SERVER['REMOTE_ADDR'];  
}  
return $ip;  
}


function preg_StrInt($data){
$string = preg_match("/^['A-Z a-z 0-9']*$/", $data);
if ($string) {
return $string;
} else {
return FALSE;
}

}


function preg_int($data){
$int = preg_match("/^['0-9']*$/", $data);
if ($int) {
return $int;
} else {
return FALSE;
}

}

function preg_date($data){
$int = preg_match("/^['0-9-00-000']*$/", $data);
if ($int) {
return $int;
} else {
return FALSE;
}

}

function validatePassword($password)
{
if (preg_match('/^(?=.*\d)(?=.*[@#\-_$%^&+=§!\?])(?=.*[a-z])(?=.*[A-Z])[0-9A-Za-z@#\-_$%^&+=§!\?]{8,20}$/',$password)) {
return TRUE;
}else{
return FALSE;
}
}

function v_passess($password)
{
if (preg_match("#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*\W).*$#", $password )){
return TRUE; 
} else {
return FALSE;  
}
}

function v_passd($password)
{
if (preg_match("#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$#", $password)){
return TRUE;
} else {
return FALSE;  
}
}

// This function will return a random
// string of specified length
function random_alphanumericstrings($length_of_string)
{
// String of all alphanumeric character
$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// Shuffle the $str_result and returns substring
// of specified length
return substr(str_shuffle($str_result),0, $length_of_string);
}

function random_strings($length_of_string) 
{ 
// String of all alphanumeric character 
$str_result = '012345678990123456789980650403030306'; 
$str_result .= '98765432100299388858857657689202890';
$str_result .= '98712354607846583940030394048408392';
// Shufle the $str_result and returns substring 
// of specified length 
return substr(str_shuffle($str_result), 0, $length_of_string); 
}

function fetch_fund_acc(){

$get = $_GET["aid"]; 
$sql = "SELECT * FROM `users` WHERE id = '$get'";
$conn = $this->dbconn->prepare($sql);
$conn->execute();
$fetch =$conn->fetch(PDO::FETCH_ASSOC);
return $fetch;
}


function updatefunds()
{
$get = $_GET["aid"];
$sql = "UPDATE `users`  SET acc_balance = :bank_accbal,  WHERE id = '$get'";
$conn = $this->dbconn->prepare($sql);
$conn->bindParam(":bank_accbal", $this->bank_accbal);
if ($conn->execute()) {
return TRUE;
}
else {
return FALSE;
}
}

function facebook_time_ago($timestamp)  
{  
$time_ago = strtotime($timestamp);  
$current_time = time();  
$time_difference = $current_time - $time_ago;  
$seconds = $time_difference;  
$minutes      = round($seconds / 60 );           // value 60 is seconds  
$hours           = round($seconds / 3600);           //value 3600 is 60 minutes * 60 sec  
$days          = round($seconds / 86400);          //86400 = 24 * 60 * 60;  
$weeks          = round($seconds / 604800);          // 7*24*60*60;  
$months          = round($seconds / 2629440);     //((365+365+365+365+366)/5/12)*24*60*60  
$years          = round($seconds / 31553280);     //(365+365+365+365+366)/5 * 24 * 60 * 60  
if($seconds <= 60)  
{  
return "Just Now";  
}  
else if($minutes <=60)  
{  
if($minutes==1)  
{  
return "one minute ago";  
}  
else  
{  
return "$minutes minutes ago";  
}  
}  
else if($hours <=24)  
{  
if($hours==1)  
{  
return "an hour ago";  
}  
else  
{  
return "$hours hrs ago";  
}  
}  
else if($days <= 7)  
{  
if($days==1)  
{  
return "yesterday";  
}  
else  
{  
return "$days days ago";  
}  
}  
else if($weeks <= 4.3) //4.3 == 52/12  
{  
if($weeks==1)  
{  
return "a week ago";  
}  
else  
{  
return "$weeks weeks ago";  
}  
}  
else if($months <=12)  
{  
if($months==1)  
{  
return "a month ago";  
}  
else  
{  
return "$months months ago";  
}  
}  
else  
{  
if($years==1)  
{  
return "one year ago";  
}  
else  
{  
return "$years years ago";  
}  
}  
}

// function systemInfo()
// {
// $user_agent = $_SERVER['HTTP_USER_AGENT'];
// $os_platform    = "Unknown OS Platform";
// $os_array       = array('/windows phone 8/i'    =>  'Windows Phone 8',
// '/windows phone os 7/i' =>  'Windows Phone 7',
// '/windows nt 6.3/i'     =>  'Windows 8.1',
// '/windows nt 6.2/i'     =>  'Windows 8',
// '/windows nt 6.1/i'     =>  'Windows 7',
// '/windows nt 6.0/i'     =>  'Windows Vista',
// '/windows nt 5.2/i'     =>  'Windows Server 2003/XP x64',
// '/windows nt 5.1/i'     =>  'Windows XP',
// '/windows xp/i'         =>  'Windows XP',
// '/windows nt 5.0/i'     =>  'Windows 2000',
// '/windows me/i'         =>  'Windows ME',
// '/win98/i'              =>  'Windows 98',
// '/win95/i'              =>  'Windows 95',
// '/win16/i'              =>  'Windows 3.11',
// '/macintosh|mac os x/i' =>  'Mac OS X',
// '/mac_powerpc/i'        =>  'Mac OS 9',
// '/linux/i'              =>  'Linux',
// '/ubuntu/i'             =>  'Ubuntu',
// '/iphone/i'             =>  'iPhone',
// '/ipod/i'               =>  'iPod',
// '/ipad/i'               =>  'iPad',
// '/android/i'            =>  'Android',
// '/blackberry/i'         =>  'BlackBerry',
// '/webos/i'              =>  'Mobile');
// $found = false;
// $addr = new RemoteAddress;
// $device = '';
// foreach ($os_array as $regex => $value) 
// { 
// if($found)
// break;
// else if (preg_match($regex, $user_agent)) 
// {
// $os_platform    =   $value;
// $device = !preg_match('/(windows|mac|linux|ubuntu)/i',$os_platform)
// ?'MOBILE':(preg_match('/phone/i', $os_platform)?'MOBILE':'SYSTEM');
// }
// }
// $device = !$device? 'SYSTEM':$device;
// return array('os'=>$os_platform,'device'=>$device);
// }

// function browser() 
// {
// $user_agent = $_SERVER['HTTP_USER_AGENT'];

// $browser        =   "Unknown Browser";

// $browser_array  = array('/msie/i'       =>  'Internet Explorer',
// '/firefox/i'    =>  'Firefox',
// '/safari/i'     =>  'Safari',
// '/chrome/i'     =>  'Chrome',
// '/opera/i'      =>  'Opera',
// '/netscape/i'   =>  'Netscape',
// '/maxthon/i'    =>  'Maxthon',
// '/konqueror/i'  =>  'Konqueror',
// '/mobile/i'     =>  'Handheld Browser');

// foreach ($browser_array as $regex => $value) 
// { 
// if($found)
// break;
// else if (preg_match($regex, $user_agent,$result)) 
// {
// $browser    =   $value;
// }
// }
// return $browser;
// }

// // to check if it's a mobile, you can use,

// if($detect['device']=='MOBILE')
// {
// /* Your code for mobile devices */ 
// }
// else 
// {
// /* Your code for desktop systems */ 
// }
// // So, now you can use it like this:

// // $detect = Detect::systemInfo();
// // To check if the device is a mobile device, you can do it like this:

// if($detect['device']=='MOBILE')
// {
// /* Your code for mobile devices */ 
// }
// else 
// {
// /* Your code for desktop systems */ 
// }


?>