<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('getRealIpAddr'))
{
	function getRealIpAddr()
	{
		if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
		{
		  $ip=$_SERVER['HTTP_CLIENT_IP'];
		}
		else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
		{
		  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
		}
		else
		{
		  $ip=$_SERVER['REMOTE_ADDR'];
		}
		
		return $ip;
	} 
}

if ( ! function_exists('getLoanType'))
{
	function getLoanType($type)
	{
		$loanType = ($type == '1') ? 'instalment' : 'short';
		
		return $loanType;
	} 
}

if ( ! function_exists('getSessionPrefix'))
{
	function getSessionPrefix()
	{
		$ci =& get_instance();

		return $ci->config->item('session_prefix');
	} 
}

if ( ! function_exists('addSessionVariable'))
{
	function addSessionVariable($variableName, $value)
	{

		$_SESSION[getSessionPrefix()][$variableName] = $value;
	} 
}

if ( ! function_exists('getSessionVariable'))
{
	function getSessionVariable($variableName)
	{
		if(!empty($_SESSION[getSessionPrefix()]) && isset($_SESSION[getSessionPrefix()][$variableName]))
			return $_SESSION[getSessionPrefix()][$variableName];

		return null;
	} 
}

