Jump to content

block under 16 profiles


eaglelegend

Recommended Posts

Hi, I am trying to block under 16s profiles from being shown here is the code;

 

<?php

/*

User Profile (user_profile.php)

*/

$rank_check = 1;
$page_title = "User Profile";
include "header.inc.php";

$members = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$members_profiles = fetch("SELECT * FROM members_profiles2 WHERE username = '$user' AND game = '$game'");

$online = fetch("SELECT last_visit FROM online WHERE userid = '$members[id]' ORDER BY last_visit DESC LIMIT 1");

if ($rank == "7")
{
        $iplog = fetch("SELECT ip_addr FROM ip_log WHERE userid = '$members[id]' ORDER BY id DESC LIMIT 1");
        $membersIP = " ($iplog[ip_addr])";
}
if (!$members[id])
{
        die("$openHTML<p align=center class=error>That is not a real user</p>$closeHTML");
}

if ($members[rank] <= 1)
{
        die("$openHTML<p align=center class=error>This user has been suspended.</p>$closeHTML");
}

if ($members_profiles[birthday] <= 01-01-1992)
{
        die("$openHTML<p align=center class=error>This user is under 16!</p>$closeHTML");
}

$gender = $members_profiles[gender];
$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>", "<img src=images/icons/male.gif>");
$gender = $genderArray[$gender];

$mailSettings = $members_profiles[mail_settings];
$mailSettingsArray = array(
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"");
$mailSettings = $mailSettingsArray[$mailSettings];

$bud = "<a href=buds.php?game=$game&bud=$members[username]><img src=images/icons/bud.gif></a>";

$date_registered = date("M j, Y", $members_profiles[date_registered]);
$last_visited = date("H:i", $online[last_visit]);
$last_visited2 = date("M j, Y @ H:i", $online[last_visit]);

$exBday = explode("-", $members_profiles[birthday]);
$birthday = "$exBday[2]-$exBday[0]-$exBday[1]";
function birthDate($bdate){
  $btime = strtotime($bdate);
  $byear = date('Y',$btime);//birth year
  $bmonth = date('m',$btime);//birth month
  $bday = date('d',$btime);//birth day
  $nyear = date('Y');//this year
  $years = $nyear-$byear;//number of years since birth year
  if (strtotime("$nyear-$bmonth-$bday")>time()){
    $years--;//subtract one year if they haven't had a birthday yet this year
  }
  return $years;
}
$userAge = birthDate($birthday);

if ($online[last_visit] >= ($timestamp - $secondsToKeepUsersOn))
{
        $onlineNow = "<b><font color=green>Yes! <i><font size=-1>last visit at $last_visited</font></i></font></b>";
}
else
{
        $onlineNow = "<B><font color=red>No <i><font size=-1>last visit on $last_visited2</font></i></font></b></font></b>";
}

$yourNotes = fetch("SELECT bud_note FROM buds2 WHERE bud_me = '$userid' AND bud_you = '$members[id]'");
$yourNotes = $yourNotes[bud_note];
if (!$yourNotes) { $yourNotes = "<i>You do not have any notes on the player, add them to your buddy list to add notes!</i>"; }

$find_shop = fetch("SELECT shop_name,shop_size FROM usershops2 WHERE owner = '$members[id]' AND game = '$game'");
if ($find_shop[shop_name])
{
        $usershop_line = "<b>Shop:</b> <a href=$base_url/usershop.php?game=$game&user=$user>$find_shop[shop_name]</a> <font size=-1>(size $find_shop[shop_size])</font>";
}

$find_gallery = fetch("SELECT gallery_name,gallery_size FROM usergallerys WHERE owner = '$members[id]' AND game = '$game'");
if ($find_gallery[gallery_name])
{
        $gallery_line = "<br><b>Gallery:</b> <a href=$base_url/usergallery.php?game=$game&user=$user>$find_gallery[gallery_name]</a> <font size=-1>(size $find_gallery[gallery_size])</font>";
}

$locationLine = $members_profiles[location];
if (!$locationLine)
{
        $locationLine = "<i>Middle of no where!</i>";
}

$getClub = fetch("SELECT position,club FROM club_members2 WHERE user = '$members[id]' AND game = '$game'");
$getclub = fetch("SELECT id,name FROM clubs2 WHERE id = '$getClub[club]' AND game = '$game'");
if ($getclub[id])
{
        $clubrank = $getClub[position];
        if ($clubrank == 1)
        {
                $position = "Member";
        }
        if ($clubrank == 2)
        {
                $position = "Moderator";
        }
        if ($clubrank == 3)
        {
                $position = "Admin";
        }
        $club_line = "<br><b>Club:</b> $position in <a href=$base_url/club.php?game=$game&clubid=$getclub[id]>$getclub[name]</a>";
}


$findPets = mysql_query("SELECT id,name,level FROM user_pets2 WHERE owner = '$members[id]' AND adoption = '0' AND game = '$game'");
$numUserPets = mysql_num_rows($findPets);
$x = 1;
while ($getPets = mysql_fetch_array($findPets))
{
        if ($x < $numUserPets)
        {
                $petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a> (Lvl. $getPets[level]), ";
        }
        else
        {
                $petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a> (Lvl. $getPets[level])";
        }
        $x++;
}

echo <<<END
$openHTML

<table bgcolor=#ffffff width=95%>
<tr><td>
         <CENTER>
END;

echo "<img src='uploads/$members_profiles[avatar_selected]' width=40 height=40> ";

echo <<<END
<FONT SIZE="+2"><B>$members[display_name]'s Profile</B></FONT></CENTER>

         <p>$members_profiles[profile]</p>

         <center><hr width=75% color="$tableOutline"></center>

         <font size=-1>

         <P><b>Username:</b> $members[display_name]$membersIP<br>
                        <b>Real name:</b> $members_profiles[real_name]<bR>
                        <b>Birthday:</b> $birthday ($userAge years old!)<br>
                        <b>Location:</b> $locationLine<br>
                        <b>Date Registered:</b> $date_registered<br>
                        <b>Total Referrals:</b> $members_profiles[referrals]<br>
            <b>Total Posts:</b> $members[post_count]
         </P>

         <P><b>Your Notes:</b> $yourNotes</P>

         <P><b>$numUserPets Pets:</b> $petList</p>

         <P>$usershop_line<br>
         $club_line
         $gallery_line</p>

         <p><b>Online?</b> $onlineNow</P>

                 </font>

<center><table><tr><td>
<form action=mail_send.php?game=$game&send_to=$members[username] method=post>
<input type=submit value="Send Mail">
</form></td><td>
<form action=buds.php?game=$game&bud=$members[username] method=post>
<input type=submit value="Add to Buddy List">
</form></td></tr></table></center>
</td></tr></table>

$closeHTML
END;

?>

 

Here is the code I am trying to get to block that page...

 

if ($members_profiles[birthday] <= 01-01-1992)
{
        die("$openHTML<p align=center class=error>This user is under 16!</p>$closeHTML");
}

 

please help, help is much appreciated.

Link to comment
Share on other sites

You could modify your query so that it shows only profiles 16 years old or older.

 

WHERE birthday >= DATE_SUB(CURDATE(), - INTERVAL 16 YEAR)

 

Or something similar.  Proper syntax: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

 

hey thanks!, could you give, me a hint where I can put the code at all? thanks again

Link to comment
Share on other sites

Well, the way I interpreted it is that if he's going to block them.. why show them?  That's like saying: "There's some delicious lolipops on the table, but you can't have any."

 

So if you don't even want to include them in the query, you'll need to add a modifier to the end of the query: WHERE birthday >= DATE_SUB(CURDATE(), - INTERVAL 16 YEAR);  Assuming birthday is a column of DATETIME or DATETIME compatible.

 

If you want to list the profile but display a message "Here's someone, but you can't see them."  You could probably use a strtotime check if the age is >= today's date minus 16 years and display a message or profile accordingly.

Link to comment
Share on other sites

<?php

/*

User Profile (user_profile.php)

*/

$rank_check = 1;
$page_title = "User Profile";
include "header.inc.php";

$members = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game' ");
$members_profiles = fetch("SELECT * FROM members_profiles2 WHERE username = '$user' AND game = '$game' AND birthday >= DATE_SUB(CURDATE(), - INTERVAL 16 YEAR);");

$online = fetch("SELECT last_visit FROM online WHERE userid = '$members[id]' ORDER BY last_visit DESC LIMIT 1");

if ($rank == "7")
{
        $iplog = fetch("SELECT ip_addr FROM ip_log WHERE userid = '$members[id]' ORDER BY id DESC LIMIT 1");
        $membersIP = " ($iplog[ip_addr])";
}
if (!$members[id])
{
        die("$openHTML<p align=center class=error>That is not a real user</p>$closeHTML");
}

if ($members[rank] <= 1)
{
        die("$openHTML<p align=center class=error>This user has been suspended.</p>$closeHTML");
}

if ($members_profiles[birthday] <= 01-01-1992)
{
        die("$openHTML<p align=center class=error>This user is under 16!</p>$closeHTML");
}

$gender = $members_profiles[gender];
$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>", "<img src=images/icons/male.gif>");
$gender = $genderArray[$gender];

$mailSettings = $members_profiles[mail_settings];
$mailSettingsArray = array(
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"");
$mailSettings = $mailSettingsArray[$mailSettings];

$bud = "<a href=buds.php?game=$game&bud=$members[username]><img src=images/icons/bud.gif></a>";

$date_registered = date("M j, Y", $members_profiles[date_registered]);
$last_visited = date("H:i", $online[last_visit]);
$last_visited2 = date("M j, Y @ H:i", $online[last_visit]);

$exBday = explode("-", $members_profiles[birthday]);
$birthday = "$exBday[2]-$exBday[0]-$exBday[1]";
function birthDate($bdate){
  $btime = strtotime($bdate);
  $byear = date('Y',$btime);//birth year
  $bmonth = date('m',$btime);//birth month
  $bday = date('d',$btime);//birth day
  $nyear = date('Y');//this year
  $years = $nyear-$byear;//number of years since birth year
  if (strtotime("$nyear-$bmonth-$bday")>time()){
    $years--;//subtract one year if they haven't had a birthday yet this year
  }
  return $years;
}
$userAge = birthDate($birthday);

if ($online[last_visit] >= ($timestamp - $secondsToKeepUsersOn))
{
        $onlineNow = "<b><font color=green>Yes! <i><font size=-1>last visit at $last_visited</font></i></font></b>";
}
else
{
        $onlineNow = "<B><font color=red>No <i><font size=-1>last visit on $last_visited2</font></i></font></b></font></b>";
}

$yourNotes = fetch("SELECT bud_note FROM buds2 WHERE bud_me = '$userid' AND bud_you = '$members[id]'");
$yourNotes = $yourNotes[bud_note];
if (!$yourNotes) { $yourNotes = "<i>You do not have any notes on the player, add them to your buddy list to add notes!</i>"; }

$find_shop = fetch("SELECT shop_name,shop_size FROM usershops2 WHERE owner = '$members[id]' AND game = '$game'");
if ($find_shop[shop_name])
{
        $usershop_line = "<b>Shop:</b> <a href=$base_url/usershop.php?game=$game&user=$user>$find_shop[shop_name]</a> <font size=-1>(size $find_shop[shop_size])</font>";
}

$find_gallery = fetch("SELECT gallery_name,gallery_size FROM usergallerys WHERE owner = '$members[id]' AND game = '$game'");
if ($find_gallery[gallery_name])
{
        $gallery_line = "<br><b>Gallery:</b> <a href=$base_url/usergallery.php?game=$game&user=$user>$find_gallery[gallery_name]</a> <font size=-1>(size $find_gallery[gallery_size])</font>";
}

$locationLine = $members_profiles[location];
if (!$locationLine)
{
        $locationLine = "<i>Middle of no where!</i>";
}

$getClub = fetch("SELECT position,club FROM club_members2 WHERE user = '$members[id]' AND game = '$game'");
$getclub = fetch("SELECT id,name FROM clubs2 WHERE id = '$getClub[club]' AND game = '$game'");
if ($getclub[id])
{
        $clubrank = $getClub[position];
        if ($clubrank == 1)
        {
                $position = "Member";
        }
        if ($clubrank == 2)
        {
                $position = "Moderator";
        }
        if ($clubrank == 3)
        {
                $position = "Admin";
        }
        $club_line = "<br><b>Club:</b> $position in <a href=$base_url/club.php?game=$game&clubid=$getclub[id]>$getclub[name]</a>";
}


$findPets = mysql_query("SELECT id,name,level FROM user_pets2 WHERE owner = '$members[id]' AND adoption = '0' AND game = '$game'");
$numUserPets = mysql_num_rows($findPets);
$x = 1;
while ($getPets = mysql_fetch_array($findPets))
{
        if ($x < $numUserPets)
        {
                $petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a> (Lvl. $getPets[level]), ";
        }
        else
        {
                $petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a> (Lvl. $getPets[level])";
        }
        $x++;
}

echo <<<END
$openHTML

<table bgcolor=#ffffff width=95%>
<tr><td>
         <CENTER>
END;

echo "<img src='uploads/$members_profiles[avatar_selected]' width=40 height=40> ";

echo <<<END
<FONT SIZE="+2"><B>$members[display_name]'s Profile</B></FONT></CENTER>

         <p>$members_profiles[profile]</p>

         <center><hr width=75% color="$tableOutline"></center>

         <font size=-1>

         <P><b>Username:</b> $members[display_name]$membersIP<br>
                        <b>Real name:</b> $members_profiles[real_name]<bR>
                        <b>Birthday:</b> $birthday ($userAge years old!)<br>
                        <b>Location:</b> $locationLine<br>
                        <b>Date Registered:</b> $date_registered<br>
                        <b>Total Referrals:</b> $members_profiles[referrals]<br>
            <b>Total Posts:</b> $members[post_count]
         </P>

         <P><b>Your Notes:</b> $yourNotes</P>

         <P><b>$numUserPets Pets:</b> $petList</p>

         <P>$usershop_line<br>
         $club_line
         $gallery_line</p>

         <p><b>Online?</b> $onlineNow</P>

                 </font>

<center><table><tr><td>
<form action=mail_send.php?game=$game&send_to=$members[username] method=post>
<input type=submit value="Send Mail">
</form></td><td>
<form action=buds.php?game=$game&bud=$members[username] method=post>
<input type=submit value="Add to Buddy List">
</form></td></tr></table></center>
</td></tr></table>

$closeHTML
END;

?>

 

OK, this is the code - however I have cliked on under 16's profiles, however they still show...

Link to comment
Share on other sites

yes I get an error query - Error

 

SQL query: Documentation

 

SELECT *

FROM members_profiles2

WHERE username = '$user'

AND game = '$game'

AND birthday >= DATE_SUB( CURDATE( ) , - INTERVAL 16 YEAR )

LIMIT 0 , 30

 

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '- INTERVAL 16 YEAR)

LIMIT 0, 30' at line 1

Link to comment
Share on other sites

  • 2 weeks later...

Thanks guys, I figured out it was this code I had to do...

if ($userAge < ('16')
{
        die("$openHTML<p align=center class=error>This user is under 16 years old.</p>$closeHTML");
}

 

However I would like to make the code more advanced, since an "adult" is a differant age in differant countrys...

 

so now, what I would like to do is for an english users profile would not be viewable to anyone, if the users profile is in the UK and they are under 16, like the above code.

 

however for US since the COPPA rules allow 13 year olds, so for US users would be 13 year old Users would be viewable...

 

I do hope you guys understand what I mean, and if you could help me please. thanks in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.