require_login();
//session_start();
//print_r($_POST);
// For calculating difference between two dates
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $end_date - $start_date;
}
function timediff($startdate,$enddate)
{
$time_period = ( $enddate - $startdate );
$days = 0;
$hours = 0;
$minutes = 0;
$seconds = 0;
$time_increments = array( 'Days' => 86400,
'Hours' => 3600,
'Minutes' => 60,
'Seconds' => 1 );
## will hold our values for ( day, minute, hour, seconds )
$time_span = array();
## cycle through time_increments
while( list( $key, $value ) = each( $time_increments )) {
$this_value = (int) ( $time_period / $value );
$time_period = ( $time_period % $value );
# save value
$time_span[$key] = $this_value;
}
//print_r($time_span);
## show results
//while( list( $key, $value ) = each( $time_span )) {
//print "$key $value
\n";
// }
return $time_span;
}
//
// Greet the currently logged-in user!
//echo "
Hello, !
";
$facebook_users = $facebook->api_client->fql_query('SELECT hometown_location,current_location,first_name,pic FROM user WHERE uid='.$user_id);
// Print out at most 25 of the logged-in user's friends,
// for display current location and future plans
$current_date = date("Y-m-d");
$select_plans1 = "select * from fb_plan where userid='".$user_id."' and date_format(dt_from,'%Y-%m-%d')<='".$current_date."' and date_format(dt_to,'%Y-%m-%d')>='".$current_date."'";
$select_sql2 = mysql_query($select_plans1);
$fetch_result = mysql_fetch_array($select_sql2);
$city = $fetch_result["city"];
// Future plans
$select_fplans1 = "select * from fb_plan where userid='".$user_id."' and date_format(dt_from,'%Y-%m-%d')>'".$current_date."' group by userid";
$select_fsql2 = mysql_query($select_fplans1);
//
// using the friends.get API method
$friends = $facebook->api_client->friends_getAppUsers();
$friends = array_slice($friends, 0, 25);
foreach ($friends as $friend) {
//echo "
$friend";
$fr_str .= "'".$friend."',";
}
$final_str = substr($fr_str,0,strlen($fr_str)-1);
$from_fbplan = mysql_query("SELECT * FROM fb_plan WHERE userid IN(".$final_str.") and city like '%".$city."%'");
$numres = mysql_num_rows($from_fbplan);
if(!isset($_GET['s']))
$s = 0;
else
$s = $_GET["s"];
$perpage = 4;
if(($s=="")or($s>=$numres)or($s<0)or($s==0))
{
$s = 0;
}
//$facebook_frnd = $facebook->api_client->fql_query("SELECT hometown_location,current_location,uid,first_name,pic FROM user WHERE uid IN(".$final_str.") limit ".$s.",".$perpage."");
$from_fbplan1 = mysql_query("SELECT * FROM fb_plan WHERE userid IN(".$final_str.") and city like '%".$city."%' group by userid limit ".$s.",".$perpage);
$numres1 = mysql_num_rows($from_fbplan1);
$msg = "";
// For adding event modified 24th december
if (isset($_POST["country"]))
{
$errmsg = "";
$from_date = $_POST["year"]."-".$_POST["month"]."-".$_POST["day"];
$to_date = $_POST["tyear"]."-".$_POST["tmonth"]."-".$_POST["tday"];
if (isset($_POST["year"]))
$diff = dateDiff("-", $to_date, $from_date);
//$diff = 0;
/*
if ($_POST["country"]=="")
$errmsg .= "Select the country";
if ($_POST["regi"]=="")
$errmsg .= "Select the region";
if ($_POST["city1"]=="")
$errmsg .= "Enter the city"; */
If(!checkdate($_POST["month"],$_POST["day"],$_POST["year"]))
$errmsg .= "Invalid From date";
If(!checkdate($_POST["tmonth"],$_POST["tday"],$_POST["tyear"]))
$errmsg .= "Invalid To date";
if ($diff <0 )
$errmsg .= "To date is smaller than From date";
if ($errmsg!='')
{
$errmsg = "";
}
else
{
$countryy = explode(",",$_POST["country"]);
$country_val = $countryy[1];
// echo "
asdfsas".$_GET["m"]."
";
$insert_event = "insert into fb_plan set userid='".$user_id."',city ='".addslashes($_POST["city1"])."',country ='".addslashes($country_val)."',region ='".addslashes($_POST["regi"])."',dt_from='".$from_date."',dt_to ='".$to_date."',description='".addslashes($_POST["desc"])."',reg_date=now()";
$insert_sql = mysql_query($insert_event);
}
}
/////////// modified 24 th december
// For edit the event
if(isset($_GET["id"]))
{
$select_event = "select plan_id,userid,description,city,country,date_format(dt_from,'%Y-%m-%d')as frd,date_format(dt_to,'%Y-%m-%d')as tod from fb_plan where plan_id='".$_GET["id"]."'";
$select_sqls = mysql_query($select_event);
$select_resu = mysql_fetch_array($select_sqls);
$fdate = explode("-",$select_resu["frd"]);
$tdate = explode("-",$select_resu["tod"]);
}
else
{
$fdate[0] = date('Y');$fdate[2] = date('d');$fdate[1] = date('m');
$tdate[0] = date('Y');$tdate[2] = date('d');$tdate[1] = date('m');
}
// Edit end
// For delete the event
if(isset($_GET["did"]))
{
$del_event = "delete from fb_plan where plan_id='".$_GET["did"]."'";
$del_sql = mysql_query($del_event);
}
// Edit end
// end
if (!isset($_GET["fu"]))
{
?>
'".$current_date."'";
//echo $select_plans;
$select_sql = mysql_query($select_plans);
$num_future_plan = mysql_num_rows($select_sql);
$select_frndplans = "select plan_id,userid,description,city,country,date_format(dt_from,'%m-%d-%Y')as frd,date_format(dt_to,'%m-%d-%Y')as tod from fb_plan where userid!='".$user_id."' and date_format(dt_from,'%Y-%m-%d')>'".$current_date."' and city like '%".$city."%'";
// echo $select_frndplans;
$select_fsql = mysql_query($select_frndplans);
$num_frnd_future_plan = mysql_num_rows($select_fsql);
?>
|
|
|
|
EVENT INFORMATION |
|
|
|
0) {?>
|
FUTURE WHEREABOUTS : |
|
while ($select_res =mysql_fetch_array($select_sql))
{?>
|
|
|
0) { ?>
|
FRIENDS SOON IN : |
|
while ($select_fres =mysql_fetch_array($select_fsql))
{
$facebook_fusers = $facebook->api_client->fql_query('SELECT hometown_location,current_location,first_name,pic FROM user WHERE uid='.$select_fres["userid"]);?>
- ( ) ( ".$facebook_fusers[0]["first_name"]."";?> coming to )
|
|
|
|
echo " ";
//echo "| ".$facebook_users[0]['first_name']." has ".$numres." friends in ".$city." ";
echo " | | ";
//for($i=0;$i<$numres1;$i++)
echo "";
$i=0;
while ($result = mysql_fetch_array($from_fbplan1))
{
$execute_per_userid = $facebook->api_client->fql_query("SELECT hometown_location,current_location,uid,first_name,pic FROM user WHERE uid='".$result["userid"]."'");
echo "";
echo "";
if ($execute_per_userid[0]['pic']!='')
echo " | ";
else
echo " | ";
echo "
| Name | : | ".$execute_per_userid[0]['first_name']." | ";
| | |