mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Fix COPPA problems
git-svn-id: file:///svn/phpbb/trunk@2209 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
19f7c091d9
commit
582cee4b07
1 changed files with 36 additions and 75 deletions
|
@ -101,30 +101,22 @@ function validate_email($email)
|
||||||
//
|
//
|
||||||
function validate_optional_fields(&$icq, &$aim, &$msnm, &$yim, &$website, &$location, &$occupation, &$interests, &$sig)
|
function validate_optional_fields(&$icq, &$aim, &$msnm, &$yim, &$website, &$location, &$occupation, &$interests, &$sig)
|
||||||
{
|
{
|
||||||
|
$check_var_length = array('aim', 'msnm', 'yim', 'location', 'occupation', 'interests', 'sig');
|
||||||
|
|
||||||
|
for($i = 0; $i < count($check_var_length); $i++)
|
||||||
|
{
|
||||||
|
if ( strlen($$check_var_length[$i]) < 2 )
|
||||||
|
{
|
||||||
|
$$check_var_length[$i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ICQ number has to be only numbers.
|
// ICQ number has to be only numbers.
|
||||||
if ( !preg_match("/^[0-9]+$/", $icq) )
|
if ( !preg_match("/^[0-9]+$/", $icq) )
|
||||||
{
|
{
|
||||||
$icq = "";
|
$icq = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// AIM address has to have length >= 2.
|
|
||||||
if (strlen($aim) < 2)
|
|
||||||
{
|
|
||||||
$aim = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// MSNM address has to have length >= 2.
|
|
||||||
if (strlen($msnm) < 2)
|
|
||||||
{
|
|
||||||
$msnm = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// YIM address has to have length >= 2.
|
|
||||||
if (strlen($yim) < 2)
|
|
||||||
{
|
|
||||||
$yim = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// website has to start with http://, followed by something with length at least 3 that
|
// website has to start with http://, followed by something with length at least 3 that
|
||||||
// contains at least one dot.
|
// contains at least one dot.
|
||||||
if ( $website != "" )
|
if ( $website != "" )
|
||||||
|
@ -140,34 +132,10 @@ function validate_optional_fields(&$icq, &$aim, &$msnm, &$yim, &$website, &$loca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// location has to have length >= 2.
|
|
||||||
if (strlen($location) < 2)
|
|
||||||
{
|
|
||||||
$location = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// occupation has to have length >= 2.
|
|
||||||
if (strlen($occupation) < 2)
|
|
||||||
{
|
|
||||||
$occupation = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// interests has to have length >= 2.
|
|
||||||
if (strlen($interests) < 2)
|
|
||||||
{
|
|
||||||
$interests = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// sig has to have length >= 2.
|
|
||||||
if (strlen($sig) < 2)
|
|
||||||
{
|
|
||||||
$sig = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_password()
|
function gen_rand_string($hash)
|
||||||
{
|
{
|
||||||
$chars = array(
|
$chars = array(
|
||||||
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J", "k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8",
|
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J", "k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8",
|
||||||
|
@ -176,12 +144,13 @@ function generate_password()
|
||||||
$max_chars = count($chars) - 1;
|
$max_chars = count($chars) - 1;
|
||||||
srand((double)microtime()*1000000);
|
srand((double)microtime()*1000000);
|
||||||
|
|
||||||
|
$rand_str = "";
|
||||||
for($i = 0; $i < 8; $i++)
|
for($i = 0; $i < 8; $i++)
|
||||||
{
|
{
|
||||||
$new_passwd = ($i == 0) ? $chars[rand(0, $max_chars)] : $new_passwd . $chars[rand(0, $max_chars)];
|
$rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return($new_passwd);
|
return ( $hash ) ? md5($rand_str) : $rand_str;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// End page specific functions
|
// End page specific functions
|
||||||
|
@ -194,9 +163,7 @@ function generate_password()
|
||||||
if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
{
|
{
|
||||||
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
|
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
|
||||||
//
|
|
||||||
// Begin page proper
|
|
||||||
//
|
|
||||||
if ( $mode == "viewprofile" )
|
if ( $mode == "viewprofile" )
|
||||||
{
|
{
|
||||||
if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
|
if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
|
||||||
|
@ -217,8 +184,7 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Output page header and
|
// Output page header and profile_view template
|
||||||
// profile_view template
|
|
||||||
//
|
//
|
||||||
$template->set_filenames(array(
|
$template->set_filenames(array(
|
||||||
"body" => "profile_view_body.tpl",
|
"body" => "profile_view_body.tpl",
|
||||||
|
@ -235,16 +201,12 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
"S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx"))
|
"S_JUMPBOX_ACTION" => append_sid("viewforum.$phpEx"))
|
||||||
);
|
);
|
||||||
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
||||||
//
|
|
||||||
// End header
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate the number of days this user has been a member ($memberdays)
|
// Calculate the number of days this user has been a member ($memberdays)
|
||||||
// Then calculate their posts per day
|
// Then calculate their posts per day
|
||||||
//
|
//
|
||||||
$regdate = $profiledata['user_regdate'];
|
$regdate = $profiledata['user_regdate'];
|
||||||
|
|
||||||
$memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
|
$memberdays = max(1, round( ( time() - $regdate ) / 86400 ));
|
||||||
$posts_per_day = $profiledata['user_posts'] / $memberdays;
|
$posts_per_day = $profiledata['user_posts'] / $memberdays;
|
||||||
|
|
||||||
|
@ -1026,14 +988,13 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
if( $email != $current_email && ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) && $userdata['user_level'] != ADMIN )
|
if( $email != $current_email && ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) && $userdata['user_level'] != ADMIN )
|
||||||
{
|
{
|
||||||
$user_active = 0;
|
$user_active = 0;
|
||||||
$user_actkey = generate_activation_key();
|
$user_actkey = gen_rand_string(true);
|
||||||
|
|
||||||
//
|
//
|
||||||
// The user is inactive, remove their session forcing them to login again before they can post.
|
// The user is inactive, remove their session forcing them to login again before they can post.
|
||||||
//
|
//
|
||||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||||
WHERE session_user_id = " . $userdata['user_id'];
|
WHERE session_user_id = " . $userdata['user_id'];
|
||||||
|
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1078,7 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
|
|
||||||
if ( $board_config['require_activation'] ==USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa == 1)
|
if ( $board_config['require_activation'] ==USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa == 1)
|
||||||
{
|
{
|
||||||
$user_actkey = generate_activation_key();
|
$user_actkey = gen_rand_string(true);
|
||||||
$sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
|
$sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1135,7 +1096,12 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
VALUES ($new_user_id, $new_group_id, 0)";
|
VALUES ($new_user_id, $new_group_id, 0)";
|
||||||
if ( $result = $db->sql_query($sql, END_TRANSACTION) )
|
if ( $result = $db->sql_query($sql, END_TRANSACTION) )
|
||||||
{
|
{
|
||||||
if( $board_config['require_activation'] == USER_ACTIVATION_SELF )
|
if ( $coppa )
|
||||||
|
{
|
||||||
|
$message = $lang['COPPA'];
|
||||||
|
$email_template = "coppa_welcome_inactive";
|
||||||
|
}
|
||||||
|
else if ( $board_config['require_activation'] == USER_ACTIVATION_SELF )
|
||||||
{
|
{
|
||||||
$message = $lang['Account_inactive'];
|
$message = $lang['Account_inactive'];
|
||||||
$email_template = "user_welcome_inactive";
|
$email_template = "user_welcome_inactive";
|
||||||
|
@ -1145,11 +1111,6 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
$message = $lang['Account_inactive_admin'];
|
$message = $lang['Account_inactive_admin'];
|
||||||
$email_template = "admin_welcome_inactive";
|
$email_template = "admin_welcome_inactive";
|
||||||
}
|
}
|
||||||
else if( $coppa )
|
|
||||||
{
|
|
||||||
$message = $lang['COPPA'];
|
|
||||||
$email_template = "coppa_welcome_inactive";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$message = $lang['Account_added'];
|
$message = $lang['Account_added'];
|
||||||
|
@ -1703,8 +1664,8 @@ if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
||||||
|
|
||||||
$username = $row['username'];
|
$username = $row['username'];
|
||||||
|
|
||||||
$user_actkey = generate_activation_key();
|
$user_actkey = gen_rand_string(true);
|
||||||
$user_password = generate_password();
|
$user_password = gen_rand_string(false);
|
||||||
|
|
||||||
$sql = "UPDATE " . USERS_TABLE . "
|
$sql = "UPDATE " . USERS_TABLE . "
|
||||||
SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey'
|
SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey'
|
||||||
|
|
Loading…
Add table
Reference in a new issue