session_start();
$_SESSION['url']="https://".gethostbyaddr($_SERVER['REMOTE_ADDR'])."/";
$_SESSION['daysSearch']=1;
// -------------- connect to the database --------------------------------
//error_reporting(0);
function db_conn(){
//This is for the qaserver
@$db = "springbreakdirect_2007";
@$location = "localhost";
@$user = "root";
@$password = "spring6782inc";
@$conn = mysql_connect($location, $user, $password);
@mysql_select_db($db, $conn) or die("Couldn't select database.");
}
$max_display_homepage = 1; //maximum number of ROWS display on homepage
$max_display_perpage = 10; //maximum number of ROWS display per page
?>
//Key to ENCRYPT/DECRYPT the String, which will store as Password
$strEncDecKey="q7p8r5b5d2";
//$servername_defined="http://192.168.1.230/";
//$servername_defined="http://ncl-it-40/sbd/";
//$servername_defined="http://213.130.53.163/sbd/";
$servername_defined="https://www.springbreakdirect.com/";
?>
/*FUNCTION WHICH WILL ENCRYPT THE STRING IT WILL REQUIRE 2 PARAMETERS STRING TO BE ENCRYPTED AND THE KEY BY WHICH THE STRING
WILL BE ENCYPTED / DECRYPTED*/
function Encrypt($string, $key)
{
$result = '';
for($i=1; $i<=strlen($string); $i++)
{
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return $result;
}
/*FUNCTION WHICH WILL DECRYPT THE STRING IT WILL REQUIRE 2 PARAMETERS STRING TO BE DECRYPTED AND THE KEY BY WHICH THE STRING
WILL BE ENCYPTED / DECRYPTED*/
function Decrypt($string, $key)
{
$result = '';
for($i=1; $i<=strlen($string); $i++)
{
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
function fncGetPassword($userName)
{
include "config.inc.php";
//@$pwdCollection=array("temppass","return","abcdedf","opreods","fdfdghf","divyesh","suresh","anshul","kapil","jaspreet");
$strSql="select userid,userpassword from tblusers where userloginid='" . $userName. "'";
$result=mysql_query($strSql) or die(mysql_error());
$i=0;
$countData=mysql_num_rows($result);
if ($countData==0)
return 2;
else
{
$row=mysql_fetch_array($result) or die(mysql_error());
$userIdVal=$row[0] or die(mysql_error());
// $num=rand(0,9);
$password=Decrypt($row[1],$strEncDecKey);
//$randPass=$pwdCollection[$num];
//$encryptPassword=md5($randPass);
//$strSql="update tblusers set UserPassword='" . $encryptPassword . "' where userId=". $userIdVal;
//mysql_query($strSql) or die(mysql_error());
echo " Your new Password is ".$password."";
return 1;
}
}
function changePassword($id,$oldPass,$newPass,$confirmPass)
{
include "config.inc.php";
$strSql="select userpassword from tblusers where userid=". $id;
$result=mysql_query($strSql) or die('Error Occured');
$row=mysql_fetch_array($result);
$dbPassword=$row[0];
if ($dbPassword=="")
{
return 0;
}
else
{
if ($dbPassword==Encrypt($oldPass,$strEncDecKey))
{
if ($newPass==$confirmPass)
{
$strSql="update tblusers set userpassword='".Encrypt($newPass,$strEncDecKey)."' where userid=".$id;
mysql_query($strSql) or die(mysql_error());
return 1;
}
else
return 2;
}
else
return 3;
}
}
function insertUser($login,$fname,$lname,$email,$phone,$pass,$confirmPass)
{
include "config.inc.php";
if ($pass!=$confirmPass)
{
return 0;
//Password are not same
}
elseif($login=="")
{
return 1;
//Login Field Empty
}
else
{
$strSql="select * from tblusers where userLoginId='" .$login."'";
$result=mysql_query($strSql) or die('Error Occured at Run Query');
$loginCount=mysql_num_rows($result);// or die('Error Occured at Counting'.mysql_error());
echo mysql_error();
if ($loginCount==0)
{
$encyptPass=Encrypt(trim($pass),$strEncDecKey);
$strSql="insert into tblusers (UserLoginId,UserPassword,UserFName,UserLName,UserTele,UserEmail) values('". $login."','".$encyptPass."','".$fname."','".$lname."','".$phone."','".$email."')";
$result=mysql_query($strSql) or die('Error Occured'.mysql_error());
//return (mysql_insert_id());
$arr=array(mysql_insert_id(),3);
return $arr;
}
else
{
return 2;
//Login Name Already Exists
}
}
}
function moduleInfo($parentid,$userId)
{
$strSql="select * from tblmodules where moduleparent=".$parentid;
$result=mysql_query($strSql) or die ('I am in function,.php'.mysql_error());
while($row=mysql_fetch_array($result))
{
$strSql1="select * from tblmodules where moduleparent=".$row[0];
// $temp=0;
$result1=mysql_query($strSql1) or die(mysql_error());
$count=mysql_num_rows($result1) ;
echo mysql_error();
//echo $count;
//echo "Hello";
//echo $row[0];
$countLevel =childCount($row[0],0);
//echo "This is out".$countLevel;
//echo "".$countLevel."";
//for($i=0;$i<$countLevel;$i++)
// {
// echo "Hello";
// }
$strSelected="select count(*) from tblusermodules where ModuleId=".$row[0]." and userId=".$userId;
$result_selected=mysql_query($strSelected) or die(mysql_error());
$row_selected=mysql_fetch_array($result_selected);
if ($row_selected[0]>0)
{
echo ''.$row[1].'';
}
else
{
echo ''.$row[1].'';
}
echo " ";
if ($count>0)
{
//echo $countLevel
moduleInfo($row[0],$userId);
}
/*else
{
echo $row[0];
echo " ";
}*/
}
//return $result;
}
function childCount($moduleid,$i)
{
//echo "At start ".$i;
//$strSql="select moduleId from tblmodules where moduleparent="$parentid;
//$i=0;
$strSql2="select moduleparent from tblmodules where moduleid=".$moduleid;
$result=mysql_query($strSql2);
while($row=mysql_fetch_array($result))
{
//echo "&t";
echo " ";
echo " ";
if ($row[0]==0)
{
//echo "Before Break".$i;
break;
}
else
{
$i=$i+1;
childCount($row[0],$i);
//echo $i;
}
}
//echo "At end ".$i;
return $i;
}
function fncValidateParent($arrModule,$module)
{
$flag=0;
$strSql="select ModuleParent from tblmodules where ModuleId='$module'";
$result=mysql_query($strSql);
$row=mysql_fetch_array($result);
foreach ($arrModule as $parent)
{
if($parent==$row["ModuleParent"] || $row["ModuleParent"]==0)
{
$flag=1;
break;
}
}
return $flag;
}
function dateValidation($date)
{
$date=explode('-',$date);
$cury=date("Y");
$curm=date("m");
$curd=date("d");
if($date[2]<=$cury)
{
if($date[1]<=$curm)
{
if($date[1]<$curm)
{
return true;
exit;
}
if($date[0]<=$curd)
{
return true;
}
else
{
//echo "Date of birth is not valid";
return false;
}
}
else
{
//echo "Date of birth is not valid";
return false;
}
}
else
{
return false;
}
}
?>