350 lines
12 KiB
PHP
350 lines
12 KiB
PHP
<?php if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/include/analytics/');
|
|
ini_set('session.bug_compat_warn', 0);
|
|
ini_set('session.bug_compat_42', 0);
|
|
include(PATHTOINCLUDES."base.php");
|
|
$em="";
|
|
$page = "community";
|
|
include "header.php";/* $Id: community.php 59 2012-03-25 03:25:54Z phil $ */
|
|
$dbcon=dbconnect2();
|
|
$csql="SELECT
|
|
`cp_sitemessage`.`cp_sitemsg`,
|
|
`cp_sitemessage`.`cp_active`,
|
|
`cp_sitemessage`.`lastupdate`
|
|
FROM `cp_sitemessage` WHERE `cp_sitemessage`.`cp_id` = 1";
|
|
$cresult=mysql_query($csql) or $em=$em.mysql_error();
|
|
$cp=mysql_fetch_assoc($cresult);
|
|
$_SESSION["cp_userid"]=$user->user_info['user_id'];
|
|
$_SESSION["pagename"]="Community Page";
|
|
$_SESSION["nickname"]=$user->user_info['user_username'];
|
|
$_SESSION["blocklist"]=$user->user_info['user_blocklist'];
|
|
$_SESSION["invisible"]=$user->user_info['user_invisible'];
|
|
$_SESSION["userphoto"]=$user->user_photo("./images/nophoto.png",true);
|
|
$_SESSION["cp_useremail"]=$user->user_info['user_email'];
|
|
$_SESSION["cp_userlevel"]=$user->user_info['user_level_id'];
|
|
//if(!isset($_SESSION["newvisit"]))
|
|
// {
|
|
|
|
include(PATHTOINCLUDES."setstate2.php");
|
|
// }
|
|
include(PATHTOINCLUDES."recordset.php");
|
|
date_default_timezone_set('America/Phoenix');
|
|
function get_timespan_string($older, $newer) {
|
|
$Y1 = $older->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, 'minute').' ';
|
|
}
|
|
if($found_first_diff) {
|
|
//$timespan_string .= 'and ';
|
|
}
|
|
//$timespan_string .= pluralize($s, 'second');
|
|
return $timespan_string;
|
|
}
|
|
|
|
function pluralize( $count, $text )
|
|
{
|
|
return $count . ( ( $count == 1 ) ? ( "$text" ) : ( "${text}" ) );
|
|
}
|
|
|
|
$wid=0;
|
|
|
|
$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 5 OFFSET 0";
|
|
$result=mysql_query($sql) or $em=$em.mysql_error();
|
|
|
|
$sql2="SELECT count(`community_wall`.`wid`) AS cwid FROM `community_wall` ORDER BY
|
|
`community_wall`.`datecreated` DESC LIMIT 100 OFFSET 0";
|
|
$rcount=mysql_query($sql2);
|
|
$thecount = mysql_result($rcount,0);
|
|
mysql_free_result($rcount);
|
|
|
|
$rownum=0;
|
|
$thewall="";
|
|
while ($row = mysql_fetch_assoc($result)) {
|
|
$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";}
|
|
|
|
|
|
if($rownum==1)
|
|
{
|
|
$firstrow="<div class=\"wall-msg firstrow\" id=\"wall_post_0\">
|
|
<div class=\"wall-msg-pad\">
|
|
<a href=\"http://bateworld.com/profile.php?user=".stripslashes($row['displayname'])."\" target=\"_community\"><img src=\"".$uimage."\" width=\"50\" /></a>
|
|
<div>
|
|
<span class=\"from_msg\">Posted by <a href=\"http://bateworld.com/profile.php?user=".stripslashes($row['displayname'])."\" target=\"_community\">".stripslashes($row['displayname'])."</a></span>
|
|
<span class=\"date_msg\">Most Recent Post ".$ug."</span>
|
|
<div class=\"wall-clear-right\"> </div>
|
|
</div>
|
|
<div class=\"wmsg\" id=\"wmsg_".$row["wid"]."\" style=\"border:none; outline: none;\">".stripslashes($row['msg'])."</div>
|
|
<div class=\"wall-clear\"> </div>
|
|
</div>";
|
|
if($_SESSION["cp_userid"]==21092 || $_SESSION["cp_userid"]==7563 || $_SESSION["cp_userid"]==6286 || $_SESSION["cp_userid"]==8 || $_SESSION["cp_userid"]==58188){
|
|
$firstrow=$firstrow."<div style=\"position:relative;text-align:center;\">";
|
|
$firstrow=$firstrow."<input type=\"button\" value=\"D\" class=\"bl_delbutton\" onclick=\"del_wall_post('".$row["wid"]."','0')\" />";
|
|
$firstrow=$firstrow."<input type=\"button\" value=\"E\" class=\"bl_editbutton\" onclick=\"edit_wall_post('".$row["wid"]."','".$rownum."')\" />";
|
|
$firstrow=$firstrow."<input type=\"button\" value=\"Update\" class=\"bl_updatebutton\" onclick=\"update_wall_post('".$row["wid"]."','".$rownum."')\" />";
|
|
$firstrow=$firstrow."</div>"; }
|
|
|
|
$firstrow=$firstrow."</div>";
|
|
|
|
|
|
$wid=$row["wid"];
|
|
}
|
|
|
|
else {
|
|
$thewall=$thewall."<div class=\"wall-msg\" id=\"wall_post_".$rownum."\" style=\"background:".$rc.";\">
|
|
<div class=\"wall-msg-pad\">
|
|
<a href=\"http://bateworld.com/profile.php?user=".stripslashes($row['displayname'])."\" target=\"_community\"><img src=\"".$uimage."\" width=\"50\" /></a>
|
|
<div>
|
|
<span class=\"from_msg\">Posted by <a href=\"http://bateworld.com/profile.php?user=".stripslashes($row['displayname'])."\" target=\"_community\">".stripslashes($row['displayname'])."</a></span>
|
|
<span class=\"date_msg\">".$ug."</span>
|
|
<div class=\"wall-clear-right\"> </div>
|
|
</div>
|
|
<div class=\"wmsg\" id=\"wmsg_".$row["wid"]."\" style=\"border:none; outline: none;\">".stripslashes($row['msg'])."</div>
|
|
<div class=\"wall-clear\"> </div>
|
|
|
|
</div>";
|
|
if($_SESSION["cp_userid"]==21092 || $_SESSION["cp_userid"]==7563 || $_SESSION["cp_userid"]==6286 || $_SESSION["cp_userid"]==8 || $_SESSION["cp_userid"]==58188){
|
|
$thewall=$thewall."<div style=\"position:relative;text-align:center;\">";
|
|
$thewall=$thewall."<input type=\"button\" value=\"D\" class=\"bl_delbutton\" onclick=\"del_wall_post('".$row["wid"]."','".$rownum."')\" />";
|
|
$thewall=$thewall."<input type=\"button\" value=\"E\" class=\"bl_editbutton\" onclick=\"edit_wall_post('".$row["wid"]."','".$rownum."')\" />";
|
|
$thewall=$thewall."<input type=\"button\" value=\"Update\" class=\"bl_updatebutton\" onclick=\"update_wall_post('".$row["wid"]."','".$rownum."')\" />";
|
|
$thewall=$thewall."</div>";
|
|
}
|
|
|
|
$thewall=$thewall."</div>";
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if(!isset($offset)){
|
|
$offset=0;
|
|
}
|
|
else
|
|
{
|
|
if($offset==""){$offset=0;}
|
|
}
|
|
|
|
$limit=4;
|
|
$container="wall_posts";
|
|
$page_url="/js/act/wall_rs_act.php";
|
|
$navaid=recordsetNav($thecount,$page_url,$container,$offset,$limit,1);
|
|
$navaid="<div id=\"navaid\">".$navaid."</div>";
|
|
|
|
if($thecount > 5)
|
|
{
|
|
$thewall=$thewall.$navaid;
|
|
}
|
|
|
|
if(!isset($_SESSION["cmsglupd"]))
|
|
{
|
|
$_SESSION["cmsglupd"]=$cp["lastupdate"];
|
|
}
|
|
$datea=strtotime($cp["lastupdate"]);
|
|
|
|
$dateb=strtotime($_SESSION["cmsglupd"]);
|
|
$thedd=$datea-$dateb;
|
|
if($cp["cp_sitemsg"]==""){$cpannounce="<br />";} else {$cpannounce=stripslashes($cp["cp_sitemsg"]);}
|
|
|
|
|
|
|
|
$em="";
|
|
if(!isset($_COOKIE["batorid"]))
|
|
{
|
|
$bwa_expire=strtotime("+3 years");
|
|
$bwa_data=uuid();
|
|
setcookie('batorid', $bwa_data, $bwa_expire,'/', false, 0);
|
|
$bwa_ip=getRealIpAddr();
|
|
$sql_bwa="INSERT INTO site_analytics (u_uid, current_userid, init_ul, current_ul, init_ip, current_ip, `init_uname`)
|
|
VALUES ('".$bwa_data."',".$user->user_info['user_id'].",".$user->user_info['user_level_id'].", ".$user->user_info['user_level_id'].",'".$bwa_ip."','".$bwa_ip."','".$user->user_info['user_username']."')";
|
|
mysql_query($sql_bwa) or $em=$em.mysql_error();
|
|
}
|
|
else
|
|
{
|
|
$bwa_cid=$_COOKIE["batorid"];
|
|
$bwa_ip=getRealIpAddr();
|
|
$sql_bwa="SELECT u_uid, current_userid FROM site_analytics WHERE u_uid = '".$_COOKIE["batorid"]."' LIMIT 1";
|
|
$q_bwa=mysql_query($sql_bwa) or $em=$em.mysql_error();
|
|
$i_bwa=mysql_fetch_assoc($q_bwa);
|
|
if($user->user_info['user_id'] != $i_bwa["current_userid"])
|
|
{
|
|
$sql_up_bwa="UPDATE site_analytics SET current_ul = ".$user->user_info['user_level_id'].", current_ip = '".$bwa_ip."', `current_date` = Now(), current_userid = ".$user->user_info['user_id'].", prev_userid = ".$i_bwa["current_userid"].", current_uname = '".$user->user_info['user_username']."' WHERE u_uid = '".$bwa_cid."'";
|
|
mysql_query($sql_up_bwa) or $em=$em.mysql_error();
|
|
}
|
|
else
|
|
{
|
|
|
|
$sql_up_bwa="UPDATE site_analytics SET current_ul = ".$user->user_info['user_level_id'].", current_ip = '".$bwa_ip."', `current_date` = Now(), current_uname = '".$user->user_info['user_username']."' WHERE u_uid = '".$bwa_cid."'";
|
|
mysql_query($sql_up_bwa) or $em=$em.mysql_error();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$ctpsql="SELECT
|
|
`caption_this_pic`.`hcidu`,
|
|
`caption_this_pic`.`hcuid`,
|
|
`caption_this_pic`.`ctpactive`,
|
|
`caption_this_pic`.`hc_path`,
|
|
`caption_this_pic`.`hc_name`,
|
|
`caption_this_pic`.`hc_ext`,
|
|
`caption_this_pic`.`blogid`,
|
|
`caption_this_pic`.`ctpused`
|
|
FROM
|
|
`caption_this_pic`
|
|
WHERE
|
|
`caption_this_pic`.`ctpused` = 'yes'
|
|
ORDER BY
|
|
`caption_this_pic`.`hcidu` DESC";
|
|
$ctpresult=mysql_query($ctpsql) or $em=$em.mysql_error();
|
|
$ctpactive="";
|
|
$ctpentries="";
|
|
$ctpimages="";
|
|
while ($row = mysql_fetch_assoc($ctpresult)) {
|
|
$fullctpimg=$row["hc_path"]."/".$row["hc_name"]."_full.".$row["hc_ext"]."?id=".$row["hcidu"];
|
|
$medctpimg=$row["hc_path"]."/".$row["hc_name"]."_medium.".$row["hc_ext"];
|
|
|
|
if($row["ctpactive"]=="yes")
|
|
{
|
|
$ctpactive='<a class="rsContent" href="javascript:get_page(\'http://bateworld.com/caption_this_pic.php?user=CaptionThisPic&blogentry_id='.$row["blogid"].'\')" style="margin-left:0px;"><img src="'.$medctpimg.'" class="rsImg" /></a>';
|
|
}
|
|
else
|
|
{
|
|
$ctpentries.='<a class="rsContent" href="javascript:get_page(\'http://bateworld.com/caption_this_pic.php?user=CaptionThisPic&blogentry_id='.$row["blogid"].'\')" style="margin-left:0px;"><img src="'.$medctpimg.'" class="rsImg" /></a>';
|
|
}
|
|
}
|
|
$ctpimages=$ctpactive.$ctpentries;
|
|
|
|
|
|
$smarty->assign('ctpimages',$ctpimages);
|
|
$smarty->assign('thetitle',"Community Page");
|
|
$smarty->assign('em',$em);
|
|
$smarty->assign('announce', $cpannounce);
|
|
$smarty->assign('aactive', $cp["cp_active"]);
|
|
$smarty->assign('firstrow', $firstrow);
|
|
$smarty->assign('thewall', $thewall);
|
|
$smarty->assign('wid', $wid);
|
|
$smarty->assign('pdp_rcount',$thecount);
|
|
include "footer.php";
|
|
?>
|