# fb_profile_v1.php ######################################################################################################################################################################
# $SCRIPT == /members/ shows member profile, posts and contributions
# $SCRIPT == /live/ animated display of what's happening on the site now
# $SCRIPT == /settings/ edit member settings
$pagelength = 20;
require("fb_start.php");
function resize($src, $newwidth, $newheight, $newsrc) {
list($width, $height, $type, $attr) = getimagesize($src);
if ($width > 2000 or $height > 2000) {
return 0;
} else {
switch($type) {
case 1:
$old = imagecreatefromgif($src);
break;
case 2:
$old = imagecreatefromjpeg($src);
break;
case 3:
$old = imagecreatefrompng($src);
break;
case 15:
$old = imagecreatefromwbmp($src);
break;
default:
return 0; }
if ($newwidth <= 0 && $newheight <= 0) {
$newwidth= $width; $newheight= $height;
} else {
if ($newwidth <= 0) {
$raport= $newheight / $height; $newwidth= $width * $raport;
} elseif ($newheight <= 0) {
$raport= $newwidth / $width;
$newheight= $height * $raport;
}}
if (($newwidth >= $width) || ($newheight >= $height)) { $newwidth= $width; $newheight= $height; }
$aux= imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($aux, $old, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($aux, $newsrc);
return 1; } }
function exploder($array, $element, $explode) {
$a = explode($explode, $array);
return $a[$element]; }
if ($SCRIPT == "members" and $PARAMETER1 == "!" and isset($PARAMETER2) and $PARAMETER2 == "data" and $PARAMETER3 == "") {
exit;
if (isset($PARAMETER4)) {
$lastdate = str_replace("$source";
}
$time = microtime();
$time = explode(" ", $time);
$time = $time[1] + $time[0];
$finish = $time;
$totaltime = ($finish - $scriptstart);
error_log($_SERVER["SCRIPT_NAME"] . " {$_SERVER['REQUEST_URI']} script took $totaltime \n=====================================================================================================================================", 0);
exit; }
if ($SCRIPT == "polls" and isset($PARAMETER1) and $PARAMETER1 == "vote" and isset($PARAMETER2) and is_numeric($PARAMETER2) and isset($PARAMETER3) and is_numeric($PARAMETER3)) {
if (isset($US_ID)) $u = $US_ID; else $u = $_SERVER['REMOTE_ADDR'];
$sql = "select * from PO_PollQuestions where POQ_ID = " . mysql_real_escape_string($PARAMETER2) . " and POQ_Status = 'L'";
$res = mysql_query($sql);
while($row = mysql_fetch_array($res)) {
#if (isset($US_TYPE)) {
$sql_del = "delete from PO_PollAnswers where POA_Poll = " . mysql_real_escape_string($PARAMETER2) . " and POA_User = '$u' limit 1"; mysql_query($sql_del);
$sql_ins = "insert into PO_PollAnswers values(0, " . mysql_real_escape_string($PARAMETER2) . ", '$u', " . mysql_real_escape_string($PARAMETER3) . ")"; mysql_query($sql_ins);
#}
if ($row['POQ_User'] == 0) $u = ""; else { $row2 = mysql_fetch_row(mysql_query("select US_Username from US_Users where US_ID = {$row['POQ_User']}")) or exit; $u = $row2[0]; }
header("location: $PATH/members/$u/polls/$PARAMETER2/" . storyTitle($row['POQ_Question'])); exit;
} }
if ($SCRIPT == "polls" and $PARAMETER1 == "js") { # create javascript for polls
if (isset($PARAMETER3) and ($PARAMETER3 == '.gitignore')) exit;
header('Content-Type: application/javascript');
$colours = "'#aa0000', '#000088', '#007700', '#ff9900', '#0099ff', '#ff0000', '#00ff00', '#0000ff', '#ffff00', '#33CC99', '#660066', '#663300'";
if (isset($PARAMETER3)) {
#if (substr_count($PARAMETER3, 'size:large') > 0) { $chartwidth = 100; $chartheight = 100; }
if (substr_count($PARAMETER3, 'type:barchart') > 0) { $charttype = "BarChart"; }
}
#if (!isset($chartwidth)) { $chartwidth = 400; $chartheight = 240; }
if (!isset($charttype)) { $charttype = "PieChart"; }
$started = 'n';
$pies = explode("|", $PARAMETER2);
foreach ($pies as &$value) {
if (!is_numeric($value)) exit;
if ($started == 'n')
print "initGalleryCharts();
var chartsData = {};
function initGalleryCharts() { google.setOnLoadCallback(initCharts); }
function initCharts() { $(window).resize(drawCharts); setupData(); drawCharts(); }
function setupData() {";
$started = 'y';
$sql = "select * from PO_PollQuestions where POQ_ID = " . mysql_real_escape_string($value) . " limit 1";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
$poll_title = stripslashes($row['POQ_Question']);
$answers = explode("\n", $row['POQ_Answers']);
$poll_data = "";
foreach ($answers as $x => $v) {
$sql2 = "select count(*) as cnt from PO_PollAnswers where POA_Poll = {$row['POQ_ID']} and POA_Answer = " . ($x+1);
$res2 = mysql_query($sql2);
while ($row2 = mysql_fetch_array($res2)) {
if ($poll_data != "") $poll_data .= ",";
$poll_data .= "['" . trim(addslashes(stripslashes($v))) . "', " . $row2['cnt'] . "]";
}
}
print "chartsData.chart{$row['POQ_ID']} = {};
chartsData.chart{$row['POQ_ID']}.data = new google.visualization.DataTable();
chartsData.chart{$row['POQ_ID']}.data.addColumn('string', 'Answer');
chartsData.chart{$row['POQ_ID']}.data.addColumn('number', 'votes');
chartsData.chart{$row['POQ_ID']}.data.addRows([$poll_data]);
chartsData.chart{$row['POQ_ID']}.chart = new google.visualization.$charttype(document.getElementById('chart{$row['POQ_ID']}'));
chartsData.chart{$row['POQ_ID']}.options = { is3D:true, width:\"90%\", height:\"90%\", colors: [$colours]};\n\n";
}
}
print "} function drawCharts() { $(\".chart_container\").each(function() { var id = $(this).attr(\"id\"); if (chartsData[id]) chartsData[id].chart.draw(chartsData[id].data, chartsData[id].options); });}";
exit; }
if ($SCRIPT == "polls" and $PARAMETER1 == "poll-delete" and isset($US_ID) and is_numeric($PARAMETER2)) {
if ($US_TYPE == "A" or $US_TYPE == "S") {
$res = mysql_query("update PO_PollQuestions set POQ_Status = 'D' where POQ_ID = " . mysql_real_escape_string($PARAMETER2) . " limit 1");
} else {
$sql = "select * from PO_PollQuestions where POQ_ID = " . mysql_real_escape_string($PARAMETER2) . " limit 1";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) if ($row['POQ_User'] == $US_ID) $res = mysql_query("update PO_PollQuestions set POQ_Status = 'D' where POQ_ID = " . mysql_real_escape_string($PARAMETER2) . " limit 1");
}
header ("location: $PATH/members/!/polls/"); exit; }
if ($SCRIPT == "members" and isset($PARAMETER1) and $PARAMETER1 != "!" and $PARAMETER1 != "") { # get user details if supplied. err if banned/deleted etc
$sql = "select * from US_Users where US_Username = \"" . mysql_real_escape_string($PARAMETER1) . "\" limit 1";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
$us_id = $row['US_ID'];
$username = $row['US_Username'];
$us_type = $row['US_Type'];
$extra = explode("~", stripslashes($row['US_Extra']));
}
if (!isset($us_type) or $us_type == "D" or $us_type == "B" or $us_type == "" or $us_type == "V") {
require("fb_top.php");
print "
Error
Sorry, this user profile doesn't exist. Please contact $SUPPORT if you believe there to be an error";
require("fb_bottom.php"); exit;}
}
######## LIVE
#if ($SCRIPT == "members" and (!isset($PARAMETER2) or (isset($PARAMETER2) and $PARAMETER2 != "data")) and (!isset($PARAMETER3) or $PARAMETER3 == '' or (isset($PARAMETER3) and is_numeric($PARAMETER3)))) {
if ($SCRIPT == "members" and (!isset($PARAMETER2) or (isset($PARAMETER2) and $PARAMETER2 != "data")) and (!isset($PARAMETER3) or $PARAMETER3 == '' or (isset($PARAMETER3) and is_numeric($PARAMETER3)))) {
if (!isset($PARM_PAGE)) $PARM_PAGE = 1;
if (!isset($PARAMETER2)) $PARAMETER2 = "";
$start = ($PARM_PAGE - 1) * $pagelength;
if ($PARAMETER2 == "") { # ALL ACTIVITY FOR USER/SITE
$PARAMETER2 = "posts";
# if (isset($us_id)) {
# $PAGE_TITLE = "All site contributions from $username";
# $sql = "select MBT_Text AS txt, MBT_Date1 AS dte, MBT_ID as data, MBT_Subject as title, 'F' as type, MBT_User as user from MB_Threads where MBT_User = $us_id union
# select BL_Intro AS txt, BL_DateTime AS dte, BL_ID as data, BL_Title as title, 'B' as type, BL_Author as user from BL_Blogs where BL_Author = $us_id and BL_DateTime < now() union
# select '' AS txt, PLE_DateTime AS dte, PLE_Match as data, '' as title, 'Q' as type, PLE_User as user from Football_PL_Predictions where PLE_User = $us_id union
# select NC_Comment AS txt, NC_DateTime as dte, concat_ws('~', NC_Story, NC_ID) as data, NE_Title as title, 'comment' as type, NC_User as user from NC_NewsComments, NE_News where NC_Story = NE_ID and NC_User = $us_id order by dte desc limit $start, $pagelength";
#}
# else {
# $PAGE_TITLE = "What's happening now on $SITE_NAME";
# $sql = "select LV_Text AS txt, LV_DateTime as dte, LV_Data as data, LV_Title as title, LV_Type as type, LV_User as user from LV_Live where LV_Domain = $SITE_ID order by LV_DateTime desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "posts") {
if (isset($us_id)) {
$PAGE_TITLE = "Latest forum posts by $username";
$sql = "select MBT_Text AS txt, MBT_Date1 AS dte, MBT_ID as data, MBT_Subject as title, 'F' as type, MBT_User as user from MB_Threads where MBT_User = $us_id
union select MBR_Text AS txt, MBR_Date AS dte, MBR_ID as data, MBR_Subject as title, 'f' as type, MBR_User as user from MB_Replies where MBR_User = $us_id and MBR_Initial = 0
order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest forum posts"; $sql = "select LV_Text AS txt, LV_DateTime as dte, LV_Data as data, LV_Title as title, LV_Type as type, LV_User as user from LV_Live where LV_Domain = $SITE_ID and LV_Type = 'F' order by LV_DateTime desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "comments") {
if (isset($us_id)) { $PAGE_TITLE = "Latest news and blog comments by $username"; $sql = "select NC_Comment AS txt, NC_DateTime as dte, NC_ID as data, NC_Story as title, 'C' as type, NC_User as user from NC_NewsComments where NC_Status != 'D' and NC_User = $us_id union select NC_Comment AS txt, NC_DateTime as dte, NC_ID as data, NC_Story as title, 'c' as type, NC_User as user from BC_BlogComments where NC_User = $us_id order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest news and blog comments"; $sql = "select LV_Text AS txt, LV_DateTime as dte, LV_Data as data, LV_Title as title, LV_Type as type, LV_User as user from LV_Live where LV_Domain = $SITE_ID and (LV_Type = 'C' or LV_Type = 'c') order by LV_DateTime desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "polls") {
if (isset($us_id)) { $PAGE_TITLE = "Latest polls by $username"; $sql = "select POQ_Answers AS txt, POQ_DateTime as dte, POQ_ID as data, POQ_Question as title, 'P' as type, POQ_User as user from PO_PollQuestions where POQ_User = $us_id and POQ_Status != 'D' order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest polls"; $sql = "select POQ_Answers AS txt, POQ_DateTime as dte, POQ_ID as data, POQ_Question as title, 'P' as type, POQ_User as user from PO_PollQuestions where POQ_Domain = $SITE_ID and POQ_Status != 'D' order by dte desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "ratings") {
if (isset($us_id)) { $PAGE_TITLE = "Latest ratings by $username"; $sql = "select '' AS txt, max(PRV_DateTime) as dte, PRV_Match as data, '' as title, 'R' as type, PRV_User as user from Football_PV_PlayerVotes where PRV_User = $us_id group by PRV_Match, PRV_User order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest polls"; $sql = "select '' AS txt, max(PRV_DateTime) as dte, PRV_Match as data, '' as title, 'R' as type, PRV_User as user from Football_PV_PlayerVotes group by PRV_Match, PRV_User order by dte desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "reports") {
if (isset($us_id)) { $PAGE_TITLE = "Latest Your Reports by $username"; $sql = "select YR_Text AS txt, YR_DateTime as dte, YR_Match as data, '' as title, 'Y' as type, YR_User as user from Football_YR_YourReport where YR_User = $us_id and YR_Flag = 'A' order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest polls"; $sql = "select YR_Text AS txt, YR_DateTime as dte, YR_Match as data, '' as title, 'Y' as type, YR_User as user from Football_YR_YourReport where YR_Flag = 'A' order by dte desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "predictions") {
if (isset($us_id)) { $PAGE_TITLE = "Latest predictions by $username"; $sql = "select '' AS txt, PLE_DateTime as dte, PLE_Match as data, '' as title, 'Q' as type, PLE_User as user from Football_PL_Predictions where PLE_User = $us_id order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest polls"; $sql = "select '' AS txt, PLE_DateTime as dte, PLE_Match as data, '' as title, 'Q' as type, PLE_User as user from Football_PL_Predictions order by dte desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "team-selector") {
if (isset($us_id)) { $PAGE_TITLE = "Latest team selections by $username"; $sql = "select '' AS txt, TS_DateTime as dte, TS_ID as data, TS_Title as title, 'S' as type, TS_User as user from Football_TS_TeamSelector where TS_Domain = $SITE_ID and TS_User = $us_id and TS_Status = 'L' order by dte desc limit $start, $pagelength"; }
else { $PAGE_TITLE = "Latest team selections"; $sql = "select '' AS txt, TS_DateTime as dte, TS_ID as data, TS_Title as title, 'S' as type, TS_User as user from Football_TS_TeamSelector where TS_Domain = $SITE_ID and TS_Status = 'L' order by dte desc limit $start, $pagelength"; }
}
if ($PARAMETER2 == "blogs") {
if (isset($us_id)) {
$PAGE_TITLE = "Blogs from $username";
$sql = "select BL_Intro AS txt, BL_DateTime AS dte, BL_ID as data, BL_Title as title, 'B' as type, BL_Author as user from BL_Blogs where BL_Domain = $SITE_ID and BL_Author = $us_id and BL_DateTime < now() order by dte desc limit $start, $pagelength"; }
else {
$PAGE_TITLE = "$SITE_NAME blogs";
$sql = "select BL_Intro AS txt, BL_DateTime AS dte, BL_ID as data, BL_Title as title, 'B' as type, BL_Author as user from BL_Blogs where BL_Domain = $SITE_ID and BL_DateTime < now() order by dte desc limit $start, $pagelength"; }
}
$res = mysql_query($sql);
$recs = 0; $source = ""; $lastdate = 0; $newuser = "";
while ($row = mysql_fetch_array($res)) {
if ($recs < $pagelength) {
$sql_user = "select * from US_Users where US_ID = " . $row['user'] . " limit 1";
$res_user = mysql_query($sql_user);
$avatar = ""; $US_Username = "";
while ($row_user = mysql_fetch_array($res_user)) {
if (!isset($us_id)) $newuser = " by {$row_user['US_Username']}";
if (is_file("images/avatars/{$row['user']}.gif")) $avatar = "";
else $avatar = "";
$US_Username = $row_user['US_Username'];
}
if ($avatar == "") $avatar = "";
$date = date("H:i j M Y", strtotime($row['dte']));
if ($row['type'] == "B") $row['txt'] = strip_tags($row['txt']);
if ($row['type'] == 'F') $source .= "