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']." | ";
| | |