format('Y'); $Y2 = $newer->format('Y'); $Y = $Y2 - $Y1; $m1 = $older->format('m'); $m2 = $newer->format('m'); $m = $m2 - $m1; $d1 = $older->format('d'); $d2 = $newer->format('d'); $d = $d2 - $d1; $H1 = $older->format('H'); $H2 = $newer->format('H'); $H = $H2 - $H1; $i1 = $older->format('i'); $i2 = $newer->format('i'); $i = $i2 - $i1; $s1 = $older->format('s'); $s2 = $newer->format('s'); $s = $s2 - $s1; if($s < 0) { $i = $i -1; $s = $s + 60; } if($i < 0) { $H = $H - 1; $i = $i + 60; } if($H < 0) { $d = $d - 1; $H = $H + 24; } if($d < 0) { $m = $m - 1; $d = $d + get_days_for_previous_month($m2, $Y2); } if($m < 0) { $Y = $Y - 1; $m = $m + 12; } $timespan_string = create_timespan_string($Y, $m, $d, $H, $i, $s); return $timespan_string; } function get_days_for_previous_month($current_month, $current_year) { $previous_month = $current_month - 1; if($current_month == 1) { $current_year = $current_year - 1; //going from January to previous December $previous_month = 12; } if($previous_month == 11 || $previous_month == 9 || $previous_month == 6 || $previous_month == 4) { return 30; } else if($previous_month == 2) { if(($current_year % 4) == 0) { //remainder 0 for leap years return 29; } else { return 28; } } else { return 31; } } function create_timespan_string($Y, $m, $d, $H, $i, $s) { $timespan_string = ''; $found_first_diff = false; if($Y >= 1) { $found_first_diff = true; $timespan_string .= pluralize($Y, 'Y').' '; } if($m >= 1 || $found_first_diff) { $found_first_diff = true; $timespan_string .= pluralize($m, 'M').' '; } if($d >= 1 || $found_first_diff) { $found_first_diff = true; $timespan_string .= pluralize($d, 'D').' '; } if($H >= 1 || $found_first_diff) { $found_first_diff = true; $timespan_string .= pluralize($H, 'H').' '; } if($i >= 1 || $found_first_diff) { $found_first_diff = true; // $timespan_string .= pluralize($i, 'M').' '; } if($found_first_diff) { //$timespan_string .= 'and '; } //$timespan_string .= pluralize($s, 'S'); return $timespan_string; } function pluralize( $count, $text ) { return $count . ( ( $count == 1 ) ? ( "$text" ) : ( "${text}" ) ); } $em=""; $sql="SELECT `community_wall`.`wid`, `community_wall`.`userid`, `community_wall`.`msg`, `community_wall`.`datecreated`, `community_wall`.`displayname`, `community_wall`.`photo`, `se_users`.`user_enabled` FROM `community_wall` Left Outer Join `se_users` ON `se_users`.`user_id` = `community_wall`.`userid` WHERE `se_users`.`user_enabled` = 1 ORDER BY `community_wall`.`datecreated` DESC LIMIT 1 OFFSET 0"; $result=$database->database_query($sql) or $em=$em.$database->database_error(); $row = $database->database_fetch_assoc($result); $number = (((int)($row['userid']/1000))*1000)+1000; //$uimage="/uploads_user/".$number."/".$row['userid']."/".$row['user_photo']; if($row['photo']=="") { $uimage="/images/nophoto.png"; } else { $uimage="/uploads_user/".$number."/".$row['userid']."/".$row['photo']; } $now = time(); $dc=$row['datecreated']; $wid=$row['wid']; $cdate = $dc; $ndate = date('Y-m-d H:i:s',$now); $datetime1 = date_create($dc); $datetime2 = date_create($ndate); $ug=get_timespan_string($datetime1, $datetime2); if($ug==""){$ug="< 1H";} $firstrow="
Posted by ".$row['displayname']." Most Recent Post ".$ug."
 
".$row['msg']."
 
"; if(isset($_SESSION["cp_userid"])){ if($_SESSION["cp_userid"]==21092 || $_SESSION["cp_userid"]==7653 || $_SESSION["cp_userid"]==6286 || $_SESSION["cp_userid"]==8){ $firstrow=$firstrow."
"; $firstrow=$firstrow.""; $firstrow=$firstrow.""; $firstrow=$firstrow.""; $firstrow=$firstrow."
"; }} $firstrow=$firstrow."
"; $csql="SELECT `cp_sitemessage`.`cp_sitemsg`, `cp_sitemessage`.`cp_active`, `cp_sitemessage`.`lastupdate` FROM `cp_sitemessage` WHERE `cp_sitemessage`.`cp_id` = 1"; $cresult=$database->database_query($csql) or $em=$em.$database->database_error(); $cp=$database->database_fetch_assoc($cresult); if(!isset($_SESSION["cmsglupd"])) { $_SESSION["cmsglupd"]=$cp["lastupdate"]; } $datea=strtotime($cp["lastupdate"]); $dateb=strtotime($_SESSION["cmsglupd"]); $thedd=$datea-$dateb; $bwmessage=""; $active=$cp["cp_active"]; if($thedd > 1) { if($cp["cp_active"] == "Y"){ $bwmessage=$cp["cp_sitemsg"]; $bwmessage=stripslashes($bwmessage); } } else { $bwmessage=""; } $_SESSION["cmsglupd"]=$cp["lastupdate"]; $sql2="SELECT hits FROM cmeter"; $query2=$database->database_query($sql2) or $em=$em.$database->database_error(); $result=$database->database_fetch_assoc($query2); $hits=$result["hits"]; $hits=number_format($hits); $thewall=""; $pdp_js_count=""; $thenav=""; if(isset($_GET["tcount"])){ $pdp_js_count=$_GET["tcount"]+0; $pdp_js_count=(int)$pdp_js_count; if(!isset($wid)){$wid=$_GET["twid"];} if($pdp_js_count < 5) { $sql3="SELECT count(`community_wall`.`wid`) AS cwid FROM `community_wall` WHERE `community_wall`.`wid` <> ".$wid." ORDER BY `community_wall`.`datecreated` DESC LIMIT 100 OFFSET 0"; $rcount=$database->database_query($sql3); $thecount = $database->database_result($rcount,0); $database->database_free_result($rcount); if($pdp_js_count < 5 && $thecount >= 1) { $sql4="SELECT `community_wall`.`wid`, `community_wall`.`userid`, `community_wall`.`msg`, `community_wall`.`datecreated`, `community_wall`.`displayname`, `community_wall`.`photo`, `se_users`.`user_enabled` FROM `community_wall` Left Outer Join `se_users` ON `se_users`.`user_id` = `community_wall`.`userid` WHERE `community_wall`.`wid` <> ".$wid." AND `se_users`.`user_enabled` = 1 ORDER BY `community_wall`.`datecreated` DESC LIMIT 4 OFFSET 0"; $result4=$database->database_query($sql4) or $em=$em.$database->database_error(); $rownum=1; $thewall=""; while ($row = $database->database_fetch_assoc($result4)) { $rownum=$rownum+1; if($rownum % 2 != 0){$rc="#000";} else{$rc="#333";} $number = (((int)($row['userid']/1000))*1000)+1000; if($row["photo"]=="") { $uimage="/images/nophoto.png"; } else { $uimage="/uploads_user/".$number."/".$row['userid']."/".$row['photo']; } $now = time(); $dc=$row['datecreated']; $cdate = $dc; $ndate = date('Y-m-d H:i:s',$now); $datetime1 = date_create($dc); $datetime2 = date_create($ndate); $ug=get_timespan_string($datetime1, $datetime2); if($ug==""){$ug="< 1H";} $thewall=$thewall.'
Posted by '.stripslashes($row["displayname"]).' '.$ug.'
 
'.stripslashes($row["msg"]).'
 
'; if(isset($_SESSION["cp_userid"])){ if($_SESSION["cp_userid"]==21092 || $_SESSION["cp_userid"]==7653 || $_SESSION["cp_userid"]==6286 || $_SESSION["cp_userid"]==8){ $thewall=$thewall.''; } } $thewall=$thewall."
"; } //end result 4 while if(isset($_SESSION["pdp_no_nav_update"])){unset($_SESSION["pdp_no_nav_update"]);} } //pdp_js_count < 3 if($thecount != $pdp_js_count){$pdp_js_count=$thecount;} }//pdp_js_count < 5 }// end while if($pdp_js_count == 5 && !isset($_SESSION["pdp_no_nav_update"])) { include(PATHTOINCLUDES."recordset.php"); $offset=0; $limit=4; $container="wall_posts"; $page_url="/js/act/wall_rs_act.php"; $navaid=recordsetNav($thecount,$page_url,$container,$offset,$limit,1); if($thecount > 4){$navaid="
".$navaid."
";} $thewall=$thewall.$navaid; $_SESSION["pdp_no_nav_update"]="no more"; $pdp_js_count=6; } $arr = array ('error' => $em, 'firstrow'=> $firstrow, 'wid'=> $wid, 'hits'=> $hits, 'bwmessage' => $bwmessage, 'active' => $active,'wallcount'=> $pdp_js_count, 'thewall'=> $thewall, 'thenav'=> $thenav); echo json_encode($arr); ?>