<?php

/*if(!defined('MyConst')) {

  header('Location:index.php');

}

*/

class customPDO extends PDO{



private $user;

private $password;

private $host;

private $db_name;

private $engine="mysql";





function customPDO($username,$pass,$db,$host){ 

        $this->user=$username;

        $this->password=$pass;

        $this->db_name=$db;

        $this->host=$host;

        $dns = $this->engine.':dbname='.$this->db_name.";host=".$this->host; 

        parent::__construct( $dns, $this->user, $this->password ); 

        try

    		{

    			$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    		}

    		catch (PDOException $e)

    		{

    			die($e->getMessage());

    		}

    }





function selectData($sql)

{

	$query = $this->prepare($sql); 

    $query->execute();

    return $query->fetchall(PDO::FETCH_ASSOC); 

}



function insertData($sql)

{

	$this->exec($sql);

}





 function SMS_API_RETURN($phone, $message, $sender_id) {

    $key = "B8y19qHznfmmZ7QSA690Wi4cU";

    $message2 = urlencode($message);

    $to = trim($phone);

    $URL = "http://bulk.mnotify.net/smsapi?key=$key&to=$to&msg=$message2&sender_id=$sender_id";

    $result = file_get_contents($URL);

}





function base_url($atRoot=FALSE, $atCore=FALSE, $parse=FALSE){

        if (isset($_SERVER['HTTP_HOST'])) {

            $http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';

            $hostname = $_SERVER['HTTP_HOST'];

            $dir =  str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);



            $core = preg_split('@/@', str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(dirname(__FILE__))), NULL, PREG_SPLIT_NO_EMPTY);

            $core = $core[0];



            $tmplt = $atRoot ? ($atCore ? "%s://%s/%s/" : "%s://%s/") : ($atCore ? "%s://%s/%s/" : "%s://%s%s");

            $end = $atRoot ? ($atCore ? $core : $hostname) : ($atCore ? $core : $dir);

            $base_url = sprintf( $tmplt, $http, $hostname, $end );

        }

        else $base_url = 'http://localhost/';



        if ($parse) {

            $base_url = parse_url($base_url);

            if (isset($base_url['path'])) if ($base_url['path'] == '/') $base_url['path'] = '';

        }



        return $base_url;

    }





    function is_connected()

{

    $connected = @fsockopen("www.google.com", 80); 

                                        //website, port  (try 80 or 443)

    if ($connected){

        $is_conn = true; //action when connected

        fclose($connected);

    }else{

        $is_conn = false; //action in connection failure

    }

    return $is_conn;



}





}







$mysqlLocal=new customPDO('root','forall2love','rxclaim_client','localhost');

if($mysqlLocal->is_connected()==true){

$mysqlLive=new customPDO('rxclaim_user','QZiN[5)3l0wm','rxclaim_live','69.64.72.136');

}else{

    $mysqlLive=0;

   // print_r(json_encode(array( "STATUSCODE"=>"000","STATUSMSG"=>"No Internet")));

   // exit;

}





?>