mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Majority are UCP related updates ... avatars should now work, aside from gallery, fixed a few other issues, updated schema/basic
git-svn-id: file:///svn/phpbb/trunk@4062 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -883,6 +883,10 @@ function phpbb_unlink($filename, $mode = 'file', $use_ftp = false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// posting.php specific
|
||||
//
|
||||
@@ -968,8 +972,8 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
$post_sql = array_merge($post_sql, array(
|
||||
'post_checksum' => $post_data['message_md5'],
|
||||
'post_text' => $message,
|
||||
'post_encoding' => $user->lang['ENCODING']
|
||||
));
|
||||
'post_encoding' => $user->lang['ENCODING'])
|
||||
);
|
||||
}
|
||||
|
||||
if ($mode == 'edit')
|
||||
@@ -995,9 +999,9 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
|
||||
if ($poll['poll_start'] && $mode == 'edit')
|
||||
{
|
||||
$sql = "SELECT * FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE topic_id = " . $post_data['topic_id'] . "
|
||||
ORDER BY poll_option_id";
|
||||
$sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . '
|
||||
WHERE topic_id = ' . $post_data['topic_id'] . '
|
||||
ORDER BY poll_option_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($cur_poll_options[] = $db->sql_fetchrow($result));
|
||||
@@ -1010,15 +1014,16 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
{
|
||||
if (empty($cur_poll_options[$i]))
|
||||
{
|
||||
$sql = "INSERT INTO " . POLL_OPTIONS_TABLE . " (poll_option_id, topic_id, poll_option_text)
|
||||
VALUES (" . $i . ", " . $post_data['topic_id'] . ", '" . $db->sql_escape($poll['poll_options'][$i]) . "')";
|
||||
$sql = 'INSERT INTO ' . POLL_OPTIONS_TABLE . " (poll_option_id, topic_id, poll_option_text)
|
||||
VALUES ($i, " . $post_data['topic_id'] . ", '" . $db->sql_escape($poll['poll_options'][$i]) . "')";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
else if ($poll['poll_options'][$i] != $cur_poll_options[$i])
|
||||
{
|
||||
$sql = "UPDATE " . POLL_OPTIONS_TABLE . "
|
||||
SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "'
|
||||
WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'];
|
||||
WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . "
|
||||
AND topic_id = $topic_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -1026,9 +1031,9 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
|
||||
if (sizeof($poll['poll_options']) < sizeof($cur_poll_options))
|
||||
{
|
||||
$sql = "DELETE FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE poll_option_id > " . sizeof($poll['poll_options']) . "
|
||||
AND topic_id = " . $post_data['topic_id'];
|
||||
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '
|
||||
WHERE poll_option_id > ' . sizeof($poll['poll_options']) . '
|
||||
AND topic_id = ' . $post_data['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -1248,6 +1253,10 @@ function user_notification($mode, $subject, $forum_id, $topic_id, $post_id)
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO : Paul
|
||||
// Now grab group settings ... users can belong to multiple groups so we grab
|
||||
// the minimum setting for all options. ACL_NO overrides ACL_YES so act appropriatley
|
||||
$sql = "SELECT ug.user_id, MIN(a.auth_setting) as min_setting
|
||||
@@ -1272,6 +1281,10 @@ function user_notification($mode, $subject, $forum_id, $topic_id, $post_id)
|
||||
$allowed_users = array_unique($allowed_users);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
if ($topic_notification)
|
||||
{
|
||||
|
@@ -260,8 +260,8 @@ class ucp extends user
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT group_name
|
||||
FROM " . GROUPS_TABLE . "
|
||||
$sql = 'SELECT group_name
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE LOWER(group_name) = '" . strtolower($db->sql_escape($username)) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -271,8 +271,8 @@ class ucp extends user
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT disallow_username
|
||||
FROM " . DISALLOW_TABLE;
|
||||
$sql = 'SELECT disallow_username
|
||||
FROM ' . DISALLOW_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@@ -284,8 +284,8 @@ class ucp extends user
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT word
|
||||
FROM " . WORDS_TABLE;
|
||||
$sql = 'SELECT word
|
||||
FROM ' . WORDS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@@ -303,27 +303,27 @@ class ucp extends user
|
||||
// Check to see if email address is banned or already present in the DB
|
||||
function validate_email($email)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
if ($email != '')
|
||||
global $config, $db, $user;
|
||||
|
||||
if (preg_match('#^[a-z0-9\.\-_\+]+?@(.*?\.)*?[a-z0-9\-_]+?\.[a-z]{2,4}$#i', $email))
|
||||
{
|
||||
if (preg_match('#^[a-z0-9\.\-_\+]+@(.*?\.)*?[a-z0-9\-_]+\.[a-z]+$#is', $email))
|
||||
$sql = 'SELECT ban_email
|
||||
FROM ' . BANLIST_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = "SELECT ban_email
|
||||
FROM " . BANLIST_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
if (preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $email))
|
||||
{
|
||||
if (preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#is', $email))
|
||||
{
|
||||
return 'EMAIL_BANNED';
|
||||
}
|
||||
return 'EMAIL_BANNED';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT user_email
|
||||
FROM " . USERS_TABLE . "
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$config['allow_emailreuse'])
|
||||
{
|
||||
$sql = 'SELECT user_email
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_email = '" . $db->sql_escape($email) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -332,18 +332,208 @@ class ucp extends user
|
||||
return 'EMAIL_TAKEN';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'EMAIL_INVALID';
|
||||
}
|
||||
|
||||
function update_user($userdata)
|
||||
|
||||
|
||||
|
||||
|
||||
function update_username($old_name, $new_name)
|
||||
{
|
||||
|
||||
|
||||
global $db;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function avatar_delete()
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
$avatar = explode(':', $user->data['user_avatar']);
|
||||
$avatar_type = array_shift($avatar);
|
||||
|
||||
if ($avatar_type != 'upload')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$avatar = implode('', $avatar);
|
||||
if (@file_exists('./' . $config['avatar_path'] . '/' . $avatar))
|
||||
{
|
||||
@unlink('./' . $config['avatar_path'] . '/' . $avatar);
|
||||
}
|
||||
}
|
||||
|
||||
function avatar_remote(&$data)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
if (!preg_match('#^(http[s]*?)|(ftp)://#i', $data['remotelink']))
|
||||
{
|
||||
$data['remotelink'] = 'http://' . $data['remotelink'];
|
||||
}
|
||||
|
||||
if (!preg_match('#^(http[s]?)|(ftp)://(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}:?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $data['remotelink']))
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_URL_INVALID'];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!($data['width'] || $data['height']) && ($config['avatar_max_width'] || $config['avatar_max_height']))
|
||||
{
|
||||
list($width, $height) = @getimagesize($data['remotelink']);
|
||||
|
||||
if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'])
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_max_width'], $config['avatar_max_height']);
|
||||
return true;
|
||||
}
|
||||
|
||||
$data['width'] = &$width;
|
||||
$data['height'] = &$height;
|
||||
}
|
||||
else if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_max_width'], $config['avatar_max_height']);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set type
|
||||
$data['filename'] = &$data['remotelink'];
|
||||
$data['type'] = AVATAR_REMOTE;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function avatar_upload(&$data)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
if (!empty($_FILES['uploadfile']['tmp_name']))
|
||||
{
|
||||
$filename = $_FILES['uploadfile']['tmp_name'];
|
||||
$filesize = $_FILES['uploadfile']['size'];
|
||||
$realname = $_FILES['uploadfile']['name'];
|
||||
|
||||
if (file_exists($filename) && preg_match('#^(.*?)\.(jpg|jpeg|gif|png)$#i', $realname, $match))
|
||||
{
|
||||
$realname = $match[1];
|
||||
$filetype = $match[2];
|
||||
$php_move = 'move_uploaded_file';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (preg_match('#^(http://).*?\.(jpg|jpeg|gif|png)$#i', $data['uploadurl'], $match))
|
||||
{
|
||||
if (empty($match[2]))
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_URL_INVALID'];
|
||||
return true;
|
||||
}
|
||||
|
||||
$url = parse_url($data['uploadurl']);
|
||||
|
||||
$host = $url['host'];
|
||||
$path = dirname($url['path']);
|
||||
$port = (!empty($url['port'])) ? $url['port'] : 80;
|
||||
$filetype = array_pop(explode('.', $url['path']));
|
||||
$realname = basename($url['path'], '.' . $filetype);
|
||||
$filename = $url['path'];
|
||||
$filesize = 0;
|
||||
|
||||
if (!($fsock = @fsockopen($host, $port, $errno, $errstr)))
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
|
||||
fputs($fsock, 'GET /' . $filename . " HTTP/1.1\r\n");
|
||||
fputs($fsock, "HOST: " . $host . "\r\n");
|
||||
fputs($fsock, "Connection: close\r\n\r\n");
|
||||
|
||||
$avatar_data = '';
|
||||
while (!feof($fsock))
|
||||
{
|
||||
$avatar_data .= fread($fsock, $config['avatar_filesize']);
|
||||
}
|
||||
@fclose($fsock);
|
||||
$avatar_data = array_pop(explode("\r\n", $avatar_data));
|
||||
|
||||
if (empty($avatar_data))
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
unset($url_ary);
|
||||
|
||||
$tmp_path = (!@ini_get('safe_mode')) ? false : './' . $config['avatar_path'] . '/tmp';
|
||||
$filename = tempnam($tmp_path, uniqid(rand()) . '-');
|
||||
|
||||
if (!($fp = @fopen($filename, 'wb')))
|
||||
{
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
$filesize = fwrite($fp, $avatar_data);
|
||||
fclose($fp);
|
||||
unset($avatar_data);
|
||||
|
||||
if (!$filesize)
|
||||
{
|
||||
unlink($filename);
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
|
||||
$php_move = 'copy';
|
||||
}
|
||||
|
||||
list($width, $height) = getimagesize($filename);
|
||||
|
||||
if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'] || !$width || !$height)
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_max_width'], $config['avatar_max_height']);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Replace any chars which may cause us problems with _
|
||||
$bad_chars = array(' ', '/', ':', '*', '?', '"', '<', '>', '|');
|
||||
|
||||
$data['filename'] = $user->data['user_id'] . '_' . str_replace($bad_chars, '_', $realname) . '.' . $filetype;
|
||||
$data['width'] = &$width;
|
||||
$data['height'] = &$height;
|
||||
|
||||
if(!$php_move($filename, './' . $config['avatar_path'] . '/' . $data['filename']))
|
||||
{
|
||||
@unlink($filename);
|
||||
$this->error[] = $user->lang['AVATAR_NOT_UPLOADED'];
|
||||
return true;
|
||||
}
|
||||
@unlink($filename);
|
||||
|
||||
$filesize = filesize('./' . $config['avatar_path'] . '/' . $data['filename']);
|
||||
if (!$filesize || $filesize > $config['avatar_filesize'])
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['AVATAR_WRONG_FILESIZE'], $config['avatar_filesize']);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set type
|
||||
$data['type'] = AVATAR_UPLOAD;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -923,7 +923,7 @@ class fulltext_search
|
||||
$words = array();
|
||||
if ($mode == 'edit')
|
||||
{
|
||||
echo $sql = "SELECT w.word_id, w.word_text, m.title_match
|
||||
$sql = "SELECT w.word_id, w.word_text, m.title_match
|
||||
FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m
|
||||
WHERE m.post_id = " . intval($post_id) . "
|
||||
AND w.word_id = m.word_id";
|
||||
|
@@ -17,9 +17,7 @@
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
class ucp_activate extends ucp
|
||||
{
|
||||
@@ -42,7 +40,7 @@ class ucp_activate extends ucp
|
||||
else if ($row['user_actkey'] == $_GET['k'])
|
||||
{
|
||||
$sql_update_pass = ($row['user_newpasswd'] != '') ? ", user_password = '" . $db->sql_escape($row['user_newpasswd']) . "', user_newpasswd = ''" : '';
|
||||
|
||||
z
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_active = 1, user_actkey = ''" . $sql_update_pass . "
|
||||
WHERE user_id = " . $row['user_id'];
|
||||
|
@@ -144,8 +144,92 @@ class ucp_main extends ucp
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
*/
|
||||
|
||||
$user_id = $user->data['user_id'];
|
||||
|
||||
// Grab all the relevant data
|
||||
$sql = "SELECT COUNT(p.post_id) AS num_posts
|
||||
FROM " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f
|
||||
WHERE p.poster_id = $user_id
|
||||
AND f.forum_id = p.forum_id
|
||||
$post_count_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$num_real_posts = min($row['user_posts'], $db->sql_fetchfield('num_posts', 0, $result));
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
|
||||
FROM " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f
|
||||
WHERE p.poster_id = $user_id
|
||||
AND f.forum_id = p.forum_id
|
||||
$post_count_sql
|
||||
GROUP BY f.forum_id, f.forum_name
|
||||
ORDER BY num_posts DESC";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
|
||||
$active_f_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
|
||||
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
||||
WHERE p.poster_id = $user_id
|
||||
AND t.topic_id = p.topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
$post_count_sql
|
||||
GROUP BY t.topic_id, t.topic_title
|
||||
ORDER BY num_posts DESC";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
|
||||
$active_t_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Do the relevant calculations
|
||||
$memberdays = max(1, round((time() - $row['user_regdate']) / 86400));
|
||||
$posts_per_day = $row['user_posts'] / $memberdays;
|
||||
$percentage = ($config['num_posts']) ? min(100, ($num_real_posts / $config['num_posts']) * 100) : 0;
|
||||
|
||||
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
||||
if (!empty($active_f_row['num_posts']))
|
||||
{
|
||||
$active_f_name = $active_f_row['forum_name'];
|
||||
$active_f_id = $active_f_row['forum_id'];
|
||||
$active_f_count = $active_f_row['num_posts'];
|
||||
$active_f_pct = ($active_f_count / $row['user_posts']) * 100;
|
||||
}
|
||||
unset($active_f_row);
|
||||
|
||||
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
||||
if (!empty($active_t_row['num_posts']))
|
||||
{
|
||||
$active_t_name = $active_t_row['topic_title'];
|
||||
$active_t_id = $active_t_row['topic_id'];
|
||||
$active_t_count = $active_t_row['num_posts'];
|
||||
$active_t_pct = ($active_t_count / $row['user_posts']) * 100;
|
||||
}
|
||||
unset($active_t_row);
|
||||
|
||||
$template->assign_vars(show_profile($row));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
||||
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
||||
'ACTIVE_FORUM' => $active_f_name,
|
||||
'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
||||
'ACTIVE_TOPIC' => $active_t_name,
|
||||
'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
||||
|
||||
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
||||
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
||||
|
||||
'S_PROFILE_ACTION' => "groupcp.$phpEx$SID",
|
||||
'S_GROUP_OPTIONS' => $group_options,
|
||||
|
||||
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&f=$active_f_id",
|
||||
'U_ACTIVE_TOPIC' => "viewtopic.$phpEx$SID&t=$active_t_id",)
|
||||
);
|
||||
*/
|
||||
break;
|
||||
|
||||
case 'watched':
|
||||
|
@@ -64,7 +64,7 @@ class ucp_prefs extends ucp
|
||||
if (!sizeof($this->error))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'user_viewemail' => $data['viewemail'],
|
||||
'user_allow_viewemail' => $data['viewemail'],
|
||||
'user_allow_viewonline' => !$data['hideonline'],
|
||||
'user_notify_pm' => $data['notifypm'],
|
||||
'user_popup_pm' => $data['popuppm'],
|
||||
@@ -90,7 +90,7 @@ class ucp_prefs extends ucp
|
||||
unset($data);
|
||||
}
|
||||
|
||||
$view_email = (isset($viewemail)) ? $viewemail : $user->data['user_viewemail'];
|
||||
$view_email = (isset($viewemail)) ? $viewemail : $user->data['user_allow_viewemail'];
|
||||
$view_email_yes = ($viewemail) ? ' checked="checked"' : '';
|
||||
$view_email_no = (!$viewemail) ? ' checked="checked"' : '';
|
||||
$hideonline = (isset($hideonline)) ? $hideonline : !$user->data['user_allow_viewonline'];
|
||||
|
@@ -45,23 +45,29 @@ class ucp_profile extends ucp
|
||||
$data = array();
|
||||
$normalise = array(
|
||||
'string' => array(
|
||||
'username' => '2,30',
|
||||
'username' => $config['min_name_chars'] . ',' . $config['max_name_chars'],
|
||||
'password_confirm' => $config['min_pass_chars'] . ',' . $config['max_pass_chars'],
|
||||
'new_password' => $config['min_pass_chars'] . ',' . $config['max_pass_chars'],
|
||||
'cur_password' => $config['min_pass_chars'] . ',' . $config['max_pass_chars'],
|
||||
'email' => '7,60',
|
||||
'email_confirm' => '7,60',
|
||||
'password_confirm' => '6,255',
|
||||
'new_password' => '6,255',
|
||||
'cur_password' => '6,255',
|
||||
)
|
||||
);
|
||||
$data = $this->normalise_data($_POST, $normalise);
|
||||
|
||||
// md5 current password for checking
|
||||
$data['cur_password'] = md5($data['cur_password']);
|
||||
|
||||
$validate = array(
|
||||
'reqd' => array('username', 'email'),
|
||||
'compare' => array(
|
||||
'password_confirm' => ($data['new_password']) ? $data['new_password'] : '',
|
||||
'cur_password' => ($data['new_password'] || $data['email'] != $user->data['user_email']) ? $user->data['user_password'] : '',
|
||||
'cur_password' => ($data['new_password'] || $data['email'] != $user->data['user_email'] || $data['username'] != $user->data['username']) ? $user->data['user_password'] : '',
|
||||
'email_confirm' => ($data['email'] != $user->data['user_email']) ? $data['email'] : '',
|
||||
),
|
||||
'match' => array(
|
||||
'username' => ($data['username'] != $user->data['username']) ? '#^' . str_replace('\\\\', '\\', $config['allow_name_chars']) . '$#iu' : '',
|
||||
),
|
||||
'function' => array(
|
||||
'username' => ($data['username'] != $user->data['username']) ? 'validate_username' : '',
|
||||
'email' => ($data['email'] != $user->data['user_email']) ? 'validate_email' : '',
|
||||
@@ -82,6 +88,12 @@ class ucp_profile extends ucp
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Need to update config, forum, topic, posting, messages, etc.
|
||||
if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') & $config['allow_namechange'])
|
||||
{
|
||||
$this->update_username($user->data['username'], $data['username']);
|
||||
}
|
||||
|
||||
meta_refresh(3, "ucp.$phpEx$SID&i=$id&mode=$submode");
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&i=$id&mode=$submode\">", '</a>');
|
||||
trigger_error($message);
|
||||
@@ -92,14 +104,19 @@ class ucp_profile extends ucp
|
||||
unset($data);
|
||||
}
|
||||
|
||||
$user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\w]+' => 'USERNAME_ALPHA_ONLY', '[\w_\+\. \-\[\]]+' => 'USERNAME_ALPHA_SPACERS');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (sizeof($this->error)) ? implode('<br />', $this->error) : '',
|
||||
|
||||
'USERNAME' => (isset($username)) ? $username : $user->data['username'],
|
||||
'EMAIL' => (isset($email)) ? $email : $user->data['user_email'],
|
||||
'NEW_PASSWORD' => (isset($new_password)) ? $new_password : '',
|
||||
'USERNAME' => (isset($username)) ? stripslashes($username) : $user->data['username'],
|
||||
'EMAIL' => (isset($email)) ? stripslashes($email) : $user->data['user_email'],
|
||||
'NEW_PASSWORD' => (isset($new_password)) ? stripslashes($new_password) : '',
|
||||
'CUR_PASSWORD' => '',
|
||||
'PASSWORD_CONFIRM' => (isset($password_confirm)) ? $password_confirm : '',
|
||||
'PASSWORD_CONFIRM' => (isset($password_confirm)) ? stripslashes($password_confirm) : '',
|
||||
|
||||
'L_USERNAME_EXPLAIN' => sprintf($user->lang[$user_char_ary[str_replace('\\\\', '\\', $config['allow_name_chars'])] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
|
||||
'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang['CHANGE_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
|
||||
'S_CHANGE_USERNAME' => $config['allow_namechange'] & $auth->acl_get('u_chgname'),
|
||||
'S_CHANGE_EMAIL' => $auth->acl_get('u_chgemail'),
|
||||
@@ -329,85 +346,123 @@ class ucp_profile extends ucp
|
||||
|
||||
case 'avatar':
|
||||
|
||||
$dir = @opendir($config['avatar_gallery_path']);
|
||||
|
||||
$avatar_images = array();
|
||||
while( $file = @readdir($dir) )
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
if( $file != '.' && $file != '..' && !is_file($config['avatar_gallery_path'] . '/' . $file) && !is_link($config['avatar_gallery_path'] . '/' . $file) )
|
||||
$data = array();
|
||||
if (!empty($_FILES['uploadfile']['tmp_name']))
|
||||
{
|
||||
$sub_dir = @opendir($config['avatar_gallery_path'] . '/' . $file);
|
||||
|
||||
$avatar_row_count = 0;
|
||||
$avatar_col_count = 0;
|
||||
while( $sub_file = @readdir($sub_dir) )
|
||||
{
|
||||
if( preg_match('#(\.gif$|\.png$|\.jpg|\.jpeg)$#i', $sub_file) )
|
||||
{
|
||||
$avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file;
|
||||
$avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $sub_file)));
|
||||
|
||||
$avatar_col_count++;
|
||||
if( $avatar_col_count == 4 )
|
||||
{
|
||||
$avatar_row_count++;
|
||||
$avatar_col_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->avatar_upload($data);
|
||||
}
|
||||
}
|
||||
|
||||
@closedir($dir);
|
||||
|
||||
@ksort($avatar_images);
|
||||
@reset($avatar_images);
|
||||
|
||||
$category = (isset($_POST['avatarcat'])) ? htmlspecialchars($_POST['avatarcat']) : '';
|
||||
if( empty($category) )
|
||||
{
|
||||
list($category, ) = each($avatar_images);
|
||||
}
|
||||
@reset($avatar_images);
|
||||
|
||||
$s_categories = '';
|
||||
while( list($key) = each($avatar_images) )
|
||||
{
|
||||
$selected = ( $key == $category ) ? ' selected="selected"' : '';
|
||||
if( count($avatar_images[$key]) )
|
||||
else if (!empty($_POST['uploadurl']))
|
||||
{
|
||||
$s_categories .= '<option value="' . $key . '"' . $selected . '>' . ucfirst($key) . '</option>';
|
||||
$normalise = array(
|
||||
'string' => array(
|
||||
'uploadurl' => '1,255',
|
||||
)
|
||||
);
|
||||
$data = $this->normalise_data($_POST, $normalise);
|
||||
$this->avatar_upload($data);
|
||||
}
|
||||
else if (!empty($_POST['remotelink']))
|
||||
{
|
||||
$normalise = array(
|
||||
'string' => array(
|
||||
'remotelink' => '1,255',
|
||||
'width' => '1,3',
|
||||
'height' => '1,3',
|
||||
)
|
||||
);
|
||||
$data = $this->normalise_data($_POST, $normalise);
|
||||
$this->avatar_remote($data);
|
||||
}
|
||||
else if (!empty($_POST['delete']))
|
||||
{
|
||||
$data['filename'] = $data['width'] = $data['height'] = '';
|
||||
$this->avatar_delete();
|
||||
}
|
||||
|
||||
if (!sizeof($this->error))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'user_avatar' => $data['filename'],
|
||||
'user_avatar_type' => $data['type'],
|
||||
'user_avatar_width' => $data['width'],
|
||||
'user_avatar_height' => $data['height'],
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Delete an existing avatar if present
|
||||
$this->avatar_delete();
|
||||
|
||||
meta_refresh(3, "ucp.$phpEx$SID&i=$id&mode=$submode");
|
||||
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&i=$id&mode=$submode\">", '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
//
|
||||
extract($data);
|
||||
unset($data);
|
||||
}
|
||||
|
||||
$s_colspan = 0;
|
||||
for($i = 0; $i < count($avatar_images[$category]); $i++)
|
||||
/*
|
||||
for ($i = 0; $i < count($avatar_images[$category]); $i++)
|
||||
{
|
||||
$template->assign_block_vars('avatar_row', array());
|
||||
|
||||
$s_colspan = max($s_colspan, count($avatar_images[$category][$i]));
|
||||
|
||||
for($j = 0; $j < count($avatar_images[$category][$i]); $j++)
|
||||
for ($j = 0; $j < count($avatar_images[$category][$i]); $j++)
|
||||
{
|
||||
$template->assign_block_vars('avatar_row.avatar_column', array(
|
||||
"AVATAR_IMAGE" => $config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j],
|
||||
"AVATAR_NAME" => $avatar_name[$category][$i][$j])
|
||||
'AVATAR_IMAGE' => $config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j],
|
||||
'AVATAR_NAME' => $avatar_name[$category][$i][$j])
|
||||
);
|
||||
|
||||
$template->assign_block_vars('avatar_row.avatar_option_column', array(
|
||||
"S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j])
|
||||
'S_OPTIONS_AVATAR' => $avatar_images[$category][$i][$j])
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$avatar_img = '';
|
||||
if ($user->data['user_avatar'])
|
||||
{
|
||||
switch ($user->data['user_avatar_type'])
|
||||
{
|
||||
case AVATAR_UPLOAD:
|
||||
$avatar_img = $config['avatar_path'] . '/';
|
||||
break;
|
||||
case AVATAR_GALLERY:
|
||||
$avatar_img = $config['avatar_gallery_path'] . '/';
|
||||
break;
|
||||
}
|
||||
$avatar_img .= $user->data['user_avatar'];
|
||||
|
||||
$avatar_img = '<img src="' . $avatar_img . '" width="' . $user->data['user_avatar_width'] . '" height="' . $user->data['user_avatar_height'] . '" border="0" alt="" />';
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'AVATAR' => '<img src="images/avatars/upload/' . $user->data['user_avatar'] . '" />',
|
||||
'ERROR' => (sizeof($this->error)) ? implode('<br />', $this->error) : '',
|
||||
|
||||
'S_AVATAR_CAT_OPTIONS' => $s_categories,
|
||||
'AVATAR' => $avatar_img,
|
||||
'AVATAR_SIZE' => $config['avatar_filesize'],
|
||||
'AVATAR_URL' => (isset($uploadurl)) ? $uploadurl : '',
|
||||
'AVATAR_REMOTE' => (isset($remotelink)) ? $remotelink : (($user->data['user_avatar_type'] == AVATAR_REMOTE) ? $avatar_img : ''),
|
||||
'WIDTH' => (isset($width)) ? $width : $user->data['user_avatar_width'],
|
||||
'HEIGHT' => (isset($height)) ? $height : $user->data['user_avatar_height'],
|
||||
|
||||
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),
|
||||
|
||||
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
|
||||
'S_UPLOAD_AVATAR_FILE' => true,
|
||||
'S_UPLOAD_AVATAR_URL' => true,
|
||||
'S_LINK_AVATAR' => true,
|
||||
'S_GALLERY_AVATAR' => true,)
|
||||
'S_GALLERY_AVATAR' => false,
|
||||
'S_AVATAR_CAT_OPTIONS' => $s_categories,
|
||||
'S_AVATAR_PAGE_OPTIONS' => $s_pages,)
|
||||
);
|
||||
|
||||
break;
|
||||
@@ -427,27 +482,6 @@ class ucp_profile extends ucp
|
||||
$this->display($user->lang['UCP_PROFILE'], 'ucp_profile.html');
|
||||
}
|
||||
|
||||
function check_image_type(&$type)
|
||||
{
|
||||
global $user;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'jpeg':
|
||||
case 'pjpeg':
|
||||
case 'jpg':
|
||||
return '.jpg';
|
||||
case 'gif':
|
||||
return '.gif';
|
||||
case 'png':
|
||||
return '.png';
|
||||
case 'bmp':
|
||||
return '.bmp';
|
||||
}
|
||||
|
||||
$this->error[] = $user->lang['INVALID_IMAGETYPE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -73,13 +73,13 @@ class ucp_register extends ucp
|
||||
{
|
||||
$normalise = array(
|
||||
'string' => array(
|
||||
'username' => '2,30',
|
||||
'username' => $config['min_name_chars'] . ',' . $config['max_name_chars'],
|
||||
'password_confirm' => $config['min_pass_chars'] . ',' . $config['max_pass_chars'],
|
||||
'new_password' => $config['min_pass_chars'] . ',' . $config['max_pass_chars'],
|
||||
'lang' => '1,50',
|
||||
'confirm_code' => '6,6',
|
||||
'email' => '7,60',
|
||||
'email_confirm' => '7,60',
|
||||
'new_password' => '6,255',
|
||||
'password_confirm' => '6,255',
|
||||
'lang' => '1,50',
|
||||
'confirm_code' => '6,6'
|
||||
),
|
||||
'int' => array('tz')
|
||||
);
|
||||
@@ -91,6 +91,9 @@ class ucp_register extends ucp
|
||||
'password_confirm' => $data['new_password'],
|
||||
'email_confirm' => $data['email'],
|
||||
),
|
||||
'match' => array(
|
||||
'username' => '#^' . str_replace('\\\\', '\\', $config['allow_name_chars']) . '$#iu',
|
||||
),
|
||||
'function' => array(
|
||||
'username' => 'validate_username',
|
||||
'email' => 'validate_email',
|
||||
@@ -139,8 +142,9 @@ class ucp_register extends ucp
|
||||
{
|
||||
$server_url = generate_board_url();
|
||||
|
||||
if ($coppa && ($config['require_activation'] == USER_ACTIVATION_SELF ||
|
||||
$config['require_activation'] == USER_ACTIVATION_ADMIN))
|
||||
if (($coppa ||
|
||||
$config['require_activation'] == USER_ACTIVATION_SELF ||
|
||||
$config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable'])
|
||||
{
|
||||
$user_actkey = $this->gen_rand_string(10);
|
||||
$key_len = 54 - (strlen($server_url));
|
||||
@@ -161,7 +165,7 @@ class ucp_register extends ucp
|
||||
'user_ip' => $user->ip,
|
||||
'user_regdate' => time(),
|
||||
'username' => $data['username'],
|
||||
'user_password' => $data['new_password'],
|
||||
'user_password' => md5($data['new_password']),
|
||||
'user_email' => $data['email'],
|
||||
'user_allow_pm' => 1,
|
||||
'user_timezone' => (float) $data['tz'],
|
||||
@@ -175,8 +179,10 @@ class ucp_register extends ucp
|
||||
|
||||
$user_id = $db->sql_nextid();
|
||||
|
||||
// Place into appropriate group, either REGISTERED or INACTIVE depending on config
|
||||
$group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? 'REGISTERED' : 'INACTIVE';
|
||||
// Place into appropriate group, either REGISTERED(_COPPA) or INACTIVE(_COPPA) depending on config
|
||||
$group_reg = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED';
|
||||
$group_inactive = ($coppa) ? 'INACTIVE_COPPA' : 'INACTIVE';
|
||||
$group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? $group_reg : $group_inactive;
|
||||
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
|
||||
SELECT $user_id, group_id, 0
|
||||
FROM " . GROUPS_TABLE . "
|
||||
@@ -186,17 +192,17 @@ class ucp_register extends ucp
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
if ($coppa)
|
||||
if ($coppa && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_COPPA'];
|
||||
$email_template = 'coppa_welcome_inactive';
|
||||
}
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_SELF)
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_INACTIVE'];
|
||||
$email_template = 'user_welcome_inactive';
|
||||
}
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable'])
|
||||
{
|
||||
$message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
|
||||
$email_template = 'admin_welcome_inactive';
|
||||
@@ -235,7 +241,7 @@ class ucp_register extends ucp
|
||||
'SITENAME' => $config['sitename'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$emailer->send();
|
||||
$emailer->reset();
|
||||
|
||||
@@ -257,7 +263,7 @@ class ucp_register extends ucp
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['require_activation'] == USER_ACTIVATION_NONE)
|
||||
if ($config['require_activation'] == USER_ACTIVATION_NONE || !$config['email_enable'])
|
||||
{
|
||||
set_config('newest_user_id', $user_id);
|
||||
set_config('newest_username', $data['username']);
|
||||
@@ -311,7 +317,7 @@ class ucp_register extends ucp
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['attempts'] > 5)
|
||||
if ($row['attempts'] > 3)
|
||||
{
|
||||
trigger_error($user->lang['TOO_MANY_REGISTERS']);
|
||||
}
|
||||
@@ -342,6 +348,8 @@ class ucp_register extends ucp
|
||||
break;
|
||||
}
|
||||
|
||||
$user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\w]+' => 'USERNAME_ALPHA_ONLY', '[\w_\+\. \-\[\]]+' => 'USERNAME_ALPHA_SPACERS');
|
||||
|
||||
//
|
||||
$template->assign_vars(array(
|
||||
'USERNAME' => $username,
|
||||
@@ -352,8 +360,10 @@ class ucp_register extends ucp
|
||||
'CONFIRM_IMG' => $confirm_image,
|
||||
'ERROR' => (sizeof($this->error)) ? implode('<br />', $this->error) : '',
|
||||
|
||||
'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlentities($config['board_contact']) . '">', '</a>'),
|
||||
'L_ITEMS_REQUIRED' => $l_reg_cond,
|
||||
'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlentities($config['board_contact']) . '">', '</a>'),
|
||||
'L_ITEMS_REQUIRED' => $l_reg_cond,
|
||||
'L_USERNAME_EXPLAIN' => sprintf($user->lang[$user_char_ary[str_replace('\\\\', '\\', $config['allow_name_chars'])] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
|
||||
'L_NEW_PASSWORD_EXPLAIN'=> sprintf($user->lang['NEW_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
|
||||
'S_LANG_OPTIONS' => language_select($lang),
|
||||
'S_TZ_OPTIONS' => tz_select($tz),
|
||||
|
Reference in New Issue
Block a user