mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-04 21:44:57 +02:00
Some code cleanup and various updates + moved certain functions here
git-svn-id: file:///svn/phpbb/trunk@230 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
a7493e7455
commit
8b068f0428
@ -13,8 +13,8 @@
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modified
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
@ -34,12 +34,176 @@ init_userprefs($userdata);
|
||||
// End session management
|
||||
//
|
||||
|
||||
//
|
||||
// Page specific functions
|
||||
//
|
||||
function validate_username($username)
|
||||
{
|
||||
|
||||
global $db;
|
||||
|
||||
$sql = "SELECT LOWER(u.username), d.disallow_username
|
||||
FROM ".USERS_TABLE." u, ".DISALLOW_TABLE." d
|
||||
WHERE u.username = '".strtolower($username)."'
|
||||
OR d.disallow_username = '$username'";
|
||||
if($result = $db->sql_query($sql))
|
||||
{
|
||||
if($db->sql_numrows($result) > 0)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
function language_select($default, $dirname="language/")
|
||||
{
|
||||
global $phpEx;
|
||||
$dir = opendir($dirname);
|
||||
$lang_select = "<select name=\"language\">\n";
|
||||
while ($file = readdir($dir))
|
||||
{
|
||||
if (ereg("^lang_", $file))
|
||||
{
|
||||
$filename = str_replace("lang_", "", $file);
|
||||
$filename = str_replace(".$phpEx", "", $filename);
|
||||
$displayname = preg_replace("/(.*)_(.*)/", "\\1 [ \\2 ]", $filename);
|
||||
$selected = (strtolower($default) == strtolower($filename)) ? " selected" : "";
|
||||
$lang_select .= " <option value=\"$filename\"$selected>".ucwords($displayname)."</option>\n";
|
||||
}
|
||||
}
|
||||
$lang_select .= "</select>\n";
|
||||
closedir($dir);
|
||||
return $lang_select;
|
||||
}
|
||||
// NOTE: This function should check is_dir($file), however the is_dir function seems to be buggy on my
|
||||
// system so its not currently implemented that way
|
||||
// - James
|
||||
function template_select($default)
|
||||
{
|
||||
$dir = opendir("templates");
|
||||
$template_select = "<select name=\"template\">\n";
|
||||
while($file = readdir($dir))
|
||||
{
|
||||
unset($selected);
|
||||
|
||||
if($file != "." && $file != ".." && $file != "CVS")
|
||||
{
|
||||
if($file == $default)
|
||||
{
|
||||
$selected = " SELECTED";
|
||||
}
|
||||
$template_select .= "<option value=\"$file\"$selected>$file</option>\n";
|
||||
}
|
||||
}
|
||||
$template_select .= "</select>";
|
||||
closedir($dir);
|
||||
return($template_select);
|
||||
}
|
||||
function theme_select($default)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = "SELECT themes_id, themes_name
|
||||
FROM ".THEMES_TABLE."
|
||||
ORDER BY themes_name";
|
||||
if($result = $db->sql_query($sql))
|
||||
{
|
||||
$num = $db->sql_numrows($result);
|
||||
$rowset = $db->sql_fetchrowset($result);
|
||||
$theme_select = "<select name=\"theme\">\n";
|
||||
for($i = 0; $i < $num; $i++)
|
||||
{
|
||||
if(stripslashes($rowset[$i]['themes_name']) == $default || $rowset[$i]['themes_id'] == $default)
|
||||
{
|
||||
$selected = " SELECTED";
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = "";
|
||||
}
|
||||
$theme_select .= "\t<option value=\"".$rowset[$i]['themes_id']."\"$selected>".stripslashes($rowset[$i]['themes_name'])."</option>\n";
|
||||
}
|
||||
$theme_select .= "</select>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$theme_select = "<select name=\"theme\"><option value=\"-1\">Error in theme_select</option></select>";
|
||||
}
|
||||
return($theme_select);
|
||||
}
|
||||
function tz_select($default)
|
||||
{
|
||||
global $sys_timezone;
|
||||
|
||||
if(!isset($default))
|
||||
{
|
||||
$default == $sys_timezone;
|
||||
}
|
||||
$tz_select = "<select name=\"timezone\">";
|
||||
$tz_array = array(
|
||||
"-12" => "(GMT -12:00 hours) Eniwetok, Kwajalein",
|
||||
"-11" => "(GMT -11:00 hours) Midway Island, Samoa",
|
||||
"-10" => "(GMT -10:00 hours) Hawaii",
|
||||
"-9" => "(GMT -9:00 hours) Alaska",
|
||||
"-8" => "(GMT -8:00 hours) Pacific Time (US & Canada)",
|
||||
"-7" => "(GMT -7:00 hours) Mountain Time (US & Canada)",
|
||||
"-6" => "(GMT -6:00 hours) Central Time (US & Canada), Mexico City",
|
||||
"-5" => "(GMT -5:00 hours) Eastern Time (US & Canada), Bogota, Lima, Quito",
|
||||
"-4" => "(GMT -4:00 hours) Atlantic Time (Canada), Caracas, La Paz",
|
||||
"-3.5" => "(GMT -3:30 hours) Newfoundland",
|
||||
"-3" => "(GMT -3:00 hours) Brazil, Buenos Aires, Georgetown",
|
||||
"-2" => "(GMT -2:00 hours) Mid-Atlantic, Ascension Is., St. Helena, ",
|
||||
"-1" => "(GMT -1:00 hours) Azores, Cape Verde Islands",
|
||||
"0" => "(GMT) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia",
|
||||
"+1" => "(GMT +1:00 hours) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome",
|
||||
"+2" => "(GMT +2:00 hours) Kaliningrad, South Africa, Warsaw",
|
||||
"+3" => "(GMT +3:00 hours) Baghdad, Riyadh, Moscow, Nairobi",
|
||||
"+3.5" => "(GMT +3:30 hours) Tehran",
|
||||
"+4" => "(GMT +4:00 hours) Abu Dhabi, Baku, Muscat, Tbilisi",
|
||||
"+4.5" => "(GMT +4:30 hours) Kabul",
|
||||
"+5" => "(GMT +5:00 hours) Ekaterinburg, Islamabad, Karachi, Tashkent",
|
||||
"+5.5" => "(GMT +5:30 hours) Bombay, Calcutta, Madras, New Delhi",
|
||||
"+6" => "(GMT +6:00 hours) Almaty, Colombo, Dhaka",
|
||||
"+7" => "(GMT +7:00 hours) Bangkok, Hanoi, Jakarta",
|
||||
"+8" => "(GMT +8:00 hours) Beijing, Chongqing, Hong Kong, Perth, Singapore, Taipei",
|
||||
"+9" => "(GMT +9:00 hours) Tokyo, Seoul, Osaka, Sapporo, Yakutsk",
|
||||
"+9.5" => "(GMT +9:30 hours) Adelaide, Darwin",
|
||||
"+10" => "(GMT +10:00 hours) Guam, Melbourne, Papua New Guinea, Sydney, Vladivostok",
|
||||
"+11" => "(GMT +11:00 hours) Magadan, Solomon Islands, New Caledonia",
|
||||
"+12" => "(GMT +12:00 hours) Auckland, Wellington, Fiji, Kamchatka, Marshall Island");
|
||||
|
||||
while(list($offset, $zone) = each($tz_array))
|
||||
{
|
||||
if($offset == $default)
|
||||
{
|
||||
$selected = " SELECTED";
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = "";
|
||||
}
|
||||
$tz_select .= "\t<option value=\"$offset\"$selected>$zone</option>\n";
|
||||
}
|
||||
$tz_select .= "</select>\n";
|
||||
|
||||
return($tz_select);
|
||||
}
|
||||
//
|
||||
// End of functions defns
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Begin page proper
|
||||
//
|
||||
switch($mode)
|
||||
{
|
||||
case 'viewprofile':
|
||||
$pagetype = "profile";
|
||||
$page_title = "$l_profile";
|
||||
include('includes/page_header.'.$phpEx);
|
||||
|
||||
if(!$HTTP_GET_VARS[POST_USERS_URL])
|
||||
{
|
||||
if(DEBUG)
|
||||
@ -53,17 +217,20 @@ switch($mode)
|
||||
}
|
||||
$profiledata = get_userdata_from_id($HTTP_GET_VARS[POST_USERS_URL]);
|
||||
|
||||
//
|
||||
// Calculate the number of days this user has been a member ($memberdays)
|
||||
// Then calculate their posts per day
|
||||
//
|
||||
$regdate = $profiledata['user_regdate'];
|
||||
$memberdays = (time() - $regdate) / (24*60*60);
|
||||
$posts_per_day = $profiledata['user_posts'] / $memberdays;
|
||||
|
||||
$memberdays = (time() - $regdate) / (24*60*60);
|
||||
$posts_per_day = sprintf("%.2f", $profiledata['user_posts'] / $memberdays);
|
||||
|
||||
// Get the users percentage of total posts
|
||||
if($profiledata['user_posts'] != 0)
|
||||
{
|
||||
$total_posts = get_db_stat("postcount", $db);
|
||||
$percentage = ($profiledata['user_posts'] / $total_posts) * 100;
|
||||
$total_posts = get_db_stat("postcount");
|
||||
$percentage = sprintf("%.2f", ($profiledata['user_posts'] / $total_posts) * 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,43 +247,44 @@ switch($mode)
|
||||
{
|
||||
$email = $l_hidden;
|
||||
}
|
||||
$template->assign_vars(array("L_VIEWINGPROFILE" => $l_viewingprofile,
|
||||
"USERNAME" => stripslashes($profiledata['username']),
|
||||
"L_USERNAME" => $l_username,
|
||||
"L_VIEWPOSTUSER" => $l_viewpostuser,
|
||||
"L_JOINED" => $l_joined,
|
||||
"JOINED" => create_date($date_format, $profiledata['user_regdate'], $sys_timezone),
|
||||
"POSTS_PER_DAY" => $posts_per_day,
|
||||
"L_PERDAY" => $l_perday,
|
||||
"POSTS" => $profiledata['user_posts'],
|
||||
"PERCENTAGE" => $percentage . "%",
|
||||
"L_OFTOTAL" => $l_oftotal,
|
||||
"L_EMAILADDRESS" => $l_emailaddress,
|
||||
"EMAIL" => $email,
|
||||
"L_ICQNUMBER" => $l_icqnumber,
|
||||
"ICQ" => $profiledata['user_icq'],
|
||||
"L_AIM" => $l_aim,
|
||||
"AIM" => $profiledata['user_aim'],
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"MSN" => $profiledata['user_msnm'],
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"YIM" => $profiledata['user_yim'],
|
||||
"L_WEBSITE" => $l_website,
|
||||
"WEBSITE" => "<a href=\"".$profiledata['user_website']."\" target=\"_blank\">".$profiledata['user_website']."</a>",
|
||||
"L_FROM" => $l_from,
|
||||
"FROM" => stripslashes($profiledata['user_from']),
|
||||
"L_OCC" => $l_occupation,
|
||||
"OCC" => stripslashes($profiledata['user_occ']),
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"INTERESTS" => stripslashes($profiledata['user_intrest'])));
|
||||
$template->assign_vars(array(
|
||||
"L_VIEWING_PROFILE" => $l_viewing_profile,
|
||||
"USERNAME" => stripslashes($profiledata['username']),
|
||||
"L_USERNAME" => $l_username,
|
||||
"L_VIEW_USERS_POSTS" => $l_view_users_posts,
|
||||
"L_JOINED" => $l_joined,
|
||||
"JOINED" => create_date($date_format, $profiledata['user_regdate'], $sys_timezone),
|
||||
"POSTS_PER_DAY" => $posts_per_day,
|
||||
"L_PER_DAY" => $l_per_day,
|
||||
"POSTS" => $profiledata['user_posts'],
|
||||
"PERCENTAGE" => $percentage . "%",
|
||||
"L_OF_TOTAL" => $l_of_total,
|
||||
"L_EMAIL_ADDRESS" => $l_emailaddress,
|
||||
"EMAIL" => $email,
|
||||
"L_ICQ_NUMBER" => $l_icq_number,
|
||||
"ICQ" => $profiledata['user_icq'],
|
||||
"L_AIM" => $l_aim,
|
||||
"AIM" => $profiledata['user_aim'],
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"MSN" => $profiledata['user_msnm'],
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"YIM" => $profiledata['user_yim'],
|
||||
"L_WEBSITE" => $l_website,
|
||||
"WEBSITE" => "<a href=\"".$profiledata['user_website']."\" target=\"_blank\">".$profiledata['user_website']."</a>",
|
||||
"L_LOCATION" => $l_from,
|
||||
"LOCATION" => stripslashes($profiledata['user_from']),
|
||||
"L_OCCUPATION" => $l_occupation,
|
||||
"OCCUPATION" => stripslashes($profiledata['user_occ']),
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"INTERESTS" => stripslashes($profiledata['user_interests'])
|
||||
));
|
||||
|
||||
$template->pparse("body");
|
||||
|
||||
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
break;
|
||||
|
||||
break;
|
||||
case 'editprofile':
|
||||
|
||||
if(!$userdata['session_logged_in'])
|
||||
{
|
||||
header("Location: login.$phpEx?forward_page=$PHP_SELF&mode=editprofile");
|
||||
@ -126,71 +294,110 @@ switch($mode)
|
||||
include('includes/page_header.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array("body" => "profile_add_body.tpl"));
|
||||
$template->assign_vars(array("COPPA" => 0,
|
||||
"L_SUBMIT" => $l_submit,
|
||||
"USERNAME" => $userdata['username'],
|
||||
"EMAIL" => $userdata['user_email'],
|
||||
"YIM" => $userdata['user_yim'],
|
||||
"ICQ" => $userdata['user_icq'],
|
||||
"MSN" => $userdata['user_msnm'],
|
||||
"AIM" => $userdata['user_aim'],
|
||||
"OCC" => $userdata['user_occ'],
|
||||
"SIG" => $userdata['user_sig'],
|
||||
"INTERESTS" => $userdata['user_interests'],
|
||||
"FROM" => $userdata['user_from'],
|
||||
"WEBSITE" => $userdata['user_website'],
|
||||
"VIEWEMAIL_YES" => ($userdata['user_viewemail']) ? "CHECKED" : "",
|
||||
"VIEWEMAIL_NO" => (!$userdata['user_viewemail']) ? "CHECKED" : "",
|
||||
"STOREUSERNAME_YES" => "CHECKED",
|
||||
"STOREUSERNAME_NO" => "",
|
||||
"ALWAYSSIG_YES" => ($userdata['user_attachsig']) ? "CHECKED" : "",
|
||||
"ALWAYSSIG_NO" => (!$userdata['user_attachsig']) ? "CHECKED" : "",
|
||||
"ALWAYSBBCODE_YES" => ($userdata['user_bbcode']) ? "CHECKED" : "",
|
||||
"ALWAYSBBCODE_NO" => (!$userdata['user_bbcode']) ? "CHECKED" : "",
|
||||
"ALWAYSHTML_YES" => ($userdata['user_html']) ? "CHECKED" : "",
|
||||
"ALWAYSHTML_NO" => (!$userdata['user_html']) ? "CHECKED" : "",
|
||||
"ALWAYSSMILE_YES" => ($userdata['user_desmile']) ? "CHECKED" : "",
|
||||
"ALWAYSSMILE_NO" => (!$userdata['user_desmile']) ? "CHECKED" : "",
|
||||
"LANGUAGE_SELECT" => language_select($default_lang, "lang"),
|
||||
"THEME_SELECT" => theme_select($theme['theme_id'], $db),
|
||||
"TIMEZONE_SELECT" => tz_select($userdata['user_timezone']),
|
||||
"TEMPLATE_SELECT" => template_select($selected_template),
|
||||
"L_ICQNUMBER" => $l_icqnumber,
|
||||
"L_STORECOOKIE" => $l_storecookie,
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"L_WEBSITE" => $l_website,
|
||||
"L_AIM" => $l_aim,
|
||||
"L_FROM" => $l_from,
|
||||
"L_OCC" => $l_occupation,
|
||||
"L_ALWAYSSMILE" => $l_alwayssmile,
|
||||
"L_BOARDLANG" => $l_boardlang,
|
||||
"L_BOARDTHEME" => $l_boardtheme,
|
||||
"L_BOARDTEMPLATE" => $l_boardtemplate,
|
||||
"L_TIMEZONE" => $l_timezone,
|
||||
"L_YES" => $l_yes,
|
||||
"L_NO" => $l_no,
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"L_USERUNIQ" => $l_useruniq,
|
||||
"L_ALWAYSBBCODE" => $l_alwaysbbcode,
|
||||
"L_ALWAYSHTML" => $l_alwayshtml,
|
||||
"L_ALWAYSSIG" => $l_alwayssig,
|
||||
"L_SIGNATURE" => $l_signature,
|
||||
"L_SIGEXPLAIN" => $l_sigexplain,
|
||||
"L_PREFERENCES" => $l_preferences,
|
||||
"L_PUBLICMAIL" => $l_publicmail,
|
||||
"L_ITEMSREQ" => $l_itemsreq,
|
||||
"MODE" => $mode,
|
||||
"L_REGINFO" => $l_reginfo,
|
||||
"L_PROFILEINFO" => $l_profileinfo,
|
||||
"L_CONFIRM" => $l_confirm,
|
||||
"L_EMAILADDRESS" => $l_emailaddress));
|
||||
$template->pparse("body");
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
|
||||
break;
|
||||
$template->assign_vars(array(
|
||||
"COPPA" => 0,
|
||||
"MODE" => $mode,
|
||||
"USERNAME" => $userdata['username'],
|
||||
"EMAIL" => $userdata['user_email'],
|
||||
"YIM" => $userdata['user_yim'],
|
||||
"ICQ" => $userdata['user_icq'],
|
||||
"MSN" => $userdata['user_msnm'],
|
||||
"AIM" => $userdata['user_aim'],
|
||||
"OCCUPATION" => $userdata['user_occ'],
|
||||
"SIGNATURE" => $userdata['user_sig'],
|
||||
"INTERESTS" => $userdata['user_interests'],
|
||||
"LOCATION" => $userdata['user_from'],
|
||||
"WEBSITE" => $userdata['user_website'],
|
||||
"VIEW_EMAIL_YES" => ($userdata['user_viewemail']) ? "CHECKED" : "",
|
||||
"VIEW_EMAIL_NO" => (!$userdata['user_viewemail']) ? "CHECKED" : "",
|
||||
"ALWAYS_ADD_SIGNATURE_YES" => ($userdata['user_attachsig']) ? "CHECKED" : "",
|
||||
"ALWAYS_ADD_SIGNATURE_NO" => (!$userdata['user_attachsig']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_BBCODE_YES" => ($userdata['user_bbcode']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_BBCODE_NO" => (!$userdata['user_bbcode']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_HTML_YES" => ($userdata['user_html']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_HTML_NO" => (!$userdata['user_html']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_SMILIES_YES" => ($userdata['user_desmile']) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_SMILIES_NO" => (!$userdata['user_desmile']) ? "CHECKED" : "",
|
||||
"LANGUAGE_SELECT" => language_select($userdata['user_lang']),
|
||||
"THEME_SELECT" => theme_select($theme['theme_id']),
|
||||
"TIMEZONE_SELECT" => tz_select($userdata['user_timezone']),
|
||||
"DATE_FORMAT" => $userdata['user_dateformat'],
|
||||
"TEMPLATE_SELECT" => template_select($userdata['user_template']),
|
||||
|
||||
"L_PASSWORD_IF_CHANGED" => $l_password_if_changed,
|
||||
"L_PASSWORD_CONFIRM_IF_CHANGED" => $l_password_confirm_if_changed,
|
||||
"L_SUBMIT" => $l_submit,
|
||||
"L_ICQ_NUMBER" => $l_icq_number,
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"L_WEBSITE" => $l_website,
|
||||
"L_AIM" => $l_aim,
|
||||
"L_LOCATION" => $l_from,
|
||||
"L_OCCUPATION" => $l_occupation,
|
||||
"L_BOARD_LANGUAGE" => $l_boardlang,
|
||||
"L_BOARD_THEME" => $l_boardtheme,
|
||||
"L_BOARD_TEMPLATE" => $l_boardtemplate,
|
||||
"L_TIMEZONE" => $l_timezone,
|
||||
"L_DATE_FORMAT" => $l_date_format,
|
||||
"L_DATE_FORMAT_EXPLANATION" => $l_date_format_explanation,
|
||||
"L_YES" => $l_yes,
|
||||
"L_NO" => $l_no,
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"L_USER_UNIQUE" => $l_useruniq,
|
||||
"L_ALWAYS_ALLOW_SMILIES" => $l_alwayssmile,
|
||||
"L_ALWAYS_ALLOW_BBCODE" => $l_alwaysbbcode,
|
||||
"L_ALWAYS_ALLOW_HTML" => $l_alwayshtml,
|
||||
"L_ALWAYS_ADD_SIGNATURE" => $l_alwayssig,
|
||||
"L_SIGNATURE" => $l_signature,
|
||||
"L_SIGNATURE_EXPLAIN" => $l_sigexplain,
|
||||
"L_PREFERENCES" => $l_preferences,
|
||||
"L_PUBLIC_VIEW_EMAIL" => $l_publicmail,
|
||||
"L_ITEMS_REQUIRED" => $l_itemsreq,
|
||||
"L_REGISTRATION_INFO" => $l_reginfo,
|
||||
"L_PROFILE_INFO" => $l_profile_info,
|
||||
"L_PROFILE_INFO_NOTICE" => $l_profile_info_notice,
|
||||
"L_CONFIRM" => $l_confirm,
|
||||
"L_EMAIL_ADDRESS" => $l_emailaddress));
|
||||
|
||||
$template->pparse("body");
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
break;
|
||||
|
||||
case 'register':
|
||||
|
||||
$username = (!empty($HTTP_POST_VARS['username'])) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['username']))) : "";
|
||||
$email = (!empty($HTTP_POST_VARS['email'])) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['email']))) : "";
|
||||
$password = (!empty($HTTP_POST_VARS['password'])) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['password']))) : "";
|
||||
$password_confirm = (!empty($HTTP_POST_VARS['password_confirm'])) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['password_confirm']))) : "";
|
||||
|
||||
$icq = (!empty($HTTP_POST_VARS['icq'])) ? trim(strip_tags($HTTP_POST_VARS['icq'])) : "";
|
||||
$aim = (!empty($HTTP_POST_VARS['aim'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['aim']))) : "";
|
||||
$msn = (!empty($HTTP_POST_VARS['msn'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['msn']))) : "";
|
||||
$yim = (!empty($HTTP_POST_VARS['yim'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['yim']))) : "";
|
||||
|
||||
$website = (!empty($HTTP_POST_VARS['website'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['website']))) : "";
|
||||
$location = (!empty($HTTP_POST_VARS['location'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['location']))) : "";
|
||||
$occupation = (!empty($HTTP_POST_VARS['occupation'])) ? trim(strip_tags(addslashes($HTTP_POST_VARS['occupation']))) : "";
|
||||
$interests = (!empty($HTTP_POST_VARS['interests'])) ? trim(addslashes($HTTP_POST_VARS['interests'])) : "";
|
||||
$signature = (!empty($HTTP_POST_VARS['signature'])) ? trim(addslashes($HTTP_POST_VARS['signature'])) : "";
|
||||
|
||||
$viewemail = $HTTP_POST_VARS['viewemail'];
|
||||
$attachsig = $HTTP_POST_VARS['attachsig'];
|
||||
$allowhtml = $HTTP_POST_VARS['allowhtml'];
|
||||
$allowbbcode = $HTTP_POST_VARS['allowbbcode'];
|
||||
$allowsmilies = $HTTP_POST_VARS['allowsmilies'];
|
||||
|
||||
$user_theme = ($HTTP_POST_VARS['theme']) ? $HTTP_POST_VARS['theme'] : $default_theme;
|
||||
$user_lang = ($HTTP_POST_VARS['language']) ? $HTTP_POST_VARS['language'] : $default_lang;
|
||||
$user_timezone = (isset($HTTP_POST_VARS['timezone'])) ? $HTTP_POST_VARS['timezone'] : $sys_timezone;
|
||||
$user_template = ($HTTP_POST_VARS['template']) ? $HTTP_POST_VARS['template'] : $sys_template;
|
||||
$user_dateformat = ($HTTP_POST_VARS['dateformat']) ? trim($HTTP_POST_VARS['dateformat']) : $default_dateformat;
|
||||
|
||||
$submit = $HTTP_POST_VARS['submit'];
|
||||
|
||||
list($hr, $min, $sec, $mon, $day, $year) = explode(",", gmdate("H,i,s,m,d,Y", time()));
|
||||
$regdate = gmmktime($hr, $min, $sec, $mon, $day, $year);
|
||||
|
||||
$pagetype = "register";
|
||||
$page_title = "$l_register";
|
||||
include('includes/page_header.'.$phpEx);
|
||||
@ -210,21 +417,21 @@ switch($mode)
|
||||
$error = TRUE;
|
||||
$error_msg = $l_notfilledin;
|
||||
}
|
||||
if(isset($username) && (!validate_username($username, $db)))
|
||||
if(isset($username) && (!validate_username($username)))
|
||||
{
|
||||
$error = TRUE;
|
||||
if(isset($error_msg))
|
||||
{
|
||||
$error_msg .= "<br>";
|
||||
$error_msg .= "<br />";
|
||||
}
|
||||
$error_msg .= $l_invalidname;
|
||||
}
|
||||
if(isset($password) && ($password != $password_confirm))
|
||||
if($password != $password_confirm)
|
||||
{
|
||||
$error = TRUE;
|
||||
if(isset($error_msg))
|
||||
{
|
||||
$error_msg .= "<br>";
|
||||
$error_msg .= "<br />";
|
||||
}
|
||||
$error_msg .= $l_mismatch;
|
||||
}
|
||||
@ -232,73 +439,30 @@ switch($mode)
|
||||
|
||||
if(isset($submit) && !$error)
|
||||
{
|
||||
// The AUTO_INCREMENT field in MySQL v3.23 dosan't work correctly when there is a row with
|
||||
// -1 in that field so we have to explicitly get the next user ID.
|
||||
$sql = "SELECT max(user_id) AS total FROM ".USERS_TABLE;
|
||||
if($result = $db->sql_query($sql))
|
||||
{
|
||||
$user_id_row = $db->sql_fetchrow($result);
|
||||
$new_user_id = $user_id_row["total"] + 1;
|
||||
unset($result);
|
||||
unset($user_id_row);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_die(SQL_QUERY, "Couldn't obtained next user_id information.", __LINE__, __FILE__);
|
||||
}
|
||||
//
|
||||
// The AUTO_INCREMENT field in MySQL v3.23 doesn't work
|
||||
// correctly when there is a row with -1 in that field
|
||||
// so we have to explicitly get the next user ID.
|
||||
//
|
||||
$sql = "SELECT max(user_id) AS total
|
||||
FROM ".USERS_TABLE;
|
||||
if($result = $db->sql_query($sql))
|
||||
{
|
||||
$user_id_row = $db->sql_fetchrow($result);
|
||||
$new_user_id = $user_id_row['total'] + 1;
|
||||
unset($result);
|
||||
unset($user_id_row);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_die(SQL_QUERY, "Couldn't obtained next user_id information.", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
$md_pass = md5($password);
|
||||
$sql = "INSERT INTO ".USERS_TABLE." (
|
||||
user_id,
|
||||
username,
|
||||
user_regdate,
|
||||
user_password,
|
||||
user_email,
|
||||
user_icq,
|
||||
user_website,
|
||||
user_occ,
|
||||
user_from,
|
||||
user_interests,
|
||||
user_sig,
|
||||
user_viewemail,
|
||||
user_theme,
|
||||
user_aim,
|
||||
user_yim,
|
||||
user_msnm,
|
||||
user_attachsig,
|
||||
user_desmile,
|
||||
user_html,
|
||||
user_bbcode,
|
||||
user_timezone,
|
||||
user_lang,
|
||||
user_template,
|
||||
user_active,
|
||||
user_actkey)
|
||||
VALUES (
|
||||
$new_user_id,
|
||||
'".addslashes($username)."',
|
||||
'".gmmktime(gmdate("H, i, s, m, d, Y", time()))."',
|
||||
'$md_pass',
|
||||
'$email',
|
||||
'$icq',
|
||||
'".addslashes($website)."',
|
||||
'".addslashes($occ)."',
|
||||
'".addslashes($from)."',
|
||||
'".addslashes($interests)."',
|
||||
'".addslashes($sig)."',
|
||||
'$viewemail',
|
||||
'$theme',
|
||||
'".addslashes($aim)."',
|
||||
'".addslashes($yim)."',
|
||||
'".addslashes($msn)."',
|
||||
'$alwayssig',
|
||||
'$alwayssmile',
|
||||
'$alwayshtml',
|
||||
'$alwaysbbcode',
|
||||
'$timezone',
|
||||
'$lang',
|
||||
'$selected_template',
|
||||
";
|
||||
$sql = "INSERT INTO ".USERS_TABLE."
|
||||
(user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_desmile, user_html, user_bbcode, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_active, user_actkey)
|
||||
VALUES
|
||||
('$new_user_id', '$username', '$regdate', '$md_pass', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$viewemail', '$aim', '$yim', '$msn', '$attachsig', '$allowsmilies', '$allowhtml', '$allowbbcode', '$user_timezone', '$user_dateformat', '$user_lang', '$user_template', '$user_theme', ";
|
||||
if($require_activation || $coppa)
|
||||
{
|
||||
$act_key = generate_activation_key();
|
||||
@ -312,7 +476,7 @@ switch($mode)
|
||||
{
|
||||
if($require_activation)
|
||||
{
|
||||
$msg = $l_accountinactive;
|
||||
$msg = $l_accountinactive;
|
||||
$email_msg = $l_welcomeemailactivate;
|
||||
}
|
||||
else if($coppa)
|
||||
@ -330,8 +494,12 @@ switch($mode)
|
||||
mail($email, $l_welcomesubj, $email_msg, "From: $email_from\r\n");
|
||||
}
|
||||
|
||||
$template->set_filenames(array("reg_header" => "error_body.tpl"));
|
||||
$template->assign_vars(array("ERROR_MESSAGE" => $msg));
|
||||
$template->set_filenames(array(
|
||||
"reg_header" => "error_body.tpl"
|
||||
));
|
||||
$template->assign_vars(array(
|
||||
"ERROR_MESSAGE" => $msg
|
||||
));
|
||||
$template->pparse("reg_header");
|
||||
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
@ -349,10 +517,15 @@ switch($mode)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($error)
|
||||
{
|
||||
$template->set_filenames(array("reg_header" => "error_body.tpl"));
|
||||
$template->assign_vars(array("ERROR_MESSAGE" => $error_msg));
|
||||
$template->set_filenames(array(
|
||||
"reg_header" => "error_body.tpl"
|
||||
));
|
||||
$template->assign_vars(array(
|
||||
"ERROR_MESSAGE" => $error_msg
|
||||
));
|
||||
$template->pparse("reg_header");
|
||||
}
|
||||
if(!isset($coppa))
|
||||
@ -364,77 +537,85 @@ switch($mode)
|
||||
{
|
||||
$selected_template = $sys_template;
|
||||
}
|
||||
$template->assign_vars(array("COPPA" => $coppa,
|
||||
"L_SUBMIT" => $l_submit,
|
||||
"USERNAME" => $username,
|
||||
"EMAIL" => $email,
|
||||
"YIM" => $yim,
|
||||
"ICQ" => $icq,
|
||||
"MSN" => $msn,
|
||||
"AIM" => $aim,
|
||||
"OCC" => $occ,
|
||||
"INTERESTS" => $interests,
|
||||
"FROM" => $from,
|
||||
"WEBSITE" => $website,
|
||||
"SIG" => $sig,
|
||||
"VIEWEMAIL_YES" => ($viewemail) ? "CHECKED" : "",
|
||||
"VIEWEMAIL_NO" => (!$viewemail) ? "CHECKED" : "",
|
||||
"STOREUSERNAME_YES" => (!isset($storeusername) || $storeusername == 1) ? "CHECKED" : "",
|
||||
"STOREUSERNAME_NO" => (isset($storeusername) && $storeusername == 0) ? "CHECKED" : "",
|
||||
"ALWAYSSIG_YES" => ($alwayssig) ? "CHECKED" : "",
|
||||
"ALWAYSSIG_NO" => (!$alwayssig) ? "CHECKED" : "",
|
||||
"ALWAYSBBCODE_YES" => ($alwaysbbcode) ? "CHECKED" : "",
|
||||
"ALWAYSBBCODE_NO" => (!$alwaysbbcode) ? "CHECKED" : "",
|
||||
"ALWAYSHTML_YES" => ($alwayshtml) ? "CHECKED" : "",
|
||||
"ALWAYSHTML_NO" => (!$alwayshtml) ? "CHECKED" : "",
|
||||
"ALWAYSSMILE_YES" => ($alwayssmile) ? "CHECKED" : "",
|
||||
"ALWAYSSMILE_NO" => (!$alwayssmile) ? "CHECKED" : "",
|
||||
"LANGUAGE_SELECT" => language_select($default_lang, "lang"),
|
||||
"THEME_SELECT" => theme_select($theme, $db),
|
||||
"TIMEZONE_SELECT" => tz_select($timezone),
|
||||
"TEMPLATE_SELECT" => template_select($selected_template),
|
||||
"L_ICQNUMBER" => $l_icqnumber,
|
||||
"L_STORECOOKIE" => $l_storecookie,
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"L_WEBSITE" => $l_website,
|
||||
"L_AIM" => $l_aim,
|
||||
"L_FROM" => $l_from,
|
||||
"L_OCC" => $l_occupation,
|
||||
"L_ALWAYSSMILE" => $l_alwayssmile,
|
||||
"L_BOARDLANG" => $l_boardlang,
|
||||
"L_BOARDTHEME" => $l_boardtheme,
|
||||
"L_BOARDTEMPLATE" => $l_boardtemplate,
|
||||
"L_TIMEZONE" => $l_timezone,
|
||||
"L_YES" => $l_yes,
|
||||
"L_NO" => $l_no,
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"L_USERUNIQ" => $l_useruniq,
|
||||
"L_ALWAYSBBCODE" => $l_alwaysbbcode,
|
||||
"L_ALWAYSHTML" => $l_alwayshtml,
|
||||
"L_ALWAYSSIG" => $l_alwayssig,
|
||||
"L_SIGNATURE" => $l_signature,
|
||||
"L_SIGEXPLAIN" => $l_sigexplain,
|
||||
"L_PREFERENCES" => $l_preferences,
|
||||
"L_PUBLICMAIL" => $l_publicmail,
|
||||
"L_ITEMSREQ" => $l_itemsreq,
|
||||
"MODE" => $mode,
|
||||
"L_REGINFO" => $l_reginfo,
|
||||
"L_PROFILEINFO" => $l_profileinfo,
|
||||
"L_CONFIRM" => $l_confirm,
|
||||
"L_EMAILADDRESS" => $l_emailaddress));
|
||||
$template->assign_vars(array(
|
||||
"MODE" => $mode,
|
||||
"USERNAME" => $username,
|
||||
"EMAIL" => $email,
|
||||
"YIM" => $yim,
|
||||
"ICQ" => $icq,
|
||||
"MSN" => $msn,
|
||||
"AIM" => $aim,
|
||||
"OCCUPATION" => $occupation,
|
||||
"INTERESTS" => $interests,
|
||||
"LOCATION" => $location,
|
||||
"WEBSITE" => $website,
|
||||
"SIGNATURE" => $signature,
|
||||
"VIEW_EMAIL_YES" => ($viewemail) ? "CHECKED" : "",
|
||||
"VIEW_EMAIL_NO" => (!$viewemail) ? "CHECKED" : "",
|
||||
"ALWAYS_ADD_SIGNATURE_YES" => ($attachsig) ? "CHECKED" : "",
|
||||
"ALWAYS_ADD_SIGNATURE_NO" => (!$attachsig) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_BBCODE_YES" => ($allowbbcode) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_BBCODE_NO" => (!$allowbbcode) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_HTML_YES" => ($allowhtml) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_HTML_NO" => (!$allowhtml) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_SMILIES_YES" => ($allowsmilies) ? "CHECKED" : "",
|
||||
"ALWAYS_ALLOW_SMILIES_NO" => (!$allowsmilies) ? "CHECKED" : "",
|
||||
"LANGUAGE_SELECT" => language_select($user_lang),
|
||||
"THEME_SELECT" => theme_select($user_theme),
|
||||
"TIMEZONE_SELECT" => tz_select($user_timezone),
|
||||
"DATE_FORMAT" => $user_dateformat,
|
||||
"TEMPLATE_SELECT" => template_select($user_template),
|
||||
|
||||
"L_SUBMIT" => $l_submit,
|
||||
"L_ICQ_NUMBER" => $l_icq_number,
|
||||
"L_MESSENGER" => $l_messenger,
|
||||
"L_YAHOO" => $l_yahoo,
|
||||
"L_WEBSITE" => $l_website,
|
||||
"L_AIM" => $l_aim,
|
||||
"L_LOCATION" => $l_from,
|
||||
"L_OCCUPATION" => $l_occupation,
|
||||
"L_BOARD_LANGUAGE" => $l_boardlang,
|
||||
"L_BOARD_THEME" => $l_boardtheme,
|
||||
"L_BOARD_TEMPLATE" => $l_boardtemplate,
|
||||
"L_TIMEZONE" => $l_timezone,
|
||||
"L_DATE_FORMAT" => $l_date_format,
|
||||
"L_DATE_FORMAT_EXPLANATION" => $l_date_format_explanation,
|
||||
"L_YES" => $l_yes,
|
||||
"L_NO" => $l_no,
|
||||
"L_INTERESTS" => $l_interests,
|
||||
"L_USER_UNIQUE" => $l_useruniq,
|
||||
"L_ALWAYS_ALLOW_SMILIES" => $l_alwayssmile,
|
||||
"L_ALWAYS_ALLOW_BBCODE" => $l_alwaysbbcode,
|
||||
"L_ALWAYS_ALLOW_HTML" => $l_alwayshtml,
|
||||
"L_ALWAYS_ADD_SIGNATURE" => $l_alwayssig,
|
||||
"L_SIGNATURE" => $l_signature,
|
||||
"L_SIGNATURE_EXPLAIN" => $l_sigexplain,
|
||||
"L_PREFERENCES" => $l_preferences,
|
||||
"L_PUBLIC_VIEW_EMAIL" => $l_publicmail,
|
||||
"L_ITEMS_REQUIRED" => $l_itemsreq,
|
||||
"L_REGISTRATION_INFO" => $l_reginfo,
|
||||
"L_PROFILE_INFO" => $l_profile_info,
|
||||
"L_PROFILE_INFO_NOTICE" => $l_profile_info_notice,
|
||||
"L_CONFIRM" => $l_confirm,
|
||||
"L_EMAIL_ADDRESS" => $l_emailaddress));
|
||||
|
||||
$template->pparse("body");
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'activate':
|
||||
$sql = "SELECT user_id FROM ".USERS_TABLE." WHERE user_actkey = '$act_key'";
|
||||
$sql = "SELECT user_id
|
||||
FROM ".USERS_TABLE."
|
||||
WHERE user_actkey = '$act_key'";
|
||||
if($result = $db->sql_query($sql))
|
||||
{
|
||||
if($num = $db->sql_numrows($result))
|
||||
{
|
||||
$rowset = $db->sql_fetchrowset($result);
|
||||
$sql_update = "UPDATE ".USERS_TABLE." SET user_active = 1, user_actkey = '' WHERE user_id = ".$rowset[0]["user_id"];
|
||||
$sql_update = "UPDATE ".USERS_TABLE."
|
||||
SET user_active = 1, user_actkey = ''
|
||||
WHERE user_id = ".$rowset[0]['user_id'];
|
||||
if($result = $db->sql_query($sql_update))
|
||||
{
|
||||
error_die(GENERAL_ERROR, $l_nowactive);
|
||||
|
Loading…
x
Reference in New Issue
Block a user