diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-10-30 00:57:27 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-10-30 00:57:27 +0000 |
commit | 691f50ada9386a63c53a473a44b835a8b1ca5978 (patch) | |
tree | be18990bb0ae925485bc4785b15f648ca8cb2e9d | |
parent | 9075298051fca5bc78713f455fc58d99e677e77a (diff) | |
download | forums-691f50ada9386a63c53a473a44b835a8b1ca5978.tar forums-691f50ada9386a63c53a473a44b835a8b1ca5978.tar.gz forums-691f50ada9386a63c53a473a44b835a8b1ca5978.tar.bz2 forums-691f50ada9386a63c53a473a44b835a8b1ca5978.tar.xz forums-691f50ada9386a63c53a473a44b835a8b1ca5978.zip |
Changed $board_config to $config, more posting "stuff", altered polling code in viewtopic and loads of new problems, poor coding, etc. created :)
git-svn-id: file:///svn/phpbb/trunk@2983 89ea8834-ac86-4346-8a33-228a782c2dd0
43 files changed, 1070 insertions, 1042 deletions
diff --git a/phpBB/admin/admin_board.php b/phpBB/admin/admin_board.php index bdba9b292d..0656654d77 100644 --- a/phpBB/admin/admin_board.php +++ b/phpBB/admin/admin_board.php @@ -530,7 +530,7 @@ switch ( $mode ) $auth_select = ''; foreach ( $auth_plugins as $method ) { - $selected = ( $board_config['auth_method'] == $method ) ? ' selected="selected"' : ''; + $selected = ( $config['auth_method'] == $method ) ? ' selected="selected"' : ''; $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>'; } @@ -557,7 +557,7 @@ switch ( $mode ) // foreach( $config_fields as $field ) { - if ( !isset($board_config[$field]) ) + if ( !isset($config[$field]) ) { $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('$field', '')"; diff --git a/phpBB/admin/admin_email.php b/phpBB/admin/admin_email.php index e8790017c5..41e3ca55cd 100644 --- a/phpBB/admin/admin_email.php +++ b/phpBB/admin/admin_email.php @@ -94,16 +94,16 @@ if ( isset($_POST['submit']) ) // Let's do some checking to make sure that mass mail functions // are working in win32 versions of php. // - if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) + if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) { // We are running on windows, force delivery to use // our smtp functions since php's are broken by default - $board_config['smtp_delivery'] = 1; - $board_config['smtp_host'] = get_cfg_var('SMTP'); + $config['smtp_delivery'] = 1; + $config['smtp_host'] = get_cfg_var('SMTP'); } - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\n"; + $email_headers = 'From: ' . $config['board_email'] . "\n"; $bcc_list = ''; for($i = 0; $i < count($email_list); $i++) @@ -119,13 +119,13 @@ if ( isset($_POST['submit']) ) $email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\n"; $emailer->use_template('admin_send_email'); - $emailer->email_address($board_config['board_email']); + $emailer->email_address($config['board_email']); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'BOARD_EMAIL' => $board_config['board_email'], + 'SITENAME' => $config['sitename'], + 'BOARD_EMAIL' => $config['board_email'], 'MESSAGE' => $message) ); diff --git a/phpBB/admin/admin_permissions.php b/phpBB/admin/admin_permissions.php index 05d83d9139..7eec84da2e 100644 --- a/phpBB/admin/admin_permissions.php +++ b/phpBB/admin/admin_permissions.php @@ -530,12 +530,6 @@ if ( !empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators <tr> <td class="cat" colspan="4" align="center"><input class="mainoption" type="submit" name="update" value="<?php echo $user->lang['Update']; ?>" /> <input class="liteoption" type="submit" name="cancel" value="<?php echo $user->lang['Cancel']; ?>" /><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /><input type="hidden" name="type" value="<?php echo $_POST['type']; ?>" /><?php echo $ug_hidden; ?></td> </tr> - <!-- tr> - <th colspan="4"><?php echo $user->lang['Applies_to_' . $l_type]; ?></th> - </tr> - <tr> - <td class="row1" colspan="4" align="center"><textarea cols="40" rows="3"><?php echo trim($ug); ?></textarea></td> - </tr --> </table></td> </tr> </table></form> diff --git a/phpBB/admin/admin_search.php b/phpBB/admin/admin_search.php index 5fdc2b8a5e..158e13a96e 100644 --- a/phpBB/admin/admin_search.php +++ b/phpBB/admin/admin_search.php @@ -278,7 +278,7 @@ if ( isset($_POST['start']) || isset($_GET['batchstart']) ) // Remove common words after the first 2 batches and after every 4th batch after that. if ( $batchcount % 4 == 3 ) { -// remove_common('global', $board_config['common_search']); +// remove_common('global', $config['common_search']); } $batchcount++; diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index ebe5459762..b2c1c873e3 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -53,7 +53,7 @@ $mode = ( isset($_GET['mode']) ) ? $_GET['mode'] : $_POST['mode']; switch ( $mode ) { case 'editimageset': - $imgroot = ( isset($_POST['imgroot']) ) ? $_POST['imgroot'] : $board_config['default_style']; + $imgroot = ( isset($_POST['imgroot']) ) ? $_POST['imgroot'] : $config['default_style']; if ( isset($_POST['img_addconfig']) ) { diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php index ac5b7a5c52..bbc5a29bb4 100644 --- a/phpBB/admin/admin_users.php +++ b/phpBB/admin/admin_users.php @@ -197,16 +197,17 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) ) $userauth = new auth(); $userauth->acl($userdata); + foreach ($acl_options['global'] as $option_name => $option_id) + { + $type = substr($option_name, 0, strpos('_', $option_name) +1 ); + $global[$type][$option_name] = $userauth->acl_get($option_name); + } + $sql = "SELECT forum_id, forum_name FROM " . FORUMS_TABLE . " ORDER BY left_id"; $result = $db->sql_query($sql); - foreach ($acl_options['global'] as $option_name => $option_id) - { - $global[$option_name] = $userauth->acl_get($option_name); - } - $permissions = array(); while( $row = $db->sql_fetchrow($result) ) { @@ -220,13 +221,47 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) ) ?> <tr> - <td>Board-wide options</td> - <td><table cellspacing="1" cellpadding="0" border="0"> + <td colspan="2"><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th> <?php echo $user->lang['Option']; ?> </th> + <th> <?php echo $user->lang['Allow']; ?> </th> + <th> <?php echo $user->lang['Deny']; ?> </th> + </tr> +<?php + $type_lang = array( + 'f' => 'Forum', + 'a' => 'Administrator', + 'm' => 'Moderator', + 'u' => 'User', + ); + + foreach ($global as $type => $auth_ary) + { +?> + <tr> + <td class="cat" colspan="3"><?php echo $type_lang[$type]; ?></td> + </tr> <?php - foreach ($global as $option => $allow) + foreach ($auth_ary as $option => $allow) { - echo '<tr><td>' . $option . ' => ' . ( ( $allow ) ? 'Allowed' : 'Denied' ) . '</td></tr>'; + if ( $option != $type .'_' ) + { + $row_class = ( $row_class == 'row1' ) ? 'row2' : 'row1'; + + $l_can_cell = ( !empty($user->lang['acl_' . $option]) ) ? $user->lang['acl_' . $option] : ucfirst(preg_replace('#.*?_#', '', $option)); + + $allow_type = ( $allow == ACL_ALLOW ) ? ' checked="checked"' : ''; + $deny_type = ( $allow == ACL_DENY ) ? ' checked="checked"' : ''; +?> + <tr> + <td class="<?php echo $row_class; ?>"><?php echo $l_can_cell; ?></td> + <td class="<?php echo $row_class; ?>" align="center"><input type="radio"<?php echo $allow_type; ?> /></td> + <td class="<?php echo $row_class; ?>" align="center"><input type="radio"<?php echo $deny_type; ?> /></td> + </tr> +<?php + } + } } ?> @@ -245,7 +280,7 @@ if ( isset($_POST['username']) || isset($_GET['u']) || isset( $_POST['u']) ) foreach ($auth_ary as $option => $allow) { - echo '<tr><td>' . $option . ' => ' . ( ( $allow ) ? 'Allowed' : 'Denied' ) . '</td></tr>'; + echo '<tr><td>' . $user->lang['acl_' . $option] . ' => ' . ( ( $allow ) ? 'Allowed' : 'Denied' ) . '</td></tr>'; } ?> @@ -296,9 +331,9 @@ function ipwhois($ip) $match = array( '#RIPE\.NET#is' => 'whois.ripe.net', - '#whois\.apnic\.net#is' => 'whois.ripe.net', - '#nic\.ad\.jp#is' => 'whois.ripe.net', - '#whois\.registro\.br#is' => 'whois.ripe.net' + '#whois\.apnic\.net#is' => 'whois.apnic.net', + '#nic\.ad\.jp#is' => 'whois.nic.ad.jp', + '#whois\.registro\.br#is' => 'whois.registro.br' ); if ( ($fsk = fsockopen('whois.arin.net', 43)) ) diff --git a/phpBB/admin/admin_viewlogs.php b/phpBB/admin/admin_viewlogs.php index 9b35c45490..f1506c9185 100644 --- a/phpBB/admin/admin_viewlogs.php +++ b/phpBB/admin/admin_viewlogs.php @@ -196,7 +196,7 @@ if ( $mode == 'mod' ) // $log_data = array(); $log_count = 0; -view_log($mode, $log_data, $log_count, $board_config['topics_per_page'], $start, $forum_id, $where_sql, $sort_sql); +view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, $where_sql, $sort_sql); if ( $log_count ) { @@ -242,7 +242,7 @@ else <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> <tr> - <td align="left" valign="top"> <span class="nav"><?php echo on_page($log_count, $board_config['topics_per_page'], $start); ?></span></td> + <td align="left" valign="top"> <span class="nav"><?php echo on_page($log_count, $config['topics_per_page'], $start); ?></span></td> <td align="right" valign="top" nowrap="nowrap"><?php if ( $auth->acl_get('a_clearlogs') ) @@ -253,7 +253,7 @@ else } - $pagination = generate_pagination("admin_viewlogs.$phpEx$SID&mode=$mode&sort_days=$sort_days&sort_key=$sort_key&sort_dir=$sort_dir", $log_count, $board_config['topics_per_page'], $start); + $pagination = generate_pagination("admin_viewlogs.$phpEx$SID&mode=$mode&sort_days=$sort_days&sort_key=$sort_key&sort_dir=$sort_dir", $log_count, $config['topics_per_page'], $start); ?><span class="nav"><?php echo $pagination; ?></span></td> </tr> diff --git a/phpBB/admin/admin_words.php b/phpBB/admin/admin_words.php index b2ffc22b54..579014b52e 100644 --- a/phpBB/admin/admin_words.php +++ b/phpBB/admin/admin_words.php @@ -27,7 +27,7 @@ if ( !empty($setmodules) ) } $file = basename(__FILE__); - $module['General']['Word_Censor'] = "$file$SID"; + $module['Posts']['Word_Censor'] = "$file$SID"; return; } diff --git a/phpBB/admin/index.php b/phpBB/admin/index.php index e8a6c1d134..b2fea163b4 100644 --- a/phpBB/admin/index.php +++ b/phpBB/admin/index.php @@ -174,13 +174,13 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' ) } // Get forum statistics - $total_posts = $board_config['num_posts']; - $total_topics = $board_config['num_topics']; - $total_users = $board_config['num_users']; + $total_posts = $config['num_posts']; + $total_topics = $config['num_topics']; + $total_users = $config['num_users']; - $start_date = $user->format_date($board_config['board_startdate']); + $start_date = $user->format_date($config['board_startdate']); - $boarddays = ( time() - $board_config['board_startdate'] ) / 86400; + $boarddays = ( time() - $config['board_startdate'] ) / 86400; $posts_per_day = sprintf('%.2f', $total_posts / $boarddays); $topics_per_day = sprintf('%.2f', $total_topics / $boarddays); @@ -188,13 +188,13 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' ) $avatar_dir_size = 0; - if ( $avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']) ) + if ( $avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']) ) { while ( $file = @readdir($avatar_dir) ) { if ( $file != '.' && $file != '..' ) { - $avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . '/' . $file); + $avatar_dir_size += @filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); } } @closedir($avatar_dir); @@ -360,10 +360,10 @@ elseif ( isset($_GET['pane']) && $_GET['pane'] == 'right' ) <td class="row1" nowrap="nowrap"><?php echo $user->lang['Database_size']; ?>:</td> <td class="row2"><b><?php echo $dbsize; ?></b></td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['Gzip_compression']; ?>:</td> - <td class="row2"><b><?php echo ( $board_config['gzip_compress'] ) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td> + <td class="row2"><b><?php echo ( $config['gzip_compress'] ) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td> </tr> <!-- tr> - <td class="row1" colspan="4"><?php echo sprintf($user->lang['Record_online_users'], $board_config['record_online_users'], $user->format_date($board_config['record_online_date'])); ?></td> + <td class="row1" colspan="4"><?php echo sprintf($user->lang['Record_online_users'], $config['record_online_users'], $user->format_date($config['record_online_date'])); ?></td> </tr --> </table> diff --git a/phpBB/admin/pagestart.php b/phpBB/admin/pagestart.php index f08aaff80a..37aaa9c899 100644 --- a/phpBB/admin/pagestart.php +++ b/phpBB/admin/pagestart.php @@ -48,12 +48,12 @@ if ($_REQUEST['sid'] != $user->data['session_id']) // Functions function page_header($sub_title, $meta = '', $table_html = true) { - global $board_config, $db, $user, $phpEx; + global $config, $db, $user, $phpEx; define('HEADER_INC', true); // gzip_compression - if ( $board_config['gzip_compress'] ) + if ( $config['gzip_compress'] ) { if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() ) { @@ -81,7 +81,7 @@ th { background-image: url('images/cellpic3.gif') } td.cat { background-image: url('images/cellpic1.gif') } //--> </style> -<title><?php echo $board_config['sitename'] . ' - ' . $page_title; ?></title> +<title><?php echo $config['sitename'] . ' - ' . $page_title; ?></title> </head> <body> @@ -111,7 +111,7 @@ td.cat { background-image: url('images/cellpic1.gif') } function page_footer($copyright_html = true) { - global $board_config, $db, $phpEx; + global $config, $db, $phpEx; // Close our DB connection. $db->sql_close(); @@ -127,7 +127,7 @@ function page_footer($copyright_html = true) ?> -<div align="center"><span class="copyright">Powered by phpBB <?php echo $board_config['version']; ?> © 2002 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a></span></div> +<div align="center"><span class="copyright">Powered by phpBB <?php echo $config['version']; ?> © 2002 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a></span></div> <br clear="all" /> diff --git a/phpBB/common.php b/phpBB/common.php index e871afb8ed..82b0a4cc99 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -130,6 +130,9 @@ define('TOPICS_WATCH_TABLE', $table_prefix.'topics_watch'); define('USER_GROUP_TABLE', $table_prefix.'user_group'); define('USERS_TABLE', $table_prefix.'users'); define('WORDS_TABLE', $table_prefix.'words'); +define('POLL_OPTIONS_TABLE', $table_prefix.'poll_results'); +define('POLL_VOTES_TABLE', $table_prefix.'poll_voters'); + define('VOTE_DESC_TABLE', $table_prefix.'vote_desc'); define('VOTE_RESULTS_TABLE', $table_prefix.'vote_results'); define('VOTE_USERS_TABLE', $table_prefix.'vote_voters'); @@ -142,10 +145,10 @@ $template = new Template(); $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); // Obtain boardwide default config (rebuilding cache if reqd) -if ( empty($board_config) ) +if ( empty($config) ) { require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); - $board_config = config_config(); + $config = config_config(); } $sql = "SELECT * @@ -155,7 +158,7 @@ $result = $db->sql_query($sql, false); while ( $row = $db->sql_fetchrow($result) ) { - $board_config[$row['config_name']] = $row['config_value']; + $config[$row['config_name']] = $row['config_value']; } // Re-cache acl options if reqd @@ -171,9 +174,9 @@ $user = new user(); $auth = new auth(); // Show 'Board is disabled' message -if ( $board_config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN') ) +if ( $config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN') ) { - $message = ( !empty($board_config['board_disable_msg']) ) ? $board_config['board_disable_msg'] : 'Board_disable'; + $message = ( !empty($config['board_disable_msg']) ) ? $config['board_disable_msg'] : 'Board_disable'; trigger_error($message); } diff --git a/phpBB/config_cache.php b/phpBB/config_cache.php index 3d34b3d0cc..1b7d74852e 100644 --- a/phpBB/config_cache.php +++ b/phpBB/config_cache.php @@ -2,7 +2,7 @@ // phpBB cache file - DO NOT change anything in here by hand! -$board_config = array(); +$config = array(); $acl_options = array(); diff --git a/phpBB/groupcp.php b/phpBB/groupcp.php index a7d6f03646..ed477eaaad 100644 --- a/phpBB/groupcp.php +++ b/phpBB/groupcp.php @@ -29,10 +29,10 @@ include($phpbb_root_path . 'common.'.$phpEx); // function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$joined, &$poster_avatar, &$profile_img, &$profile, &$search_img, &$search, &$pm_img, &$pm, &$email_img, &$email, &$www_img, &$www, &$icq_status_img, &$icq_img, &$icq, &$aim_img, &$aim, &$msn_img, &$msn, &$yim_img, &$yim) { - global $lang, $images, $board_config, $phpEx; + global $lang, $images, $config, $phpEx; $from = ( !empty($row['user_from']) ) ? $row['user_from'] : ' '; - $joined = create_date($date_format, $row['user_regdate'], $board_config['board_timezone']); + $joined = create_date($date_format, $row['user_regdate'], $config['board_timezone']); $posts = ( $row['user_posts'] ) ? $row['user_posts'] : 0; $poster_avatar = ''; @@ -41,20 +41,20 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$ switch( $row['user_avatar_type'] ) { case USER_AVATAR_UPLOAD: - $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_upload'] ) ? '<img src="' . $config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_REMOTE: - $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_GALLERY: - $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_local'] ) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; } } if ( !empty($row['user_viewemail']) || $group_mod ) { - $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $row['user_id']) : 'mailto:' . $row['user_email']; + $email_uri = ( $config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $row['user_id']) : 'mailto:' . $row['user_email']; $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>'; $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>'; @@ -118,11 +118,11 @@ $auth->acl($user->data); // End session management // -$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path'])); +$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($config['script_path'])); $script_name = ( $script_name != '' ) ? $script_name . '/groupcp.'.$phpEx : 'groupcp.'.$phpEx; -$server_name = trim($board_config['server_name']); -$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; -$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; +$server_name = trim($config['server_name']); +$server_protocol = ( $config['cookie_secure'] ) ? 'https://' : 'http://'; +$server_port = ( $config['server_port'] <> 80 ) ? ':' . trim($config['server_port']) . '/' : '/'; $server_url = $server_protocol . $server_name . $server_port . $script_name; @@ -273,9 +273,9 @@ else if ( isset($_POST['joingroup']) && $group_id ) $moderator = $db->sql_fetchrow($result); include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; $emailer->use_template('group_request', $moderator['user_lang']); $emailer->email_address($moderator['user_email']); @@ -283,9 +283,9 @@ else if ( isset($_POST['joingroup']) && $group_id ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'GROUP_MODERATOR' => $moderator['username'], - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id&validate=true") ); @@ -551,9 +551,9 @@ else if ( $group_id ) $group_name = $group_name_row['group_name']; include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; $emailer->use_template('group_added', $row['user_lang']); $emailer->email_address($row['user_email']); @@ -561,9 +561,9 @@ else if ( $group_id ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'GROUP_NAME' => $group_name, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id") ); @@ -706,9 +706,9 @@ else if ( $group_id ) $group_name = $group_name_row['group_name']; include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\nBcc: " . $email_addresses . "\r\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\nBcc: " . $email_addresses . "\r\n"; $emailer->use_template('group_approved'); $emailer->email_address($user->data['user_email']); @@ -716,9 +716,9 @@ else if ( $group_id ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'GROUP_NAME' => $group_name, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id") ); @@ -891,7 +891,7 @@ else if ( $group_id ) $username = $group_moderator['username']; $user_id = $group_moderator['user_id']; - generate_user_info($group_moderator, $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); + generate_user_info($group_moderator, $config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); $template->assign_vars(array( 'L_GROUP_INFORMATION' => $lang['Group_Information'], @@ -976,12 +976,12 @@ else if ( $group_id ) // // Dump out the remaining users // - for($i = $start; $i < min($board_config['topics_per_page'] + $start, $members_count); $i++) + for($i = $start; $i < min($config['topics_per_page'] + $start, $members_count); $i++) { $username = $group_members[$i]['username']; $user_id = $group_members[$i]['user_id']; - generate_user_info($group_members[$i], $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); + generate_user_info($group_members[$i], $config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); if ( $group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator ) { @@ -1038,11 +1038,11 @@ else if ( $group_id ) ); } - $current_page = ( !$members_count ) ? 1 : ceil( $members_count / $board_config['topics_per_page'] ); + $current_page = ( !$members_count ) ? 1 : ceil( $members_count / $config['topics_per_page'] ); $template->assign_vars(array( - 'PAGINATION' => generate_pagination("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id", $members_count, $board_config['topics_per_page'], $start), - 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), $current_page ), + 'PAGINATION' => generate_pagination("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id", $members_count, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), $current_page ), 'L_GOTO_PAGE' => $lang['Goto_page']) ); @@ -1074,7 +1074,7 @@ else if ( $group_id ) $username = $modgroup_pending_list[$i]['username']; $user_id = $modgroup_pending_list[$i]['user_id']; - generate_user_info($modgroup_pending_list[$i], $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); + generate_user_info($modgroup_pending_list[$i], $config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim); $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 0fc0973602..0111a4d446 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -26,7 +26,7 @@ if ( !defined('IN_PHPBB') ) define('BBCODE_UID_LEN', 10); -// global that holds loaded-and-prepared bbcode templates, so we only have to do +// global that holds loaded-and-prepared bbcode templates, so we only have to do // that stuff once. $bbcode_tpl = null; @@ -45,21 +45,21 @@ function load_bbcode_template() global $template; $tpl_filename = $template->make_filename('bbcode.html'); $tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename)); - + // replace \ with \\ and then ' with \'. $tpl = str_replace('\\', '\\\\', $tpl); $tpl = str_replace('\'', '\\\'', $tpl); - + // strip newlines. $tpl = str_replace("\n", '', $tpl); - + // Turn template blocks into PHP assignment statements for the values of $bbcode_tpls.. $tpl = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . '$bbcode_tpls[\'\\1\'] = \'\\2\';', $tpl); - + $bbcode_tpls = array(); eval($tpl); - + return $bbcode_tpls; } @@ -68,7 +68,7 @@ function load_bbcode_template() * Prepares the loaded bbcode templates for insertion into preg_replace() * or str_replace() calls in the bbencode_second_pass functions. This * means replacing template placeholders with the appropriate preg backrefs - * or with language vars. NOTE: If you change how the regexps work in + * or with language vars. NOTE: If you change how the regexps work in * bbencode_second_pass(), you MUST change this function. * * Nathan Codding, Sept 26 2001 @@ -77,52 +77,52 @@ function load_bbcode_template() function prepare_bbcode_template($bbcode_tpl) { global $lang; - + $bbcode_tpl['olist_open'] = str_replace('{LIST_TYPE}', '\\1', $bbcode_tpl['olist_open']); - + $bbcode_tpl['color_open'] = str_replace('{COLOR}', '\\1', $bbcode_tpl['color_open']); - + $bbcode_tpl['size_open'] = str_replace('{SIZE}', '\\1', $bbcode_tpl['size_open']); - + $bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']); - + $bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_open']); $bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_open']); $bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_open']); - + $bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']); $bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']); - + // We do URLs in several different ways.. $bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']); $bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']); - + $bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); $bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']); - + $bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']); $bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']); - + $bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']); $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); - + define('BBCODE_TPL_READY', true); - + return $bbcode_tpl; } /** * Does second-pass bbencoding. This should be used before displaying the message in - * a thread. Assumes the message is already first-pass encoded, and we are given the + * a thread. Assumes the message is already first-pass encoded, and we are given the * correct UID as used in first-pass encoding. */ function bbencode_second_pass($text, $uid, $enable_img = true) { - global $acl, $board_config, $lang, $bbcode_tpl; + global $acl, $config, $lang, $bbcode_tpl; // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0). // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it. @@ -135,13 +135,13 @@ function bbencode_second_pass($text, $uid, $enable_img = true) $text = substr($text, 1); return $text; } - + // Only load the templates ONCE.. if (!defined('BBCODE_TPL_READY')) { // load templates from file into array. $bbcode_tpl = load_bbcode_template(); - + // prepare array for use in regexps. $bbcode_tpl = prepare_bbcode_template($bbcode_tpl); } @@ -171,7 +171,7 @@ function bbencode_second_pass($text, $uid, $enable_img = true) // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text); $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text); - + // New one liner to deal with opening quotes with usernames... // replaces the two line version that I had here before.. $text = preg_replace("/\[quote:$uid=(?:\"?([^\"]*)\"?)\]/si", $bbcode_tpl['quote_username_open'], $text); @@ -199,7 +199,7 @@ function bbencode_second_pass($text, $uid, $enable_img = true) $patterns[0] = "#\[img:$uid\](.*?)\[/img:$uid\]#si"; $replacements[0] = $bbcode_tpl['img']; } - + // [url]xxxx://www.phpbb.com[/url] code.. $patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/url\]#si"; $replacements[1] = $bbcode_tpl['url1']; @@ -253,7 +253,7 @@ function bbencode_first_pass($text, $uid) // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, ''); - + $text = bbencode_first_pass_pda($text, $uid, '/\[quote=(\\\\"[^"]*?\\\\")\]/is', '[/quote]', '', false, '', "[quote:$uid=\\1]"); // [list] and [list=x] for (un)ordered lists. @@ -351,9 +351,9 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_ $open_tag[0] = $open_tag_temp; $open_tag_count = 1; } - + $open_is_regexp = false; - + if ($open_regexp_replace) { $open_is_regexp = true; @@ -364,12 +364,12 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_ $open_regexp_replace[0] = $open_regexp_temp; } } - + if ($mark_lowest_level && $open_is_regexp) { message_die(GENERAL_ERROR, "Unsupported operation for bbcode_first_pass_pda()."); } - + // Start at the 2nd char of the string, looking for opening tags. $curr_pos = 1; @@ -398,12 +398,12 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_ // // OK we are in a quote tag that probably contains a ] bracket. // Grab a bit more of the string to hopefully get all of it.. - // + // $possible_start = substr($text, $curr_pos, strpos($text, "\"]", $curr_pos + 1) - $curr_pos + 2); } // // Now compare, either using regexp or not. - + if ($open_is_regexp) { $match_result = array(); @@ -441,7 +441,7 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_ // Keeps error in nested tag from breaking out // of table structure.. // - $curr_pos = $curr_pos + strlen($possible_start); + $curr_pos = $curr_pos + strlen($possible_start); } else { @@ -574,12 +574,12 @@ function bbencode_second_pass_code($text, $uid, $bbcode_tpl) { $before_replace = $matches[1][$i]; $after_replace = $matches[1][$i]; - + // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines. $after_replace = str_replace(" ", " ", $after_replace); // now Replace 2 spaces with " " to catch odd #s of spaces. $after_replace = str_replace(" ", " ", $after_replace); - + // Replace tabs with " " so tabbed code indents sorta right without making huge long lines. $after_replace = str_replace("\t", " ", $after_replace); @@ -740,7 +740,7 @@ function bbcode_array_pop(&$stack) // function smilies_pass($message) { - global $db, $board_config; + global $db, $config; static $smilies; if ( empty($smilies) ) @@ -749,7 +749,7 @@ function smilies_pass($message) FROM " . SMILIES_TABLE; $result = $db->sql_query($sql); - if ( !($smilies = $db->sql_fetchrowset($result)) ) + if ( !($smilies = $db->sql_fetchrowset($result)) ) { return $message; } @@ -760,7 +760,7 @@ function smilies_pass($message) for($i = 0; $i < count($smilies); $i++) { $orig[] = '/(?<=.\\W|\\W.|^\\W)' . preg_quote($smilies[$i]['code'], '/') . '(?=.\\W|\\W.|\\W$)/'; - $repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" width="' . $smilies[$i]['smile_width'] . '" height="' . $smilies[$i]['smile_height'] . '" alt="' . $smilies[$i]['smile_url'] . '" title="' . $smilies[$i]['smile_url'] . '" border="0" />'; + $repl[] = '<img src="'. $config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" width="' . $smilies[$i]['smile_width'] . '" height="' . $smilies[$i]['smile_height'] . '" alt="' . $smilies[$i]['smile_url'] . '" title="' . $smilies[$i]['smile_url'] . '" border="0" />'; } if ( $i > 0 ) diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index cabe89b944..f8a06cc91b 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -81,11 +81,11 @@ class emailer function use_template($template_file, $template_lang = '') { - global $board_config, $phpbb_root_path; + global $config, $phpbb_root_path; if ( $template_lang == '' ) { - $template_lang = $board_config['default_lang']; + $template_lang = $config['default_lang']; } $this->tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.txt'; @@ -324,10 +324,10 @@ function server_parse($socket, $response) function smtpmail($mail_to, $subject, $message, $headers = '') { // For now I'm using an array based $smtp_vars to hold the smtp server - // info, but it should probably change to $board_config... - // then the relevant info would be $board_config['smtp_host'] and - // $board_config['smtp_port']. - global $board_config; + // info, but it should probably change to $config... + // then the relevant info would be $config['smtp_host'] and + // $config['smtp_port']. + global $config; // // Fix any bare linefeeds in the message to make it RFC821 Compliant. @@ -396,37 +396,37 @@ function smtpmail($mail_to, $subject, $message, $headers = '') // Ok we have error checked as much as we can to this point let's get on // it already. // - if( !$socket = fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) ) + if( !$socket = fsockopen($config['smtp_host'], 25, $errno, $errstr, 20) ) { message_die(ERROR, "Could not connect to smtp host : $errno : $errstr"); } server_parse($socket, "220"); - if( !empty($board_config['smtp_username']) && !empty($board_config['smtp_password']) ) + if( !empty($config['smtp_username']) && !empty($config['smtp_password']) ) { // Send the RFC2554 specified EHLO. // This improved as provided by SirSir to accomodate // both SMTP AND ESMTP capable servers - fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n"); + fputs($socket, "EHLO " . $config['smtp_host'] . "\r\n"); server_parse($socket, "250"); fputs($socket, "AUTH LOGIN\r\n"); server_parse($socket, "334"); - fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n"); + fputs($socket, base64_encode($config['smtp_username']) . "\r\n"); server_parse($socket, "334"); - fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n"); + fputs($socket, base64_encode($config['smtp_password']) . "\r\n"); server_parse($socket, "235"); } else { // Send the RFC821 specified HELO. - fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n"); + fputs($socket, "HELO " . $config['smtp_host'] . "\r\n"); server_parse($socket, "250"); } // From this point onward most server response codes should be 250 // Specify who the mail is from.... - fputs($socket, "MAIL FROM: <" . $board_config['board_email'] . ">\r\n"); + fputs($socket, "MAIL FROM: <" . $config['board_email'] . ">\r\n"); server_parse($socket, "250"); // Specify each user to send to and build to header. diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5a38c4f9e7..6cfbd9db8f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -37,7 +37,7 @@ function get_userdata($user) return ( $row = $db->sql_fetchrow($result) ) ? $row : false; } -function get_forum_branch($forum_id, $type='all', $order='descending', $include_forum=TRUE) +function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $include_forum = TRUE) { global $db; @@ -216,7 +216,7 @@ function get_moderators(&$forum_moderators, $forum_id = false) // function get_forum_rules($mode, &$rules, &$forum_id) { - global $SID, $auth, $user, $phpEx; + global $SID, $auth, $user; $rules .= ( ( $auth->acl_get('f_post', $forum_id) ) ? $user->lang['Rules_post_can'] : $user->lang['Rules_post_cannot'] ) . '<br />'; $rules .= ( ( $auth->acl_get('f_reply', $forum_id) ) ? $user->lang['Rules_reply_can'] : $user->lang['Rules_reply_cannot'] ) . '<br />'; @@ -326,7 +326,7 @@ function language_select($default, $select_name = "language", $dirname="language { global $phpEx; - $dir = opendir($dirname); + $dir = @opendir($dirname); $user = array(); while ( $file = readdir($dir) ) @@ -338,10 +338,10 @@ function language_select($default, $select_name = "language", $dirname="language } } - closedir($dir); + @closedir($dir); - @asort($user); - @reset($user); + @asort($lang); + @reset($lang); $user_select = '<select name="' . $select_name . '">'; foreach ( $lang as $displayname => $filename ) @@ -431,7 +431,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat ); $message = $user->lang['No_longer_watching_' . $mode] . '<br /><br />' . sprintf($user->lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); - message_die(MESSAGE, $message); + trigger_error($message); } else { @@ -465,7 +465,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat ); $message = $user->lang['You_are_watching_' . $mode] . '<br /><br />' . sprintf($user->lang['Click_return_' . $mode], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&start=$start" . '">', '</a>'); - message_die(MESSAGE, $message); + trigger_error($message); } else { @@ -594,6 +594,146 @@ function redirect($location) exit; } +// Check to see if the username has been taken, or if it is disallowed. +// Also checks if it includes the " character, which we don't allow in usernames. +// Used for registering, changing names, and posting anonymously with a username +function validate_username($username) +{ + global $db, $user; + + $username = sql_quote($username); + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE LOWER(username) = '" . strtolower($username) . "'"; + $result = $db->sql_query($sql); + + if (($row = $db->sql_fetchrow($result)) && $row['username'] != $user->data['username']) + { + return $user->lang['Username_taken']; + } + + $sql = "SELECT group_name + FROM " . GROUPS_TABLE . " + WHERE LOWER(group_name) = '" . strtolower($username) . "'"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + return $user->lang['Username_taken']; + } + + $sql = "SELECT disallow_username + FROM " . DISALLOW_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (preg_match('#\b(' . str_replace('\*', '.*?', preg_quote($row['disallow_username'])) . ')\b#i', $username)) + { + return $user->lang['Username_disallowed']; + } + } + + $sql = "SELECT word + FROM " . WORDS_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (preg_match('#\b(' . str_replace('\*', '.*?', preg_quote($row['word'])) . ')\b#i', $username)) + { + return $user->lang['Username_disallowed']; + } + } + + // Don't allow " in username. + if (strstr($username, '"')) + { + return $user->lang['Username_invalid']; + } + + return false; +} + +// Check to see if email address is banned or already present in the DB +function validate_email($email) +{ + global $db, $user; + + if ($email != '') + { + if (preg_match('/^[a-z0-9\.\-_\+]+@[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)) + { + if (preg_match('/^' . str_replace('*', '.*?', $row['ban_email']) . '$/is', $email)) + { + return $user->lang['Email_banned']; + } + } + + $sql = "SELECT user_email + FROM " . USERS_TABLE . " + WHERE user_email = '" . sql_quote($email) . "'"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + return $user->lang['Email_taken']; + } + + return false; + } + } + + return $user->lang['Email_invalid']; +} + +// Does supplementary validation of optional profile fields. This +// expects common stuff like trim() and strip_tags() to have already +// been run. Params are passed by-ref, so we can set them to the empty +// string if they fail. +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. + if ( !preg_match('/^[0-9]+$/', $icq) ) + { + $icq = ''; + } + + // website has to start with http://, followed by something with length at least 3 that + // contains at least one dot. + if ( $website != '' ) + { + if ( !preg_match('#^http:\/\/#i', $website) ) + { + $website = 'http://' . $website; + } + + if ( !preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $website) ) + { + $website = ''; + } + } + + return; +} + // This is general replacement for die(), allows templated output in users (or default) // language, etc. $msg_code can be one of these constants: // @@ -602,7 +742,7 @@ function redirect($location) // -> ERROR : Use for any error, a simple page will be output function message_die($msg_code, $msg_text = '', $msg_title = '') { - global $db, $auth, $template, $board_config, $user, $nav_links; + global $db, $auth, $template, $config, $user, $nav_links; global $phpEx, $phpbb_root_path, $starttime; switch ( $msg_code ) @@ -667,7 +807,7 @@ function message_die($msg_code, $msg_text = '', $msg_title = '') // Error and message handler, call with trigger_error if reqd function msg_handler($errno, $msg_text, $errfile, $errline) { - global $db, $auth, $template, $board_config, $user, $nav_links; + global $db, $auth, $template, $config, $user, $nav_links; global $phpEx, $phpbb_root_path, $starttime; switch ( $errno ) @@ -696,7 +836,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo 'th { background-image: url(\'' . $phpbb_root_path . 'admin/images/cellpic3.gif\') }' . "\n"; echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'admin/images/cellpic1.gif\') }' . "\n"; echo '</style><title>' . $msg_title . '</title></head><body>'; - echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><img src="' . $phpbb_root_path . 'admin/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td><td width="100%" background="' . $phpbb_root_path . 'admin/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">General Error</span> </td></tr></table><br clear="all" /><table width="85%" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td><br clear="all" />' . $msg_text . '<hr />Please notify the board administrator or webmaster : <a href="mailto:' . $board_config['board_email'] . '">' . $board_config['board_email'] . '</a></td></tr></table><br clear="all" /></body></html>'; + echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><img src="' . $phpbb_root_path . 'admin/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td><td width="100%" background="' . $phpbb_root_path . 'admin/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">General Error</span> </td></tr></table><br clear="all" /><table width="85%" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td><br clear="all" />' . $msg_text . '<hr />Please notify the board administrator or webmaster : <a href="mailto:' . $config['board_email'] . '">' . $config['board_email'] . '</a></td></tr></table><br clear="all" /></body></html>'; exit; break; diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 97e65c25a1..b55fe6fcbd 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -413,14 +413,14 @@ function config_config($config = false) } } - $cache_str = "\$board_config = array(\n"; + $cache_str = "\$config = array(\n"; foreach ($config as $config_name => $config_value) { $cache_str .= "\t'$config_name' => " . ( ( is_numeric($config_value) ) ? $config_value : '"' . addslashes($config_value) . '"' ) . ",\n"; } $cache_str .= ");"; - config_cache_write('\$board_config = array\(.*?\);', $cache_str); + config_cache_write('\$config = array\(.*?\);', $cache_str); return $config; } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 74bb58eb0e..f78a1a431f 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -27,7 +27,7 @@ class parse_message function parse(&$message, $html, $bbcode, $uid, $url, $smilies) { - global $board_config, $db, $lang; + global $config, $db, $lang; $warn_msg = ''; @@ -44,13 +44,13 @@ class parse_message $message = preg_replace($match, $replace, $message); // Message length check - if ( !strlen($message) || ( $board_config['max_post_chars'] && strlen($message) > $board_config['max_post_chars'] ) ) + if ( !strlen($message) || ( $config['max_post_chars'] && strlen($message) > $config['max_post_chars'] ) ) { $warn_msg .= ( !strlen($message) ) ? $lang['Too_few_chars'] . '<br />' : $lang['Too_many_chars'] . '<br />'; } // Smiley check - if ( $board_config['max_post_smilies'] && $smilies ) + if ( $config['max_post_smilies'] && $smilies ) { $sql = "SELECT code FROM " . SMILIES_TABLE; @@ -64,7 +64,7 @@ class parse_message $match++; } - if ( $match > $board_config['max_post_smilies'] ) + if ( $match > $config['max_post_smilies'] ) { $warn_msg .= $lang['Too_many_smilies'] . '<br />'; break; @@ -92,13 +92,13 @@ class parse_message function html(&$message, $html) { - global $board_config, $lang; + global $config, $lang; if ( $html ) { // If $html is true then "allowed_tags" are converted back from entity // form, others remain - $allowed_tags = split(',', str_replace(' ', '', $board_config['allow_html_tags'])); + $allowed_tags = split(',', str_replace(' ', '', $config['allow_html_tags'])); $match = array(); $replace = array(); @@ -117,7 +117,7 @@ class parse_message function bbcode(&$message, $bbcode, $uid) { - global $board_config; + global $config; } @@ -126,18 +126,18 @@ class parse_message // into relative versions when the server/script path matches the link function magic_url(&$message, $url) { - global $board_config; + global $config; if ( $url ) { - $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; - $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; + $server_protocol = ( $config['cookie_secure'] ) ? 'https://' : 'http://'; + $server_port = ( $config['server_port'] <> 80 ) ? ':' . trim($config['server_port']) . '/' : '/'; $match = array(); $replace = array(); // relative urls for this board - $match[] = '#' . $server_protocol . trim($board_config['server_name']) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '\1', trim($board_config['script_path'])) . '/([^\t <\n\r\"]+)#i'; + $match[] = '#' . $server_protocol . trim($config['server_name']) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '\1', trim($config['script_path'])) . '/([^\t <\n\r\"]+)#i'; $replace[] = '<a href="\1" target="_blank">\1</a>'; // matches a xxxx://aaaaa.bbb.cccc. ... @@ -159,19 +159,9 @@ class parse_message // Based off of Acyd Burns Mod function attach($file_ary) { - global $board_config; - - $allowed_ext = explode(',', $board_config['attach_ext']); - } -} - -// Will parse poll info ... probably -class parse_poll extends parse_message -{ - function parse_poll() - { - global $board_config; + global $config; + $allowed_ext = explode(',', $config['attach_ext']); } } @@ -182,7 +172,7 @@ class fulltext_search { function split_words(&$text) { - global $user, $board_config; + global $user, $config; static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!', '*'); static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ', ' '); @@ -202,7 +192,7 @@ class fulltext_search $match[] = '#\[\/?url(=.*?)?\]#'; $match[] = '#\[\/?[a-z\*=\+\-]+(\:?[0-9a-z]+)?:[a-z0-9]{10,}(\:[a-z0-9]+)?=?.*?\]#'; // Sequences < min_search_chars & < max_search_chars - $match[] = '#\b([a-z0-9]{1,' . $board_config['min_search_chars'] . '}|[a-z0-9]{' . $board_config['max_search_chars'] . ',})\b#'; + $match[] = '#\b([a-z0-9]{1,' . $config['min_search_chars'] . '}|[a-z0-9]{' . $config['max_search_chars'] . ',})\b#'; $text = preg_replace($match, ' ', ' ' . strtolower($text) . ' '); @@ -237,33 +227,48 @@ class fulltext_search return array_unique($split_entries[1]); } - function add(&$post_id, &$new_msg, &$new_title, $old_msg = '', $old_title = '') + function add(&$mode, &$post_id, &$message, &$subject) { - global $board_config, $db; + global $config, $db; $mtime = explode(' ', microtime()); $starttime = $mtime[1] + $mtime[0]; - // // Split old and new post/subject to obtain array of 'words' - // - $split_text_new = $this->split_words($new_msg); - $split_text_old = $this->split_words(addslashes($old_msg)); - $split_title_new = ( $new_title ) ? $this->split_words($new_title) : array(); - $split_title_old = ( $old_title ) ? $this->split_words(addslashes($old_title)) : array(); + $split_text = $this->split_words($message); + $split_title = ($subject) ? $this->split_words($subject) : array(); - // - // Define new words to be added and old words to be removed - // $words = array(); - $words['add']['text'] = array_diff($split_text_new, $split_text_old); - $words['del']['text'] = array_diff($split_text_old, $split_text_new); - $words['add']['title'] = array_diff($split_title_new, $split_title_old); - $words['del']['title'] = array_diff($split_title_old, $split_title_new); + if ($mode == 'edit') + { + $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"; + $result = $db->sql_query($result); + + $cur_words = array(); + while ($row = $db->sql_fetchrow($result)) + { + $which = ($row['title_match']) ? 'title' : 'post'; + $cur_words[$which][$row['word_id']] = $row['word_text']; + } + $db->sql_freeresult($result); + + $words['add']['post'] = array_diff($split_text, $cur_words['post']); + $words['add']['title'] = array_diff($split_title, $cur_words['title']); + $words['del']['post'] = array_diff($cur_words['post'], $split_text); + $words['del']['title'] = array_diff($cur_words['title'], $split_title); + } + else + { + $words['add']['post'] = $split_text; + $words['add']['title'] = $split_title; + } + unset($split_text); + unset($split_title); - // // Get unique words from the above arrays - // $unique_add_words = array_unique(array_merge($words['add']['text'], $words['add']['title'])); // @@ -391,7 +396,7 @@ class fulltext_search echo "<br /><br />"; // Run the cleanup infrequently, once per session cleanup - if ( $board_config['session_last_gc'] < time - ( $board_config['session_gc'] / 2 ) ) + if ( $config['session_last_gc'] < time - ( $config['session_gc'] / 2 ) ) { $this->search_tidy(); } @@ -471,7 +476,7 @@ class fulltext_search // function generate_smilies($mode) { - global $SID, $auth, $db, $session, $board_config, $template, $theme, $lang; + global $SID, $auth, $db, $session, $config, $template, $theme, $lang; global $user_ip, $starttime; global $phpEx, $phpbb_root_path; global $user, $userdata; @@ -505,7 +510,7 @@ function generate_smilies($mode) { $template->assign_block_vars('emoticon', array( 'SMILEY_CODE' => $row['code'], - 'SMILEY_IMG' => $board_config['smilies_path'] . '/' . $row['smile_url'], + 'SMILEY_IMG' => $config['smilies_path'] . '/' . $row['smile_url'], 'SMILEY_WIDTH' => $row['smile_width'], 'SMILEY_HEIGHT' => $row['smile_height'], 'SMILEY_DESC' => $row['emoticon']) diff --git a/phpBB/includes/page_header.php b/phpBB/includes/page_header.php index b43c863f7c..88806b28b6 100644 --- a/phpBB/includes/page_header.php +++ b/phpBB/includes/page_header.php @@ -27,7 +27,7 @@ if ( !defined('IN_PHPBB') ) define('HEADER_INC', TRUE); // gzip_compression -if ( $board_config['gzip_compress'] ) +if ( $config['gzip_compress'] ) { if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() ) { @@ -137,10 +137,10 @@ else $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; -if ( $total_online_users > $board_config['record_online_users']) +if ( $total_online_users > $config['record_online_users']) { - $board_config['record_online_users'] = $total_online_users; - $board_config['record_online_date'] = time(); + $config['record_online_users'] = $total_online_users; + $config['record_online_date'] = time(); $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$total_online_users' @@ -148,7 +148,7 @@ if ( $total_online_users > $board_config['record_online_users']) $db->sql_query($sql); $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '" . $board_config['record_online_date'] . "' + SET config_value = '" . $config['record_online_date'] . "' WHERE config_name = 'record_online_date'"; $db->sql_query($sql); } @@ -279,14 +279,14 @@ foreach ( $nav_links as $nav_item => $nav_array ) // The following assigns all _common_ variables that may be used at any point // in a template. $template->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'SITE_DESCRIPTION' => $board_config['site_desc'], + 'SITENAME' => $config['sitename'], + 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'LAST_VISIT_DATE' => sprintf($user->lang['You_last_visit'], $s_last_visit), 'CURRENT_TIME' => sprintf($user->lang['Current_time'], $user->format_date(time())), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, - 'RECORD_USERS' => sprintf($user->lang['Record_online_users'], $board_config['record_online_users'], $user->format_date($board_config['record_online_date'])), + 'RECORD_USERS' => sprintf($user->lang['Record_online_users'], $config['record_online_users'], $user->format_date($config['record_online_date'])), 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, @@ -335,7 +335,7 @@ $template->assign_vars(array( 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], 'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID, - 'S_TIMEZONE' => ( $user->data['user_dst'] ) ? sprintf($user->lang['All_times'], $user->lang[floatval($board_config['board_timezone'])], $user->lang['tz']['dst']) : sprintf($user->lang['All_times'], $user->lang[floatval($board_config['board_timezone'])], ''), + 'S_TIMEZONE' => ( $user->data['user_dst'] ) ? sprintf($user->lang['All_times'], $user->lang[floatval($config['board_timezone'])], $user->lang['tz']['dst']) : sprintf($user->lang['All_times'], $user->lang[floatval($config['board_timezone'])], ''), 'T_STYLESHEET_DATA' => $user->theme['css_data'], 'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'], @@ -343,7 +343,7 @@ $template->assign_vars(array( 'NAV_LINKS' => $nav_links_html) ); -/*if ( $board_config['send_encoding'] ) +/*if ( $config['send_encoding'] ) { header ('Content-type: text/html; charset: ' . $user->lang['ENCODING']); }*/ diff --git a/phpBB/includes/page_tail.php b/phpBB/includes/page_tail.php index 67c99e3ed7..b39f540210 100644 --- a/phpBB/includes/page_tail.php +++ b/phpBB/includes/page_tail.php @@ -36,7 +36,7 @@ if (defined('DEBUG')) exit; } - $debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($session->load) ? $session->load : 'N/A'), $totaltime); + $debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($session->load) ? $session->load : 'N/A'), $totaltime); if ($auth->acl_get('a_')) { @@ -46,7 +46,7 @@ if (defined('DEBUG')) } $template->assign_vars(array( - 'PHPBB_VERSION' => $board_config['version'], + 'PHPBB_VERSION' => $config['version'], 'ADMIN_LINK' => ( $auth->acl_get('a_') ) ? '<a href="' . "admin/index.$phpEx?sid=" . $user->data['session_id'] . '">' . $user->lang['Admin_panel'] . '</a><br /><br />' : '', 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '' )); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 0a17b59a55..710432e162 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -31,17 +31,17 @@ class session // Called at each page start ... checks for, updates and/or creates a session function start($update = true) { - global $SID, $db, $board_config; + global $SID, $db, $config; $current_time = time(); $this->browser = ( !empty($_SERVER['HTTP_USER_AGENT']) ) ? $_SERVER['HTTP_USER_AGENT'] : $_ENV['HTTP_USER_AGENT']; $this->page = ( !empty($_SERVER['PHP_SELF']) ) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']; $this->page .= '&' . ( ( !empty($_SERVER['QUERY_STRING']) ) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING'] ); - if ( isset($_COOKIE[$board_config['cookie_name'] . '_sid']) || isset($_COOKIE[$board_config['cookie_name'] . '_data']) ) + if ( isset($_COOKIE[$config['cookie_name'] . '_sid']) || isset($_COOKIE[$config['cookie_name'] . '_data']) ) { - $sessiondata = ( isset($_COOKIE[$board_config['cookie_name'] . '_data']) ) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_data'])) : ''; - $this->session_id = ( isset($_COOKIE[$board_config['cookie_name'] . '_sid']) ) ? $_COOKIE[$board_config['cookie_name'] . '_sid'] : ''; + $sessiondata = ( isset($_COOKIE[$config['cookie_name'] . '_data']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_data'])) : ''; + $this->session_id = ( isset($_COOKIE[$config['cookie_name'] . '_sid']) ) ? $_COOKIE[$config['cookie_name'] . '_sid'] : ''; $SID = (defined('IN_ADMIN')) ? '?sid=' . $this->session_id : '?sid='; } else @@ -64,13 +64,13 @@ class session } // Load limit check (if applicable) - if ( intval($board_config['limit_load']) && file_exists('/proc/loadavg') ) + if ( intval($config['limit_load']) && file_exists('/proc/loadavg') ) { if ( $load = @file('/proc/loadavg') ) { list($this->load) = explode(' ', $load[0]); - if ( $this->load > intval($board_config['limit_load']) ) + if ( $this->load > intval($config['limit_load']) ) { trigger_error('Board_unavailable'); } @@ -93,8 +93,8 @@ class session if ( isset($this->data['user_id']) ) { // Validate IP length according to admin ... has no effect on IPv6 - $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $board_config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $board_config['ip_check'])); + $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check'])); + $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check'])); if ( $u_ip == $s_ip ) { @@ -123,12 +123,12 @@ class session // Create a new session function create(&$user_id, &$autologin) { - global $SID, $db, $board_config; + global $SID, $db, $config; $sessiondata = array(); $current_time = time(); - if ( intval($board_config['active_sessions']) ) + if ( intval($config['active_sessions']) ) { // Limit sessions in 1 minute period $sql = "SELECT COUNT(*) AS sessions @@ -139,7 +139,7 @@ class session $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ( intval($row['sessions']) > intval($board_config['active_sessions']) ) + if ( intval($row['sessions']) > intval($config['active_sessions']) ) { trigger_error('Board_unavailable'); } @@ -147,7 +147,7 @@ class session // Garbage collection ... remove old sessions updating user information // if necessary. It means (potentially) 22 queries but only infrequently - if ( $current_time - $board_config['session_gc'] > $board_config['session_last_gc'] ) + if ( $current_time - $config['session_gc'] > $config['session_last_gc'] ) { $this->gc($current_time); } @@ -236,7 +236,7 @@ class session // Destroy a session function destroy() { - global $SID, $db, $board_config; + global $SID, $db, $config; $current_time = time(); @@ -263,12 +263,12 @@ class session // Garbage collection function gc(&$current_time) { - global $db, $board_config; + global $db, $config; // Get expired sessions, only most recent for each user $sql = "SELECT session_user_id, MAX(session_time) AS recent_time FROM " . SESSIONS_TABLE . " - WHERE session_time < " . ( $current_time - $board_config['session_length'] ) . " + WHERE session_time < " . ( $current_time - $config['session_length'] ) . " GROUP BY session_user_id LIMIT 5"; $result = $db->sql_query($sql); @@ -294,7 +294,7 @@ class session // Delete expired sessions $sql = "DELETE FROM " . SESSIONS_TABLE . " WHERE session_user_id IN ($del_user_id) - AND session_time < " . ( $current_time - $board_config['session_length'] ); + AND session_time < " . ( $current_time - $config['session_length'] ); $db->sql_query($sql); } @@ -314,9 +314,9 @@ class session // Set a cookie function set_cookie($name, $cookiedata, $cookietime) { - global $board_config; + global $config; - setcookie($board_config['cookie_name'] . '_' . $name, $cookiedata, $cookietime, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + setcookie($config['cookie_name'] . '_' . $name, $cookiedata, $cookietime, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); } } @@ -336,11 +336,11 @@ class user extends session function setup($lang_set = false, $style = false) { - global $db, $template, $board_config, $phpEx, $phpbb_root_path; + global $db, $template, $config, $phpEx, $phpbb_root_path; if ( $this->data['user_id'] != ANONYMOUS ) { - $this->lang_name = ( file_exists($phpbb_root_path . 'language/' . $this->data['user_lang']) ) ? $this->data['user_lang'] : $board_config['default_lang']; + $this->lang_name = ( file_exists($phpbb_root_path . 'language/' . $this->data['user_lang']) ) ? $this->data['user_lang'] : $config['default_lang']; $this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/'; $this->date_format = $this->data['user_dateformat']; @@ -349,10 +349,10 @@ class user extends session } else { - $this->lang_name = $board_config['default_lang']; + $this->lang_name = $config['default_lang']; $this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/'; - $this->date_format = $board_config['default_dateformat']; - $this->timezone = $board_config['board_timezone'] * 3600; + $this->date_format = $config['default_dateformat']; + $this->timezone = $config['board_timezone'] * 3600; $this->dst = 0; if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) @@ -409,7 +409,7 @@ class user extends session } */ // Set up style - $style = ( $style ) ? $style : ( ( !$board_config['override_user_style'] && $this->data['user_id'] ) ? $this->data['user_style'] : $board_config['default_style'] ); + $style = ( $style ) ? $style : ( ( !$config['override_user_style'] && $this->data['user_id'] ) ? $this->data['user_style'] : $config['default_style'] ); $sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.* FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i @@ -426,7 +426,7 @@ class user extends session $template->set_template($this->theme['template_path']); - $this->img_lang = ( file_exists($phpbb_root_path . 'imagesets/' . $this->theme['imageset_path'] . '/' . $this->lang_name) ) ? $this->lang_name : $board_config['default_lang']; + $this->img_lang = ( file_exists($phpbb_root_path . 'imagesets/' . $this->theme['imageset_path'] . '/' . $this->lang_name) ) ? $this->lang_name : $config['default_lang']; return; } @@ -447,13 +447,14 @@ class user extends session return strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates); } - function img($img, $alt = '', $tag = false) + function img($img, $alt = '', $width = false, $no_cache = false) { static $imgs; - if (empty($imgs[$img])) + if (empty($imgs[$img]) || $no_cache) { - $imgs[$img] = '<img src=' . str_replace('{LANG}', $this->img_lang, $this->theme[$img]) . '" alt="' . $this->lang[$alt] . '" title="' . $this->lang[$alt] . '" />'; + $width = ( $width ) ? 'width="' . $width . '" ' : ''; + $imgs[$img] = '<img src=' . str_replace('{LANG}', $this->img_lang, $this->theme[$img]) . '" ' . $width . 'alt="' . $this->lang[$alt] . '" title="' . $this->lang[$alt] . '" />'; } return $imgs[$img]; @@ -657,9 +658,9 @@ class auth // Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him. function login($username, $password, $autologin = false) { - global $board_config, $user, $phpEx; + global $config, $user, $phpEx; - $method = trim($board_config['auth_method']); + $method = trim($config['auth_method']); if ( file_exists('includes/auth/auth_' . $method . '.' . $phpEx) ) { diff --git a/phpBB/includes/topic_review.php b/phpBB/includes/topic_review.php index 6fc0a79592..e9c8ccc88b 100644 --- a/phpBB/includes/topic_review.php +++ b/phpBB/includes/topic_review.php @@ -23,7 +23,7 @@ function topic_review($topic_id, $is_inline_review) { - global $SID, $session, $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path; + global $SID, $session, $db, $config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path; global $userdata, $user_ip; global $orig_word, $replacement_word; global $starttime; @@ -38,8 +38,8 @@ function topic_review($topic_id, $is_inline_review) // // Get topic info ... // - $sql = "SELECT t.topic_title, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments - FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f + $sql = "SELECT t.topic_title, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments + FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id"; if ( !($result = $db->sql_query($sql)) ) @@ -54,7 +54,7 @@ function topic_review($topic_id, $is_inline_review) $forum_id = $forum_row['forum_id']; $topic_title = $forum_row['topic_title']; - + // // Start session management // @@ -105,7 +105,7 @@ function topic_review($topic_id, $is_inline_review) AND p.poster_id = u.user_id AND p.post_id = pt.post_id ORDER BY p.post_time DESC - LIMIT " . $board_config['posts_per_page']; + LIMIT " . $config['posts_per_page']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql); @@ -126,7 +126,7 @@ function topic_review($topic_id, $is_inline_review) $poster_id = $row['user_id']; $poster = $row['username']; - $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']); + $post_date = create_date($config['default_dateformat'], $row['post_time'], $config['board_timezone']); // // Handle anon users posting with usernames @@ -146,14 +146,14 @@ function topic_review($topic_id, $is_inline_review) // If the board has HTML off but the post has HTML // on then we process it, else leave it alone // - if ( !$board_config['allow_html'] && $row['enable_html'] ) + if ( !$config['allow_html'] && $row['enable_html'] ) { $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $message); } if ( $bbcode_uid != '' ) { - $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); + $message = ( $config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); } $message = make_clickable($message); @@ -164,7 +164,7 @@ function topic_review($topic_id, $is_inline_review) $message = preg_replace($orig_word, $replacement_word, $message); } - if ( $board_config['allow_smilies'] && $row['enable_smilies'] ) + if ( $config['allow_smilies'] && $row['enable_smilies'] ) { $message = smilies_pass($message); } @@ -179,15 +179,15 @@ function topic_review($topic_id, $is_inline_review) $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('postrow', array( - 'ROW_COLOR' => '#' . $row_color, - 'ROW_CLASS' => $row_class, + 'ROW_COLOR' => '#' . $row_color, + 'ROW_CLASS' => $row_class, - 'MINI_POST_IMG' => $mini_post_img, - 'POSTER_NAME' => $poster, - 'POST_DATE' => $post_date, - 'POST_SUBJECT' => $post_subject, + 'MINI_POST_IMG' => $mini_post_img, + 'POSTER_NAME' => $poster, + 'POST_DATE' => $post_date, + 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, - + 'L_MINI_POST_ALT' => $mini_post_alt) ); @@ -204,7 +204,7 @@ function topic_review($topic_id, $is_inline_review) 'L_AUTHOR' => $lang['Author'], 'L_MESSAGE' => $lang['Message'], 'L_POSTED' => $lang['Posted'], - 'L_POST_SUBJECT' => $lang['Post_subject'], + 'L_POST_SUBJECT' => $lang['Post_subject'], 'L_TOPIC_REVIEW' => $lang['Topic_review']) ); diff --git a/phpBB/includes/usercp_activate.php b/phpBB/includes/usercp_activate.php index cb2a38b2ac..e823e4d211 100644 --- a/phpBB/includes/usercp_activate.php +++ b/phpBB/includes/usercp_activate.php @@ -26,7 +26,7 @@ if ( !defined('IN_PHPBB') ) exit; } -$sql = "SELECT user_active, user_id, user_email, user_newpasswd, user_lang, user_actkey +$sql = "SELECT user_active, user_id, user_email, user_newpasswd, user_lang, user_actkey FROM " . USERS_TABLE . " WHERE user_id = " . intval($HTTP_GET_VARS[POST_USERS_URL]); if ( !($result = $db->sql_query($sql)) ) @@ -49,19 +49,19 @@ if ( $row = $db->sql_fetchrow($result) ) $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : ''; $sql = "UPDATE " . USERS_TABLE . " - SET user_active = 1, user_actkey = ''" . $sql_update_pass . " - WHERE user_id = " . $row['user_id']; + SET user_active = 1, user_actkey = ''" . $sql_update_pass . " + WHERE user_id = " . $row['user_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update); } - if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '' ) + if ( $config['require_activation'] == USER_ACTIVATION_ADMIN && $sql_update_pass == '' ) { include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\n"; $emailer->use_template('admin_welcome_activated', $row['user_lang']); $emailer->email_address($row['user_email']); @@ -69,10 +69,10 @@ if ( $row = $db->sql_fetchrow($result) ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'USERNAME' => $username, 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig'])) + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig'])) ); $emailer->send(); $emailer->reset(); @@ -89,7 +89,7 @@ if ( $row = $db->sql_fetchrow($result) ) 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">') ); - $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated']; + $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated']; message_die(GENERAL_MESSAGE, $message); } } diff --git a/phpBB/includes/usercp_avatar.php b/phpBB/includes/usercp_avatar.php index f8042dc62f..c7321d758c 100644 --- a/phpBB/includes/usercp_avatar.php +++ b/phpBB/includes/usercp_avatar.php @@ -49,13 +49,13 @@ function check_image_type(&$type, &$error, &$error_msg) function user_avatar_delete($avatar_type, $avatar_file) { - global $board_config, $userdata; + global $config, $userdata; if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' ) { - if ( @file_exists('./' . $board_config['avatar_path'] . '/' . $avatar_file) ) + if ( @file_exists('./' . $config['avatar_path'] . '/' . $avatar_file) ) { - @unlink('./' . $board_config['avatar_path'] . '/' . $avatar_file); + @unlink('./' . $config['avatar_path'] . '/' . $avatar_file); } } @@ -87,7 +87,7 @@ function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename) function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype) { - global $board_config, $user_ip, $db, $lang; + global $config, $user_ip, $db, $lang; $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; @@ -117,7 +117,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ unset($avatar_data); while( !@feof($fsock) ) { - $avatar_data .= @fread($fsock, $board_config['avatar_filesize']); + $avatar_data .= @fread($fsock, $config['avatar_filesize']); } @fclose($fsock); @@ -131,11 +131,11 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ $avatar_filesize = $file_data1[1]; $avatar_filetype = $file_data2[1]; - if ( !$error && $avatar_filesize > 0 && $avatar_filesize < $board_config['avatar_filesize'] ) + if ( !$error && $avatar_filesize > 0 && $avatar_filesize < $config['avatar_filesize'] ) { $avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize); - $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['avatar_path'] . '/tmp'; + $tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $config['avatar_path'] . '/tmp'; $tmp_filename = tempnam($tmp_path, uniqid($user_ip) . '-'); $fptr = @fopen($tmp_filename, 'wb'); @@ -152,7 +152,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ } else { - $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024)); + $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); $error = true; $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size; @@ -160,14 +160,14 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ } else if ( $avatar_mode == 'local' && file_exists($avatar_filename) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) ) { - if ( $avatar_filesize <= $board_config['avatar_filesize'] && $avatar_filesize > 0 ) + if ( $avatar_filesize <= $config['avatar_filesize'] && $avatar_filesize > 0 ) { preg_match('#image\/[x\-]*([a-z]+)#', $avatar_filetype, $avatar_filetype); $avatar_filetype = $avatar_filetype[1]; } else { - $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024)); + $l_avatar_size = sprintf($lang['Avatar_filesize'], round($config['avatar_filesize'] / 1024)); $error = true; $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size; @@ -182,21 +182,21 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ return; } - if ( $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] ) + if ( $width <= $config['avatar_max_width'] && $height <= $config['avatar_max_height'] ) { $new_filename = uniqid() . $imgtype; if ( $mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' ) { - if ( file_exists('./' . $board_config['avatar_path'] . '/' . $current_avatar) ) + if ( file_exists('./' . $config['avatar_path'] . '/' . $current_avatar) ) { - @unlink('./' . $board_config['avatar_path'] . '/' . $current_avatar); + @unlink('./' . $config['avatar_path'] . '/' . $current_avatar); } } if( $avatar_mode == 'remote' ) { - @copy($tmp_filename, './' . $board_config['avatar_path'] . "/$new_filename"); + @copy($tmp_filename, './' . $config['avatar_path'] . "/$new_filename"); @unlink($tmp_filename); } else @@ -215,16 +215,16 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ $move_file = 'copy'; } - $move_file($avatar_filename, './' . $board_config['avatar_path'] . "/$new_filename"); + $move_file($avatar_filename, './' . $config['avatar_path'] . "/$new_filename"); } - @chmod('./' . $board_config['avatar_path'] . "/$new_filename", 0777); + @chmod('./' . $config['avatar_path'] . "/$new_filename", 0777); $avatar_sql = ( $mode == 'editprofile' ) ? ", user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD : "'$new_filename', " . USER_AVATAR_UPLOAD; } else { - $l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']); + $l_avatar_size = sprintf($lang['Avatar_imagesize'], $config['avatar_max_width'], $config['avatar_max_height']); $error = true; $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size; @@ -235,17 +235,17 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) { - global $board_config, $db, $template, $lang, $images, $theme; + global $config, $db, $template, $lang, $images, $theme; global $phpbb_root_path, $phpEx; - $dir = @opendir($board_config['avatar_gallery_path']); + $dir = @opendir($config['avatar_gallery_path']); $avatar_images = array(); while( $file = @readdir($dir) ) { - if( $file != '.' && $file != '..' && !is_file($board_config['avatar_gallery_path'] . '/' . $file) && !is_link($board_config['avatar_gallery_path'] . '/' . $file) ) + if( $file != '.' && $file != '..' && !is_file($config['avatar_gallery_path'] . '/' . $file) && !is_link($config['avatar_gallery_path'] . '/' . $file) ) { - $sub_dir = @opendir($board_config['avatar_gallery_path'] . '/' . $file); + $sub_dir = @opendir($config['avatar_gallery_path'] . '/' . $file); $avatar_row_count = 0; $avatar_col_count = 0; @@ -299,7 +299,7 @@ function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current for($j = 0; $j < count($avatar_images[$category][$i]); $j++) { $template->assign_block_vars('avatar_row.avatar_column', array( - "AVATAR_IMAGE" => $board_config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j], + "AVATAR_IMAGE" => $config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j], "AVATAR_NAME" => $avatar_name[$category][$i][$j]) ); diff --git a/phpBB/includes/usercp_email.php b/phpBB/includes/usercp_email.php index 5038a9024d..64f750c09c 100644 --- a/phpBB/includes/usercp_email.php +++ b/phpBB/includes/usercp_email.php @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * usercp_email.php + * usercp_email.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group @@ -40,20 +40,20 @@ if ( $userdata['user_id'] == ANONYMOUS ) exit; } -$sql = "SELECT username, user_email, user_viewemail, user_lang - FROM " . USERS_TABLE . " +$sql = "SELECT username, user_email, user_viewemail, user_lang + FROM " . USERS_TABLE . " WHERE user_id = $user_id"; $result = $db->sql_query($sql); if ( $row = $db->sql_fetchrow($result) ) { $username = $row['username']; - $user_email = $row['user_email']; + $user_email = $row['user_email']; $user_lang = $row['user_lang']; if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN ) { - if ( time() - $userdata['user_emailtime'] < $board_config['flood_interval'] ) + if ( time() - $userdata['user_emailtime'] < $config['flood_interval'] ) { message_die(MESSAGE, $lang['Flood_email_limit']); } @@ -84,13 +84,13 @@ if ( $row = $db->sql_fetchrow($result) ) if ( !$error ) { - $sql = "UPDATE " . USERS_TABLE . " - SET user_emailtime = " . time() . " + $sql = "UPDATE " . USERS_TABLE . " + SET user_emailtime = " . time() . " WHERE user_id = " . $userdata['user_id']; $result = $db->sql_query($sql); - + include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); $email_headers = 'From: ' . $userdata['user_email'] . "\n"; if ( !empty($HTTP_POST_VARS['cc_email']) ) @@ -109,10 +109,10 @@ if ( $row = $db->sql_fetchrow($result) ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'BOARD_EMAIL' => $board_config['board_email'], - 'FROM_USERNAME' => $userdata['username'], - 'TO_USERNAME' => $username, + 'SITENAME' => $config['sitename'], + 'BOARD_EMAIL' => $config['board_email'], + 'FROM_USERNAME' => $userdata['username'], + 'TO_USERNAME' => $username, 'MESSAGE' => $message) ); $emailer->send(); @@ -149,17 +149,17 @@ if ( $row = $db->sql_fetchrow($result) ) $template->assign_vars(array( 'USERNAME' => $username, - 'S_POST_ACTION' => "profile.$phpEx$SID&mode=email&u=$user_id", + 'S_POST_ACTION' => "profile.$phpEx$SID&mode=email&u=$user_id", - 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], - 'L_RECIPIENT' => $lang['Recipient'], + 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], + 'L_RECIPIENT' => $lang['Recipient'], 'L_SUBJECT' => $lang['Subject'], - 'L_MESSAGE_BODY' => $lang['Message_body'], - 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], + 'L_MESSAGE_BODY' => $lang['Message_body'], + 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], 'L_OPTIONS' => $lang['Options'], - 'L_CC_EMAIL' => $lang['CC_email'], + 'L_CC_EMAIL' => $lang['CC_email'], 'L_SPELLCHECK' => $lang['Spellcheck'], 'L_SEND_EMAIL' => $lang['Send_email']) ); diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index ac241695e7..e443f37e59 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -50,18 +50,26 @@ function show_coppa() "U_AGREE_UNDER13" => "profile.$phpEx$SID&mode=register&agreed=true&coppa=true") ); } +// +// --------------------------------------- -function update_user($mode) -{ -} // -// --------------------------------------- +// +// +if ($mode == 'register' && $config['require_activation'] == USER_ACTIVATION_DISABLE) +{ + trigger_error($user->lang['Cannot_register']); +} + +// +// +// $error = FALSE; -$page_title = ( $mode == 'editprofile' ) ? $user->lang['Edit_profile'] : $user->lang['Register']; +$page_title = ($mode == 'editprofile') ? $user->lang['Edit_profile'] : $user->lang['Register']; -if ( $mode == 'register' && !isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GET_VARS['agreed']) ) +if ($mode == 'register' && !isset($_POST['agreed']) && !isset($_GET['agreed']) && $config['enable_coppa']) { include($phpbb_root_path . 'includes/page_header.'.$phpEx); @@ -70,45 +78,36 @@ if ( $mode == 'register' && !isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GE include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } -$coppa = ( empty($HTTP_POST_VARS['coppa']) && empty($HTTP_GET_VARS['coppa']) ) ? 0 : TRUE; +$coppa = ( empty($_POST['coppa']) && empty($_GET['coppa']) ) ? 0 : TRUE; // // Check and initialize some variables if needed // -if ( - isset($HTTP_POST_VARS['submit']) || - isset($HTTP_POST_VARS['avatargallery']) || - isset($HTTP_POST_VARS['submitavatar']) || - isset($HTTP_POST_VARS['cancelavatar']) || - $mode == 'register' ) +if (isset($_POST['submit']) || $mode == 'register') { - include($phpbb_root_path . 'includes/functions_validate.'.$phpEx); - include($phpbb_root_path . 'includes/bbcode.'.$phpEx); - include($phpbb_root_path . 'includes/functions_posting.'.$phpEx); - - if ( $mode == 'editprofile' ) + if ($mode == 'editprofile') { - $user_id = intval($HTTP_POST_VARS['user_id']); - $current_email = trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['current_email']))); + $user_id = intval($_POST['user_id']); + $current_email = trim(strip_tags(htmlspecialchars($_POST['current_email']))); } $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests'); - while( list($var, $param) = @each($strip_var_list) ) + foreach ($strip_var_list as $var => $param) { - if ( !empty($HTTP_POST_VARS[$param]) ) + if ( !empty($_POST[$param]) ) { - $$var = trim(strip_tags($HTTP_POST_VARS[$param])); + $$var = trim(strip_tags($_POST[$param])); } } $trim_var_list = array('password_current' => 'cur_password', 'password' => 'new_password', 'password_confirm' => 'password_confirm', 'signature' => 'signature'); - while( list($var, $param) = @each($trim_var_list) ) + foreach ($strip_var_list as $var => $param) { - if ( !empty($HTTP_POST_VARS[$param]) ) + if ( !empty($_POST[$param]) ) { - $$var = trim($HTTP_POST_VARS[$param]); + $$var = trim($_POST[$param]); } } @@ -120,36 +119,36 @@ if ( // empty strings if they fail. validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature); - $viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0; - $allowviewonline = ( isset($HTTP_POST_VARS['hideonline']) ) ? ( ($HTTP_POST_VARS['hideonline']) ? 0 : TRUE ) : TRUE; - $notifyreply = ( isset($HTTP_POST_VARS['notifyreply']) ) ? ( ($HTTP_POST_VARS['notifyreply']) ? TRUE : 0 ) : 0; - $notifypm = ( isset($HTTP_POST_VARS['notifypm']) ) ? ( ($HTTP_POST_VARS['notifypm']) ? TRUE : 0 ) : TRUE; - $popuppm = ( isset($HTTP_POST_VARS['popup_pm']) ) ? ( ($HTTP_POST_VARS['popup_pm']) ? TRUE : 0 ) : TRUE; + $viewemail = ( isset($_POST['viewemail']) ) ? ( ($_POST['viewemail']) ? TRUE : 0 ) : 0; + $allowviewonline = ( isset($_POST['hideonline']) ) ? ( ($_POST['hideonline']) ? 0 : TRUE ) : TRUE; + $notifyreply = ( isset($_POST['notifyreply']) ) ? ( ($_POST['notifyreply']) ? TRUE : 0 ) : 0; + $notifypm = ( isset($_POST['notifypm']) ) ? ( ($_POST['notifypm']) ? TRUE : 0 ) : TRUE; + $popuppm = ( isset($_POST['popup_pm']) ) ? ( ($_POST['popup_pm']) ? TRUE : 0 ) : TRUE; if ( $mode == 'register' ) { - $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : $board_config['allow_sig']; + $attachsig = ( isset($_POST['attachsig']) ) ? ( ($_POST['attachsig']) ? TRUE : 0 ) : $config['allow_sig']; - $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $board_config['allow_html']; - $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $board_config['allow_bbcode']; - $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $board_config['allow_smilies']; + $allowhtml = ( isset($_POST['allowhtml']) ) ? ( ($_POST['allowhtml']) ? TRUE : 0 ) : $config['allow_html']; + $allowbbcode = ( isset($_POST['allowbbcode']) ) ? ( ($_POST['allowbbcode']) ? TRUE : 0 ) : $config['allow_bbcode']; + $allowsmilies = ( isset($_POST['allowsmilies']) ) ? ( ($_POST['allowsmilies']) ? TRUE : 0 ) : $config['allow_smilies']; } else { - $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : 0; + $attachsig = ( isset($_POST['attachsig']) ) ? ( ($_POST['attachsig']) ? TRUE : 0 ) : 0; - $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $userdata['user_allowhtml']; - $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $userdata['user_allowbbcode']; - $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $userdata['user_allowsmiles']; + $allowhtml = ( isset($_POST['allowhtml']) ) ? ( ($_POST['allowhtml']) ? TRUE : 0 ) : $user->data['user_allowhtml']; + $allowbbcode = ( isset($_POST['allowbbcode']) ) ? ( ($_POST['allowbbcode']) ? TRUE : 0 ) : $user->data['user_allowbbcode']; + $allowsmilies = ( isset($_POST['allowsmilies']) ) ? ( ($_POST['allowsmilies']) ? TRUE : 0 ) : $user->data['user_allowsmiles']; } - $user_style = ( isset($HTTP_POST_VARS['style']) ) ? intval($HTTP_POST_VARS['style']) : $board_config['default_style']; + $user_style = ( isset($_POST['style']) ) ? intval($_POST['style']) : $config['default_style']; - if ( !empty($HTTP_POST_VARS['language']) ) + if ( !empty($_POST['language']) ) { - if ( preg_match('/^[a-z_]+$/i', $HTTP_POST_VARS['language']) ) + if ( preg_match('/^[a-z_]+$/i', $_POST['language']) ) { - $user_lang = $HTTP_POST_VARS['language']; + $user_lang = $_POST['language']; } else { @@ -159,63 +158,23 @@ if ( } else { - $user_lang = $board_config['default_lang']; + $user_lang = $config['default_lang']; } - $user_timezone = ( isset($HTTP_POST_VARS['timezone']) ) ? doubleval($HTTP_POST_VARS['timezone']) : $board_config['board_timezone']; - $user_dateformat = ( !empty($HTTP_POST_VARS['dateformat']) ) ? trim($HTTP_POST_VARS['dateformat']) : $board_config['default_dateformat']; - - $user_avatar_local = ( isset($HTTP_POST_VARS['avatarselect']) && !empty($HTTP_POST_VARS['submitavatar']) && $board_config['allow_avatar_local'] ) ? $HTTP_POST_VARS['avatarselect'] : ( ( isset($HTTP_POST_VARS['avatarlocal']) ) ? $HTTP_POST_VARS['avatarlocal'] : '' ); - - $user_avatar_remoteurl = ( !empty($HTTP_POST_VARS['avatarremoteurl']) ) ? trim($HTTP_POST_VARS['avatarremoteurl']) : ''; - $user_avatar_upload = ( !empty($HTTP_POST_VARS['avatarurl']) ) ? trim($HTTP_POST_VARS['avatarurl']) : ( ( $HTTP_POST_FILES['avatar']['tmp_name'] != "none") ? $HTTP_POST_FILES['avatar']['tmp_name'] : '' ); - $user_avatar_name = ( !empty($HTTP_POST_FILES['avatar']['name']) ) ? $HTTP_POST_FILES['avatar']['name'] : ''; - $user_avatar_size = ( !empty($HTTP_POST_FILES['avatar']['size']) ) ? $HTTP_POST_FILES['avatar']['size'] : 0; - $user_avatar_filetype = ( !empty($HTTP_POST_FILES['avatar']['type']) ) ? $HTTP_POST_FILES['avatar']['type'] : ''; - - $user_avatar = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar'] : ''; - $user_avatar_type = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar_type'] : ''; + $user_timezone = ( isset($_POST['timezone']) ) ? doubleval($_POST['timezone']) : $config['board_timezone']; + $user_dateformat = ( !empty($_POST['dateformat']) ) ? trim($_POST['dateformat']) : $config['default_dateformat']; - if ( isset($HTTP_POST_VARS['avatargallery']) || isset($HTTP_POST_VARS['submitavatar']) || isset($HTTP_POST_VARS['cancelavatar']) ) - { - $username = stripslashes($username); - $email = stripslashes($email); - $password = ''; - $password_confirm = ''; - - $icq = stripslashes($icq); - $aim = stripslashes($aim); - $msn = stripslashes($msn); - $yim = stripslashes($yim); - - $website = stripslashes($website); - $location = stripslashes($location); - $occupation = stripslashes($occupation); - $interests = stripslashes($interests); - $signature = stripslashes($signature); - - $user_lang = stripslashes($user_lang); - $user_dateformat = stripslashes($user_dateformat); - - if ( !isset($HTTP_POST_VARS['cancelavatar'])) - { - $user_avatar = $user_avatar_local; - $user_avatar_type = USER_AVATAR_GALLERY; - } - } } // // Did the user submit? In this case build a query to update the users profile in the DB // -if ( isset($HTTP_POST_VARS['submit']) ) +if (isset($_POST['submit'])) { - include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx); - $passwd_sql = ''; if ( $mode == 'editprofile' ) { - if ( $user_id != $userdata['user_id'] ) + if ( $user_id != $user->data['user_id'] ) { $error = TRUE; $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Wrong_Profile']; @@ -251,10 +210,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) $sql = "SELECT user_password FROM " . USERS_TABLE . " WHERE user_id = $user_id"; - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql); - } + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); @@ -279,21 +235,20 @@ if ( isset($HTTP_POST_VARS['submit']) ) } else { - $password = $userdata['user_password']; + $password = $user->data['user_password']; } // // Do a ban check on this email address // - if ( $email != $userdata['user_email'] || $mode == 'register' ) + if ( $email != $user->data['user_email'] || $mode == 'register' ) { - $result = validate_email($email); - if ( $result['error'] ) + if (($result = validate_email($email)) != false) { - $email = $userdata['user_email']; + $email = $user->data['user_email']; $error = TRUE; - $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg']; + $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result; } if ( $mode == 'editprofile' ) @@ -301,16 +256,13 @@ if ( isset($HTTP_POST_VARS['submit']) ) $sql = "SELECT user_password FROM " . USERS_TABLE . " WHERE user_id = $user_id"; - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql); - } + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if ( $row['user_password'] != md5($password_current) ) { - $email = $userdata['user_email']; + $email = $user->data['user_email']; $error = TRUE; $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Current_password_mismatch']; @@ -319,31 +271,30 @@ if ( isset($HTTP_POST_VARS['submit']) ) } $username_sql = ''; - if ( $board_config['allow_namechange'] || $mode == 'register' ) + if ( $config['allow_namechange'] || $mode == 'register' ) { if ( empty($username) ) { $error = TRUE; $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Username_disallowed']; } - else if ( $username != $userdata['username'] || $mode == 'register' ) + else if ( $username != $user->data['username'] || $mode == 'register' ) { - $result = validate_username($username); - if ( $result['error'] ) + if (($result = validate_username($username)) != false) { $error = TRUE; - $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg']; + $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result; } else { - $username_sql = "username = '" . str_replace("\'", "''", $username) . "', "; + $username_sql = "username = '" . sql_quote($username) . "', "; } } } if ( $signature != '' ) { - if ( strlen($signature) > $board_config['max_sig_chars'] ) + if ( strlen($signature) > $config['max_sig_chars'] ) { $error = TRUE; $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $user->lang['Signature_too_long']; @@ -351,46 +302,14 @@ if ( isset($HTTP_POST_VARS['submit']) ) if ( $signature_bbcode_uid == '' ) { - $signature_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : ''; +// $signature_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : ''; } - $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid); - } - - if ( isset($HTTP_POST_VARS['avatardel']) && $mode == 'editprofile' ) - { - $avatar_sql = user_avatar_delete($userdata['avatar_type'], $userdata['avatar_file']); - } - else if ( ( !empty($user_avatar_upload) || !empty($user_avatar_name) ) && $board_config['allow_avatar_upload'] ) - { - if ( !empty($user_avatar_upload) ) - { - $avatar_mode = ( !empty($user_avatar_name) ) ? 'local' : 'remote'; - $avatar_sql = user_avatar_upload($mode, $avatar_mode, $userdata['user_avatar'], $userdata['user_avatar_type'], $error, $error_msg, $user_avatar_upload, $user_avatar_name, $user_avatar_size, $user_avatar_filetype); - } - else if ( !empty($user_avatar_name) ) - { - $l_avatar_size = sprintf($user->lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024)); - - $error = true; - $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $l_avatar_size; - } - } - else if ( $user_avatar_remoteurl != '' && $board_config['allow_avatar_remote'] ) - { - $avatar_sql = user_avatar_url($mode, $error, $error_msg, $user_avatar_remoteurl); - } - else if ( $user_avatar_local != '' && $board_config['allow_avatar_local'] ) - { - $avatar_sql = user_avatar_gallery($mode, $error, $error_msg, $user_avatar_local); - } - else - { - $avatar_sql = array('data' => '', 'type' => USER_AVATAR_NONE); +// $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid); } if ( !$error ) { - if ( ( ( $mode == 'editprofile' && $userdata['user_level'] != ADMIN && $email != $current_email ) || ( $mode == 'register' || $coppa ) ) && ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) ) + if ( ( ( $mode == 'editprofile' && $auth->acl_get('a_') && $email != $current_email ) || ( $mode == 'register' || $coppa ) ) && ( $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN ) ) { $user_actkey = gen_rand_string(true); $key_len = 54 - (strlen($server_url)); @@ -399,9 +318,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) $user_actkey = substr($user_actkey, 0, $key_len); $user_active = 0; - if ( $userdata['user_id'] != ANONYMOUS ) + if ( $user->data['user_id'] != ANONYMOUS ) { - session_end($userdata['session_id'], $userdata['user_id']); + $user->destroy(); } } else @@ -446,12 +365,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) 'user_actkey' => $user_actkey ); - if ( $mode == 'editprofile' ) + if ($mode == 'editprofile') { - if ( !($result = $db->sql_query_array('UPDATE ' . USERS_TABLE . ' SET WHERE user_id = ' . $user_id, &$sql_ary, BEGIN_TRANSACTION)) ) - { - message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql); - } + $db->sql_query_array('UPDATE ' . USERS_TABLE . ' SET WHERE user_id = ' . $user_id, &$sql_ary); if ( !$user_active ) { @@ -459,9 +375,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) // The users account has been deactivated, send them an email with a new activation key // include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = "From: " . $board_config['board_email'] . "\r\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = "From: " . $config['board_email'] . "\r\nReturn-Path: " . $config['board_email'] . "\r\n"; $emailer->use_template('user_activate', stripslashes($user_lang)); $emailer->email_address($email); @@ -469,9 +385,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'USERNAME' => $username, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) ); @@ -488,61 +404,51 @@ if ( isset($HTTP_POST_VARS['submit']) ) $template->assign_vars(array( "META" => '<meta http-equiv="refresh" content="5;url=' . "index.$phpEx$SID" . '">') ); - - message_die(GENERAL_MESSAGE, $message); + trigger_error($message); } else { - if ( !($result = $db->sql_query_array('INSERT INTO ' . USERS_TABLE, &$sql_ary, BEGIN_TRANSACTION)) ) - { - message_die(GENERAL_ERROR, 'Could not insert data into users table', '', __LINE__, __FILE__, $sql); - } + $db->sql_transaction(); - $user_id = $db->sql_nextid(); + $db->sql_query_array('INSERT INTO ' . USERS_TABLE, &$sql_ary); - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator) - VALUES ('', 'Personal User', 1, 0)"; - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql); - } + $user_id = $db->sql_nextid(); - $group_id = $db->sql_nextid(); + // Place into appropriate group, either REGISTERED or INACTIVE depending on config + $group_name = ( $config['require_activation'] == USER_ACTIVATION_NONE ) ? 'REGISTERED' : 'REGISTERED_INACTIVE'; + $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) SELECT $user_id, group_id, 0 FROM " . GROUPS_TABLE . " WHERE group_name = '$group_name'"; + $result = $db->sql_query($sql); - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) - VALUES ($user_id, $group_id, 0)"; - if( !($result = $db->sql_query($sql)) ) + if ($config['require_activation'] == USER_ACTIVATION_NONE) { - message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql); + // Sync config + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = $user_id + WHERE config_name = 'newest_user_id'"; + $db->sql_query($sql); + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$username' + WHERE config_name = 'newest_username'"; + $db->sql_query($sql); + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = " . ($config['num_users'] + 1) . " + WHERE config_name = 'num_users'"; + $db->sql_query($sql); } - $user_update_id = "UPDATE " . CONFIG_TABLE . " - SET config_value = $user_id - WHERE config_name = 'newest_user_id'"; - $user_update_name = "UPDATE " . CONFIG_TABLE . " - SET config_value = '$username' - WHERE config_name = 'newest_username'"; - $user_update_count = "UPDATE " . CONFIG_TABLE . " - SET config_value = " . ($board_config['num_users'] + 1) . " - WHERE config_name = 'num_users'"; - if( !$db->sql_query($user_update_id) || - !$db->sql_query($user_update_name) || - !$db->sql_query($user_update_count, END_TRANSACTION) ) - { - message_die(GENERAL_ERROR, 'Could not update user count information!', '', __LINE__, __FILE__); - } + $db->sql_transaction('commit'); if ( $coppa ) { $message = $user->lang['COPPA']; $email_template = 'coppa_welcome_inactive'; } - else if ( $board_config['require_activation'] == USER_ACTIVATION_SELF ) + else if ( $config['require_activation'] == USER_ACTIVATION_SELF ) { $message = $user->lang['Account_inactive']; $email_template = 'user_welcome_inactive'; } - else if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) + else if ( $config['require_activation'] == USER_ACTIVATION_ADMIN ) { $message = $user->lang['Account_inactive_admin']; $email_template = 'admin_welcome_inactive'; @@ -554,28 +460,28 @@ if ( isset($HTTP_POST_VARS['submit']) ) } include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = "From: " . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; $emailer->use_template($email_template, stripslashes($user_lang)); $emailer->email_address($email); - $emailer->set_subject();//sprintf($user->lang['Welcome_subject'], $board_config['sitename']) + $emailer->set_subject();//sprintf($user->lang['Welcome_subject'], $config['sitename']) $emailer->extra_headers($email_headers); - if( $coppa ) + if ($coppa) { $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $board_config['sitename']), + 'SITENAME' => $config['sitename'], + 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), 'USERNAME' => $username, 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey, - 'FAX_INFO' => $board_config['coppa_fax'], - 'MAIL_INFO' => $board_config['coppa_mail'], + 'FAX_INFO' => $config['coppa_fax'], + 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $email, 'ICQ' => $icq, 'AIM' => $aim, @@ -585,16 +491,16 @@ if ( isset($HTTP_POST_VARS['submit']) ) 'FROM' => $location, 'OCC' => $occupation, 'INTERESTS' => $interests, - 'SITENAME' => $board_config['sitename'])); + 'SITENAME' => $config['sitename'])); } else { $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $board_config['sitename']), + 'SITENAME' => $config['sitename'], + 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']), 'USERNAME' => $username, 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) ); @@ -603,16 +509,16 @@ if ( isset($HTTP_POST_VARS['submit']) ) $emailer->send(); $emailer->reset(); - if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) + if ( $config['require_activation'] == USER_ACTIVATION_ADMIN ) { $emailer->use_template("admin_activate", stripslashes($user_lang)); - $emailer->email_address($board_config['board_email']); + $emailer->email_address($config['board_email']); $emailer->set_subject(); //$user->lang['New_account_subject'] $emailer->extra_headers($email_headers); $emailer->assign_vars(array( 'USERNAME' => $username, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey) ); @@ -651,79 +557,57 @@ if ( $error ) $user_lang = stripslashes($user_lang); $user_dateformat = stripslashes($user_dateformat); - } -else if ( $mode == 'editprofile' && !isset($HTTP_POST_VARS['avatargallery']) && !isset($HTTP_POST_VARS['submitavatar']) && !isset($HTTP_POST_VARS['cancelavatar']) ) +else if ( $mode == 'editprofile' ) { - $user_id = $userdata['user_id']; - $username = htmlspecialchars($userdata['username']); - $email = $userdata['user_email']; + $user_id = $user->data['user_id']; + $username = htmlspecialchars($user->data['username']); + $email = $user->data['user_email']; $password = ''; $password_confirm = ''; - $icq = $userdata['user_icq']; - $aim = htmlspecialchars(str_replace('+', ' ', $userdata['user_aim'])); - $msn = htmlspecialchars($userdata['user_msnm']); - $yim = htmlspecialchars($userdata['user_yim']); - - $website = htmlspecialchars($userdata['user_website']); - $location = htmlspecialchars($userdata['user_from']); - $occupation = htmlspecialchars($userdata['user_occ']); - $interests = htmlspecialchars($userdata['user_interests']); - $signature_bbcode_uid = $userdata['user_sig_bbcode_uid']; - $signature = ( $signature_bbcode_uid != '' ) ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $userdata['user_sig']) : $userdata['user_sig']; - - $viewemail = $userdata['user_viewemail']; - $notifypm = $userdata['user_notify_pm']; - $popuppm = $userdata['user_popup_pm']; - $notifyreply = $userdata['user_notify']; - $attachsig = $userdata['user_attachsig']; - $allowhtml = $userdata['user_allowhtml']; - $allowbbcode = $userdata['user_allowbbcode']; - $allowsmilies = $userdata['user_allowsmile']; - $allowviewonline = $userdata['user_allow_viewonline']; - - $user_avatar = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar'] : ''; - $user_avatar_type = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar_type'] : USER_AVATAR_NONE; - - $user_style = $userdata['user_style']; - $user_lang = $userdata['user_lang']; - $user_timezone = $userdata['user_timezone']; - $user_dateformat = $userdata['user_dateformat']; + $icq = $user->data['user_icq']; + $aim = htmlspecialchars(str_replace('+', ' ', $user->data['user_aim'])); + $msn = htmlspecialchars($user->data['user_msnm']); + $yim = htmlspecialchars($user->data['user_yim']); + + $website = htmlspecialchars($user->data['user_website']); + $location = htmlspecialchars($user->data['user_from']); + $occupation = htmlspecialchars($user->data['user_occ']); + $interests = htmlspecialchars($user->data['user_interests']); + $signature_bbcode_uid = $user->data['user_sig_bbcode_uid']; + $signature = ( $signature_bbcode_uid != '' ) ? preg_replace("/\:(([a-z0-9]:)?)$signature_bbcode_uid/si", '', $user->data['user_sig']) : $user->data['user_sig']; + + $viewemail = $user->data['user_viewemail']; + $notifypm = $user->data['user_notify_pm']; + $popuppm = $user->data['user_popup_pm']; + $notifyreply = $user->data['user_notify']; + $attachsig = $user->data['user_attachsig']; + $allowhtml = $user->data['user_allowhtml']; + $allowbbcode = $user->data['user_allowbbcode']; + $allowsmilies = $user->data['user_allowsmile']; + $allowviewonline = $user->data['user_allow_viewonline']; + + $user_style = $user->data['user_style']; + $user_lang = $user->data['user_lang']; + $user_timezone = $user->data['user_timezone']; + $user_dateformat = $user->data['user_dateformat']; } // // Default pages // -include($phpbb_root_path . 'includes/page_header.'.$phpEx); - -make_jumpbox('viewforum.'.$phpEx); if ( $mode == 'editprofile' ) { - if ( $user_id != $userdata['user_id'] ) + if ( $user_id != $user->data['user_id'] ) { $error = TRUE; $error_msg = $user->lang['Wrong_Profile']; } } -if( isset($HTTP_POST_VARS['avatargallery']) && !$error ) -{ - include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx); - - $avatar_category = ( !empty($HTTP_POST_VARS['avatarcategory']) ) ? $HTTP_POST_VARS['avatarcategory'] : ''; - $template->set_filenames(array( - 'body' => 'profile_avatar_gallery.html') - ); - - $allowviewonline = !$allowviewonline; - - display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat); -} -else -{ if ( !isset($coppa) ) { $coppa = FALSE; @@ -731,37 +615,20 @@ else if ( !isset($user_template) ) { - $selected_template = $board_config['system_template']; + $selected_template = $config['system_template']; } $signature = preg_replace('/\:[0-9a-z\:]*?\]/si', ']', $signature); - $avatar_img = ''; - if ( $user_avatar_type ) - { - switch( $user_avatar_type ) - { - case USER_AVATAR_UPLOAD: - $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $user_avatar . '" alt="" />' : ''; - break; - case USER_AVATAR_REMOTE: - $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $user_avatar . '" alt="" />' : ''; - break; - case USER_AVATAR_GALLERY: - $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $user_avatar . '" alt="" />' : ''; - break; - } - } - $s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />'; if( $mode == 'editprofile' ) { - $s_hidden_fields .= '<input type="hidden" name="user_id" value="' . $userdata['user_id'] . '" />'; + $s_hidden_fields .= '<input type="hidden" name="user_id" value="' . $user->data['user_id'] . '" />'; // // Send the users current email address. If they change it, and account activation is turned on // the user account will be disabled and the user will have to reactivate their account. // - $s_hidden_fields .= '<input type="hidden" name="current_email" value="' . $userdata['user_email'] . '" />'; + $s_hidden_fields .= '<input type="hidden" name="current_email" value="' . $user->data['user_email'] . '" />'; } if ( !empty($user_avatar_local) ) @@ -769,30 +636,15 @@ else $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />'; } - $html_status = ( $userdata['user_allowhtml'] && $board_config['allow_html'] ) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF']; - $bbcode_status = ( $userdata['user_allowbbcode'] && $board_config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF']; - $smilies_status = ( $userdata['user_allowsmile'] && $board_config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF']; - - if ( $error ) - { - $template->set_filenames(array( - 'reg_header' => 'error_body.html') - ); - $template->assign_vars(array( - 'ERROR_MESSAGE' => $error_msg) - ); - $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); - } - - $template->set_filenames(array( - 'body' => 'profile_add_body.html') - ); + $html_status = ( $user->data['user_allowhtml'] && $config['allow_html'] ) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF']; + $bbcode_status = ( $user->data['user_allowbbcode'] && $config['allow_bbcode'] ) ? $user->lang['BBCode_is_ON'] : $user->lang['BBCode_is_OFF']; + $smilies_status = ( $user->data['user_allowsmile'] && $config['allow_smilies'] ) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF']; // // Let's do an overall check for settings/versions which would prevent // us from doing file uploads.... // - $form_enctype = ( @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads') == 'off') || phpversion() == '4.0.4pl1' || !$board_config['allow_avatar_upload'] || ( phpversion() < '4.0.3' && @ini_get('open_basedir') != '' ) ) ? '' : 'enctype="multipart/form-data"'; + $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off'|| !$config['allow_avatar_upload']) ? '' : 'enctype="multipart/form-data"'; $template->assign_vars(array( 'USERNAME' => $username, @@ -824,9 +676,6 @@ else 'ALWAYS_ALLOW_HTML_NO' => ( !$allowhtml ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => ( $allowsmilies ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '', - 'ALLOW_AVATAR' => $board_config['allow_avatar_upload'], - 'AVATAR' => $avatar_img, - 'AVATAR_SIZE' => $board_config['avatar_filesize'], 'LANGUAGE_SELECT' => language_select($user_lang, 'language'), 'STYLE_SELECT' => style_select($user_style, 'style'), 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'), @@ -864,20 +713,8 @@ else 'L_HIDE_USER' => $user->lang['Hide_user'], 'L_ALWAYS_ADD_SIGNATURE' => $user->lang['Always_add_sig'], - 'L_AVATAR_PANEL' => $user->lang['Avatar_panel'], - 'L_AVATAR_EXPLAIN' => sprintf($user->lang['Avatar_explain'], $board_config['avatar_max_width'], $board_config['avatar_max_height'], (round($board_config['avatar_filesize'] / 1024))), - 'L_UPLOAD_AVATAR_FILE' => $user->lang['Upload_Avatar_file'], - 'L_UPLOAD_AVATAR_URL' => $user->lang['Upload_Avatar_URL'], - 'L_UPLOAD_AVATAR_URL_EXPLAIN' => $user->lang['Upload_Avatar_URL_explain'], - 'L_AVATAR_GALLERY' => $user->lang['Select_from_gallery'], - 'L_SHOW_GALLERY' => $user->lang['View_avatar_gallery'], - 'L_LINK_REMOTE_AVATAR' => $user->lang['Link_remote_Avatar'], - 'L_LINK_REMOTE_AVATAR_EXPLAIN' => $user->lang['Link_remote_Avatar_explain'], - 'L_DELETE_AVATAR' => $user->lang['Delete_Image'], - 'L_CURRENT_IMAGE' => $user->lang['Current_Image'], - 'L_SIGNATURE' => $user->lang['Signature'], - 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['Signature_explain'], $board_config['max_sig_chars']), + 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['Signature_explain'], $config['max_sig_chars']), 'L_NOTIFY_ON_REPLY' => $user->lang['Always_notify'], 'L_NOTIFY_ON_REPLY_EXPLAIN' => $user->lang['Always_notify_explain'], 'L_NOTIFY_ON_PRIVMSG' => $user->lang['Notify_on_privmsg'], @@ -892,22 +729,19 @@ else 'L_EMAIL_ADDRESS' => $user->lang['Email_address'], 'S_PROFILE_EDIT' => ( $mode == 'editprofile' ) ? true : false, - 'S_DISPLAY_AVATAR_BLOCK' => ( $userdata['user_allowavatar'] && ( $board_config['allow_avatar_upload'] || $board_config['allow_avatar_local'] || $board_config['allow_avatar_remote'] ) ) ? true : false, - 'S_DISPLAY_AVATAR_UPLOAD' => ( $board_config['allow_avatar_upload'] && file_exists('./' . $board_config['avatar_path']) && $form_enctype != '' ) ? true : false, - 'S_DISPLAY_AVATAR_URL' => ( $board_config['allow_avatar_upload'] && file_exists('./' . $board_config['avatar_path']) ) ? true : false, - 'S_DISPLAY_AVATAR_REMOTE' => ( $board_config['allow_avatar_remote'] ) ? true : false, - 'S_DISPLAY_AVATAR_GALLERY' => ( $board_config['allow_avatar_local'] && file_exists('./' . $board_config['avatar_gallery_path']) ) ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORM_ENCTYPE' => $form_enctype, 'S_PROFILE_ACTION' => "profile.$phpEx$SID") ); - // - // This is another cheat using the block_var capability - // of the templates to 'fake' an IF...ELSE...ENDIF solution - // it works well :) - // -} +// +// +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +$template->set_filenames(array( + 'body' => 'profile_add_body.html') +); +make_jumpbox('viewforum.'.$phpEx); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); diff --git a/phpBB/includes/usercp_sendpasswd.php b/phpBB/includes/usercp_sendpasswd.php index b060f75fcf..a59590ad97 100644 --- a/phpBB/includes/usercp_sendpasswd.php +++ b/phpBB/includes/usercp_sendpasswd.php @@ -32,9 +32,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) $username = ( !empty($HTTP_POST_VARS['username']) ) ? trim(strip_tags($HTTP_POST_VARS['username'])) : ''; $email = ( !empty($HTTP_POST_VARS['email']) ) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['email']))) : ''; - $sql = "SELECT user_id, username, user_email, user_active, user_lang - FROM " . USERS_TABLE . " - WHERE user_email = '" . str_replace("\'", "''", $email) . "' + $sql = "SELECT user_id, username, user_email, user_active, user_lang + FROM " . USERS_TABLE . " + WHERE user_email = '" . str_replace("\'", "''", $email) . "' AND username = '" . str_replace("\'", "''", $username) . "'"; if ( $result = $db->sql_query($sql) ) { @@ -52,9 +52,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) $key_len = ( $str_len > 6 ) ? $key_len : 6; $user_actkey = substr($user_actkey, 0, $key_len); $user_password = gen_rand_string(false); - - $sql = "UPDATE " . USERS_TABLE . " - SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey' + + $sql = "UPDATE " . USERS_TABLE . " + SET user_newpasswd = '" .md5($user_password) . "', user_actkey = '$user_actkey' WHERE user_id = " . $row['user_id']; if ( !$db->sql_query($sql) ) { @@ -62,9 +62,9 @@ if ( isset($HTTP_POST_VARS['submit']) ) } include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; $emailer->use_template('user_activate_passwd', $row['user_lang']); $emailer->email_address($row['user_email']); @@ -72,10 +72,10 @@ if ( isset($HTTP_POST_VARS['submit']) ) $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - 'SITENAME' => $board_config['sitename'], + 'SITENAME' => $config['sitename'], 'USERNAME' => $username, 'PASSWORD' => $user_password, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => $server_url . "?mode=activate&act_key=$user_actkey") ); @@ -120,7 +120,7 @@ $template->assign_vars(array( 'USERNAME' => $username, 'EMAIL' => $email, - 'L_SEND_PASSWORD' => $lang['Send_password'], + 'L_SEND_PASSWORD' => $lang['Send_password'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_SUBMIT' => $lang['Submit'], diff --git a/phpBB/includes/usercp_viewprofile.php b/phpBB/includes/usercp_viewprofile.php index 4acb24d03d..348ce42ed9 100644 --- a/phpBB/includes/usercp_viewprofile.php +++ b/phpBB/includes/usercp_viewprofile.php @@ -83,13 +83,13 @@ if ( $profiledata['user_avatar_type'] && $profiledata['user_allowavatar'] ) switch( $profiledata['user_avatar_type'] ) { case USER_AVATAR_UPLOAD: - $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; + $avatar_img = ( $config['allow_avatar_upload'] ) ? '<img src="' . $config['avatar_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_REMOTE: - $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; + $avatar_img = ( $config['allow_avatar_remote'] ) ? '<img src="' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_GALLERY: - $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; + $avatar_img = ( $config['allow_avatar_local'] ) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $profiledata['user_avatar'] . '" alt="" border="0" />' : ''; break; } } @@ -121,7 +121,7 @@ else if ( $profiledata['user_viewemail'] || $auth->acl_get('a_') ) { - $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; + $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email']; $email_img = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>'; $email = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>'; diff --git a/phpBB/index.php b/phpBB/index.php index a69ca0d71f..94651a46f6 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -47,7 +47,7 @@ if ($mark_read == 'forums') { if ($userdata['user_id']) { - setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + setcookie($config['cookie_name'] . '_f_all', time(), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); } $template->assign_vars(array( @@ -60,13 +60,13 @@ if ($mark_read == 'forums') // End handle marking posts // Topic/forum marked read info -$mark_topics = (isset($_COOKIE[$board_config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_t'])) : array(); -$mark_forums = (isset($_COOKIE[$board_config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_f'])) : array(); +$mark_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); +$mark_forums = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array(); // Set some stats, get posts count from forums data if we... hum... retrieve all forums data -$total_users = $board_config['num_users']; -$newest_user = $board_config['newest_username']; -$newest_uid = $board_config['newest_user_id']; +$total_users = $config['num_users']; +$newest_user = $config['newest_username']; +$newest_uid = $config['newest_user_id']; if ($total_users == 0) { diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index 3cb6b330e5..82f19af51b 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -231,6 +231,7 @@ CREATE TABLE phpbb_poll_results ( poll_option_id tinyint(4) UNSIGNED NOT NULL DEFAULT '0', topic_id mediumint(8) UNSIGNED NOT NULL, poll_option_text varchar(255) NOT NULL, + poll_option_total mediumint(8) UNSIGNED NOT NULL DEFAULT '0', KEY poll_option_id (poll_option_id), KEY topic_id (topic_id) ); @@ -241,11 +242,11 @@ CREATE TABLE phpbb_poll_results ( # Table structure for table 'phpbb_vote_voters' # CREATE TABLE phpbb_poll_voters ( - vote_id mediumint(8) UNSIGNED NOT NULL DEFAULT '0', + topic_id mediumint(8) UNSIGNED NOT NULL DEFAULT '0', poll_option_id tinyint(4) UNSIGNED NOT NULL DEFAULT '0', vote_user_id mediumint(8) UNSIGNED NOT NULL DEFAULT '0', vote_user_ip varchar(40) NOT NULL, - KEY vote_id (vote_id), + KEY topic_id (vote_id), KEY vote_user_id (vote_user_id), KEY vote_user_ip (vote_user_ip) ); diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 839cb79e4c..5263f7db16 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -24,13 +24,14 @@ $lang = array_merge($lang, array( 'No_admin' => 'You are not authorised to administer this board', 'No_frames' => 'Sorry, your browser does not support frames', 'Return_to' => 'Return to ...', - 'General_cat' => 'General Admin', 'DB_cat' => 'Database Admin', - 'Users_cat' => 'User Admin', - 'Groups_cat' => 'Group Admin', 'Forums_cat' => 'Forum Admin', - 'Styles_cat' => 'Styles Admin', + 'General_cat' => 'General Admin', + 'Groups_cat' => 'Group Admin', 'Log_cat' => 'Log Admin', + 'Posts_cat' => 'Posting Admin', + 'Styles_cat' => 'Styles Admin', + 'Users_cat' => 'User Admin', 'Avatar_settings' => 'Avatar Settings', 'Cookie_settings' => 'Cookie Settings', 'Board_defaults' => 'Board Defaults', @@ -45,6 +46,7 @@ $lang = array_merge($lang, array( 'Mass_Email' => 'Mass Email', 'Ranks' => 'Ranks', 'Smilies' => 'Smilies', + 'Topic_icons' => 'Topic Icons', 'Ban_users' => 'Ban Usernames', 'Ban_emails' => 'Ban Emails', 'Ban_ips' => 'Ban IPs', diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index e946d490f8..890ce5be1d 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -300,10 +300,8 @@ $lang = array_merge($lang, array( 'Add_poll' => 'Add a Poll', 'Add_poll_explain' => 'If you do not want to add a poll to your topic leave the fields blank', 'Poll_question' => 'Poll question', - 'Poll_option' => 'Poll option', - 'Add_option' => 'Add option', - 'Update' => 'Update', - 'Delete' => 'Delete', + 'Poll_options' => 'Poll options', + 'Poll_options_explain' => 'Place each option on a new line. You may enter up to <b>%d</b> options', 'Poll_for' => 'Run poll for', 'Days' => 'Days', 'Poll_for_explain' => '[ Enter 0 or leave blank for a never ending poll ]', diff --git a/phpBB/login.php b/phpBB/login.php index 08fb7339b6..3c494cf8f6 100644 --- a/phpBB/login.php +++ b/phpBB/login.php @@ -47,7 +47,7 @@ if ( isset($login) || isset($logout) ) // // Is the board disabled? Are we an admin? No, then back to the index we go // - if ( $board_config['board_disable'] && !$auth->acl_get('a_') ) + if ( $config['board_disable'] && !$auth->acl_get('a_') ) { redirect("index.$phpEx$SID"); } diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 5025a15f04..ab8da450c8 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -86,10 +86,10 @@ $select_sort_order = '<select name="order">'; $select_sort_order .= ( $sort_order == 'a' ) ? '<option value="a" selected="selected">' . $user->lang['Sort_Ascending'] . '</option><option value="d">' . $user->lang['Sort_Descending'] . '</option>' : '<option value="a">' . $user->lang['Sort_Ascending'] . '</option><option value="d" selected="selected">' . $user->lang['Sort_Descending'] . '</option>'; $select_sort_order .= '</select>'; -if ( $mode != 'topten' || $board_config['topics_per_page'] < 10 ) +if ( $mode != 'topten' || $config['topics_per_page'] < 10 ) { - $pagination = generate_pagination("memberlist.$phpEx$SID&mode=$mode&order=$sort_order", $board_config['num_users'], $board_config['topics_per_page'], $start). ' '; - $total_members = $board_config['num_users']; + $pagination = generate_pagination("memberlist.$phpEx$SID&mode=$mode&order=$sort_order", $config['num_users'], $config['topics_per_page'], $start). ' '; + $total_members = $config['num_users']; } else { @@ -102,7 +102,7 @@ else // $template->assign_vars(array( 'PAGINATION' => $pagination, - 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_members / $board_config['topics_per_page'] )), + 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $total_members / $config['topics_per_page'] )), 'L_SELECT_SORT_METHOD' => $user->lang['Select_sort_method'], 'L_EMAIL' => $user->lang['Email'], @@ -134,31 +134,31 @@ if ( isset($_GET['mode']) || isset($_POST['mode']) ) $order_by = "user_posts DESC LIMIT 10"; break; case 'joined': - $order_by = "user_regdate ASC LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_regdate ASC LIMIT $start, " . $config['topics_per_page']; break; case 'username': - $order_by = "username $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "username $sort_order LIMIT $start, " . $config['topics_per_page']; break; case 'location': - $order_by = "user_from $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_from $sort_order LIMIT $start, " . $config['topics_per_page']; break; case 'posts': - $order_by = "user_posts $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_posts $sort_order LIMIT $start, " . $config['topics_per_page']; break; case 'email': - $order_by = "user_email $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_email $sort_order LIMIT $start, " . $config['topics_per_page']; break; case 'website': - $order_by = "user_website $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_website $sort_order LIMIT $start, " . $config['topics_per_page']; break; default: - $order_by = "user_regdate $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_regdate $sort_order LIMIT $start, " . $config['topics_per_page']; break; } } else { - $order_by = "user_regdate $sort_order LIMIT $start, " . $board_config['topics_per_page']; + $order_by = "user_regdate $sort_order LIMIT $start, " . $config['topics_per_page']; } $sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar @@ -185,20 +185,20 @@ if ( $row = $db->sql_fetchrow($result) ) switch( $row['user_avatar_type'] ) { case USER_AVATAR_UPLOAD: - $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_upload'] ) ? '<img src="' . $config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_REMOTE: - $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; case USER_AVATAR_GALLERY: - $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; + $poster_avatar = ( $config['allow_avatar_local'] ) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : ''; break; } } if ( $row['user_viewemail'] || $auth->acl_get('a_') ) { - $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $user_id : 'mailto:' . $row['user_email']; + $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $user_id : 'mailto:' . $row['user_email']; $email_img = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>'; $email = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>'; @@ -298,7 +298,7 @@ include($phpbb_root_path . 'includes/page_tail.'.$phpEx); function username_search() { global $SID, $phpEx, $phpbb_root_path; - global $db, $board_config, $template, $auth, $lang, $theme, $user; + global $db, $config, $template, $auth, $lang, $theme, $user; global $starttime; $form = ( !empty($_GET['form']) ) ? $_GET['form'] : 0; @@ -390,7 +390,7 @@ function username_search() $total_users = ( $row = $db->sql_fetchrow($result) ) ? $row['total_users'] : 0; - $pagination = generate_pagination("search.$phpEx$SID&mode=searchuser&form=$form&field=$field&username=" . urlencode($username) . "&email=" . urlencode($email) . "&icq=$icq&aim=" . urlencode($aim) . "&yahoo=" . urlencode($yahoo) . "&msn=" . urlencode($msn) . "&joined=" . urlencode(implode('-', $joined)) . "&active=" . urlencode(implode('-', $active)) . "&count=$count&sort_order=$sort_order&sort_by=$sort_by&joined_select=$joined_select&active_select=$active_select&count_select=$count_select", $total_users, $board_config['topics_per_page'], $start); + $pagination = generate_pagination("search.$phpEx$SID&mode=searchuser&form=$form&field=$field&username=" . urlencode($username) . "&email=" . urlencode($email) . "&icq=$icq&aim=" . urlencode($aim) . "&yahoo=" . urlencode($yahoo) . "&msn=" . urlencode($msn) . "&joined=" . urlencode(implode('-', $joined)) . "&active=" . urlencode(implode('-', $active)) . "&count=$count&sort_order=$sort_order&sort_by=$sort_by&joined_select=$joined_select&active_select=$active_select&count_select=$count_select", $total_users, $config['topics_per_page'], $start); // // @@ -414,7 +414,7 @@ function username_search() 'COUNT' => $count, 'PAGINATION' => $pagination, - 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $total_users / $board_config['topics_per_page'] )), + 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $total_users / $config['topics_per_page'] )), 'L_SEARCH_USERNAME' => $user->lang['Find_username'], 'L_SEARCH_EXPLAIN' => $user->lang['Find_username_explain'], @@ -451,7 +451,7 @@ function username_search() WHERE user_id <> " . ANONYMOUS . " $where_sql ORDER BY $order_by - LIMIT $start, " . $board_config['topics_per_page']; + LIMIT $start, " . $config['topics_per_page']; $result = $db->sql_query($sql); if ( $row = $db->sql_fetchrow($result) ) diff --git a/phpBB/modcp.php b/phpBB/modcp.php index ac6fe1b2d1..f3ac5fa42f 100644 --- a/phpBB/modcp.php +++ b/phpBB/modcp.php @@ -682,7 +682,7 @@ switch( $mode ) // If the board has HTML off but the post has HTML // on then we process it, else leave it alone // - if ( !$board_config['allow_html'] ) + if ( !$config['allow_html'] ) { if ( $postrow[$i]['enable_html'] ) { @@ -692,7 +692,7 @@ switch( $mode ) if ( $bbcode_uid != '' ) { - $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); + $message = ( $config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); } // @@ -710,7 +710,7 @@ switch( $mode ) $message = make_clickable($message); - if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] ) + if ( $config['allow_smilies'] && $postrow[$i]['enable_smilies'] ) { $message = smilies_pass($message); } @@ -901,7 +901,7 @@ switch( $mode ) AND t.topic_poster = u.user_id AND p.post_id = t.topic_last_post_id ORDER BY t.topic_type DESC, p.post_time DESC - LIMIT $start, " . $board_config['topics_per_page']; + LIMIT $start, " . $config['topics_per_page']; $result = $db->sql_query($sql); while ( $row = $db->sql_fetchrow($result) ) @@ -985,8 +985,8 @@ switch( $mode ) $db->sql_freeresult($result); $template->assign_vars(array( - 'PAGINATION' => generate_pagination("modcp.$phpEx$SID&f=$forum_id", $forum_topics, $board_config['topics_per_page'], $start), - 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )), + 'PAGINATION' => generate_pagination("modcp.$phpEx$SID&f=$forum_id", $forum_topics, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $config['topics_per_page'] )), 'L_GOTO_PAGE' => $lang['Goto_page']) ); diff --git a/phpBB/posting.php b/phpBB/posting.php index b330fab19f..3e187d16fa 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -68,41 +68,6 @@ switch ($mode) } -// Set toggles for various options -if ( !$board_config['allow_html'] ) -{ - $html_on = 0; -} -else -{ - $html_on = ( $post || $refresh ) ? ( ( !empty($disable_html) ) ? 0 : TRUE ) : ( ( !$user->data['user_id'] ) ? $board_config['allow_html'] : $user->data['user_allowhtml'] ); -} - -if ( !$board_config['allow_bbcode'] ) -{ - $bbcode_on = 0; -} -else -{ - $bbcode_on = ( $post || $refresh ) ? ( ( !empty($disable_bbcode) ) ? 0 : TRUE ) : ( ( !$user->data['user_id'] ) ? $board_config['allow_bbcode'] : $user->data['user_allowbbcode'] ); -} - -$magic_urls_on = ( $post || $refresh ) ? ( ( !empty($disable_magic_url) ) ? 0 : TRUE ) : TRUE; - -if ( !$board_config['allow_smilies'] ) -{ - $smilies_on = 0; -} -else -{ - $smilies_on = ( $post || $refresh ) ? ( ( !empty($disable_smilies) ) ? 0 : TRUE ) : ( ( !$user->data['user_id'] ) ? $board_config['allow_smilies'] : $user->data['user_allowsmile'] ); -} - -$attach_sig = ( $post || $refresh ) ? ( ( !empty($attach_sig) ) ? TRUE : 0 ) : ( ( !$user->data['user_id'] ) ? 0 : $user->data['user_attachsig'] ); -// -// FLAGS -// ----- - // --------- // POST INFO @@ -114,8 +79,9 @@ switch ($mode) { case 'post': break; + case 'reply': - if ( empty($topic_id) ) + if (empty($topic_id)) { trigger_error($user->lang['No_topic_id']); } @@ -124,76 +90,109 @@ switch ($mode) FROM " . TOPICS_TABLE . " WHERE topic_id = $topic_id"; break; + case 'quote': case 'edit': case 'delete': - if ( empty($post_id) ) + if (empty($post_id)) { trigger_error($user->lang['No_post_id']); } $sql = "SELECT t.*, p.*, pt.* - FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u + FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt, " . TOPICS_TABLE . " t WHERE p.post_id = $post_id AND t.topic_id = p.topic_id - AND pt.post_id = p.post_id - AND u.user_id = p.poster_id"; + AND pt.post_id = p.post_id"; break; default: trigger_error($user->lang['No_valid_mode']); } -if ( $sql != '' ) +if ($sql != '') { $result = $db->sql_query($sql); - extract($db->sql_fetchrow($result)); $db->sql_freeresult($result); } + +// Notify user checkbox +if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS) +{ + $sql = "SELECT topic_id + FROM " . TOPICS_WATCH_TABLE . " + WHERE topic_id = $topic_id + AND user_id = " . $user->data['user_id']; + $result = $db->sql_query($sql); + + $notify_set = ($db->sql_fetchrow($result)) ? true : false; + $db->sql_freeresult($result); +} + +if ($mode == 'edit' && !empty($poll_start)) +{ + $sql = "SELECT * + FROM phpbb_poll_results + WHERE topic_id = " . intval($topic_id); + $result = $db->sql_query($sql); + + $poll_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $poll_options[] = $row['poll_option_text']; + } + $db->sql_freeresult($result); +} // // POST INFO // --------- -// ACL CHECK + + +// Basic mode related permission check if (!$auth->acl_get('f_' . $mode, $forum_id)) { trigger_error($user->lang['User_cannot_' . $mode]); } -// EDIT TIME CHECK -if (($mode == 'edit' || $mode == 'delete') && !empty($board_config['edit_time']) && $post_time < time() - $board_config['edit_time']) +// Can we edit this post? +if (($mode == 'edit' || $mode == 'delete') && !empty($config['edit_time']) && $post_time < time() - $config['edit_time'] && !$auth->acl_get('m_', $forum_id) && !$auth->acl_get('a_')) { trigger_error($user->lang['Cannot_edit_time']); } + + + // -------------- // PROCESS SUBMIT // -if ( isset($post) ) +if (isset($post)) { - - // First check if message has changed (if editing), if not - // don't parse at all else ... - // - // Need to parse message, parse search words, parse polls, parse attachments, - // check whether forum is moderated or if msg is being saved (and if it is - // whether user has run out of save quota) if not topic/forum needs syncing, - // if replying notifications need sending as appropriate. $err_msg = ''; + $parse_msg = new parse_message(); + $search = new fulltext_search(); + $current_time = time(); $message_md5 = md5($message); - // Check checksum + $enable_html = (!intval($config['allow_html'])) ? 0 : ((!empty($disable_html)) ? 0 : 1); + $enable_bbcode = (!intval($config['allow_bbcode'])) ? 0 : ((!empty($disable_bbcode)) ? 0 : 1); + $enable_smilies = (!intval($config['allow_smilies'])) ? 0 : ((!empty($disable_smilies)) ? 0 : 1); + $enable_urls = (!empty($disable_magic_url)) ? 1 : 0; + $enable_sig = (empty($attach_sig) ) ? 1 : 0; + + // Check checksum ... don't re-parse message if the same if ($mode != 'edit' || $message_md5 != $post_checksum) { // Parse message - $parse_msg = new parse_message(); + $bbcode_uid = (!empty($bbcode_uid)) ? $bbcode_uid : ''; - if(($result = $parse_msg->parse($message, $html_on, $bbcode_on, $bbcode_uid, $magic_urls_on, $smilies_on)) != '') + if(($result = $parse_msg->parse($message, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies)) != '') { $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result; } @@ -210,7 +209,7 @@ if ( isset($post) ) if ($row = $db->sql_fetchrow($result)) { - if (intval($row['last_post_time']) && ($current_time - intval($row['last_post_time'])) < intval($board_config['flood_interval'])) + if (intval($row['last_post_time']) && ($current_time - intval($row['last_post_time'])) < intval($config['flood_interval'])) { $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['Flood_Error']; } @@ -220,23 +219,62 @@ if ( isset($post) ) // Validate username if (($username != '' && $user->data['user_id'] == ANONYMOUS) || ($mode == 'edit' && $post_username != '')) { - require_once($phpbb_root_path . 'includes/functions_validate.'.$phpEx); - $username = strip_tags(htmlspecialchars($username)); - $result = validate_username($username); - if ( $result['error'] ) + if (($result = validate_username($username)) != false) { - $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result['error_msg']; + $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result; } } // Parse subject - if (($subject = htmlspecialchars($subject)) == '' && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) + if (($subject = trim(htmlspecialchars(strip_tags($subject)))) == '' && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) { $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['Empty_subject']; } + // Process poll options + if (!empty($poll_option_text) && (($auth->acl_get('f_poll', $forum_id) && empty($poll_last_vote)) || $auth->acl_get('a_'))) + { + $result = $parse_msg->parse($poll_option_text, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies); + $poll_options = explode("\n", $poll_option_text); + + if (sizeof($poll_options) == 1) + { + $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['To_few_poll_options']; + } + else if (sizeof($poll_options) > intval($config['max_poll_options'])) + { + $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['To_many_poll_options']; + } + + $poll_subject = (!empty($poll_subject)) ? trim(htmlspecialchars(strip_tags($poll_subject))) : ''; + $poll_length = (!empty($poll_length)) ? intval($poll_length) : 0; + } + + // Check topic type + if ($topic_type != POST_NORMAL) + { + $auth_option = ''; + switch ($topic_type) + { + case POST_NEWS; + $auth_option = 'news'; + break; + case POST_ANNOUNCE; + $auth_option = 'announce'; + break; + case POST_STICKY; + $auth_option = 'sticky'; + break; + } + + if (!$auth->acl_get('f_' . $auth_option, $forum_id)) + { + $err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['Cannot_post_' . $auth_option]; + } + } + // Store message, sync counters if ($err_msg == '') { @@ -246,36 +284,42 @@ if ( isset($post) ) { $sql = ($mode == 'post') ? 'INSERT INTO ' . TOPICS_TABLE : 'UPDATE ' . TOPICS_TABLE . ' SET WHERE topic_id = ' . intval($topic_id); $topic_sql = array( + 'forum_id' => intval($forum_id), 'topic_title' => $subject, 'topic_poster' => intval($user->data['user_id']), 'topic_time' => $current_time, - 'forum_id' => intval($forum_id), 'topic_type' => intval($type), 'topic_icon' => intval($icon), 'topic_approved'=> ($forum_moderated) ? 0 : 1, ); + if (!empty($poll_options)) + { + $topic_sql = array_merge($topic_sql, array( + 'poll_title' => $poll_title, + 'poll_start' => (!empty($poll_start)) ? $poll_start : $current_time, + 'poll_length' => $poll_length * 3600 + )); + } $db->sql_query_array($sql, $topic_sql); $topic_id = ($mode == 'post') ? $db->sql_nextid() : $topic_id; } - $enable_sig = $enable_bbcode = $enable_html = $enable_smilies = $enable_magic_url = $bbcode_uid = 1; - $sql = ($mode == 'edit') ? 'UPDATE ' . POSTS_TABLE . ' SET , post_edit_count = post_edit_count + 1 WHERE post_id = ' . $post_id : 'INSERT INTO ' . POSTS_TABLE; $post_sql = array( 'topic_id' => intval($topic_id), 'forum_id' => intval($forum_id), 'poster_id' => ($mode == 'edit') ? intval($poster_id) : intval($user->data['user_id']), 'post_username' => ($username != '') ? sql_quote($username) : '', - 'poster_ip' => $user->ip, + 'poster_ip' => $user->ip, 'post_time' => $current_time, 'post_approved' => ($forum_moderated) ? 0 : 1, 'post_edit_time' => ($mode == 'edit') ? $current_time : 0, - 'enable_sig' => $enable_sig, + 'enable_sig' => $enable_html, 'enable_bbcode' => $enable_bbcode, 'enable_html' => $enable_html, 'enable_smilies' => $enable_smilies, - 'enable_magic_url' => $enable_magic_url, + 'enable_magic_url' => $enable_urls, ); $db->sql_query_array($sql, $post_sql); @@ -302,8 +346,43 @@ if ( isset($post) ) // Fulltext parse if ($mode != 'edit' || $message_md5 != $post_checksum) { -// $search = new fulltext_search(); -// $result = $search->add($p, $message, $subject, $post_text, $post_subject); +// $result = $search->add($mode, $post_id, $message, $subject); + } + + // Add/Update poll options ... incomplete(!) + if (!empty($poll_options)) + { + $cur_poll_options = array(); + if (!empty($poll_start) && $mode == 'edit') + { + $sql = "SELECT * FROM phpbb_poll_results + WHERE topic_id = $topic_id + ORDER BY poll_option_id"; + $result = $db->sql_query($sql); + + while ($cur_poll_options[] = $db->sql_fetchrow($result)); + $db->sql_freeresult($result); + } + + for ($i = 0; $i < sizeof($poll_options); $i++) + { + if (trim($poll_options[$i]) != '') + { + if (empty($cur_poll_options[$i])) + { + $sql = "INSERT INTO phpbb_poll_results (topic_id, poll_option_text) + VALUES (" . intval($topic_id) . ", '" . sql_quote($poll_options[$i]) . "')"; + $db->sql_query($sql); + } + else if ($poll_options[$i] != $cur_poll_options[$i]) + { + $sql = "UPDATE phpbb_poll_results + SET poll_option_text = '" . sql_quote($poll_options[$i]) . "' + WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id']; + $db->sql_query($sql); + } + } + } } // Sync forums, topics and users ... @@ -311,33 +390,33 @@ if ( isset($post) ) { $forum_topics_sql = ($mode == 'post') ? ', forum_topics = forum_topics + 1' : ''; $forum_sql = array( - 'forum_last_post_id' => intval($post_id), - 'forum_last_post_time' => $current_time, - 'forum_last_poster_id' => intval($user->data['user_id']), - 'forum_last_poster_name' => ($username != '') ? $username : '', + 'forum_last_post_id' => intval($post_id), + 'forum_last_post_time' => $current_time, + 'forum_last_poster_id' => intval($user->data['user_id']), + 'forum_last_poster_name'=> ($username != '') ? $username : '', ); $db->sql_query_array('UPDATE ' . FORUMS_TABLE . ' SET , forum_posts = forum_posts + 1' . $forum_topics_sql . ' WHERE forum_id = ' . intval($forum_id), $forum_sql); $topic_replies_sql = ($mode == 'reply') ? ', topic_replies = topic_replies + 1' : ''; $topic_sql = array( - 'topic_last_post_id' => intval($post_id), - 'topic_last_post_time' => $current_time, - 'topic_last_poster_id' => intval($user->data['user_id']), - 'topic_last_poster_name' => ($username != '') ? $username : '', + 'topic_last_post_id' => intval($post_id), + 'topic_last_post_time' => $current_time, + 'topic_last_poster_id' => intval($user->data['user_id']), + 'topic_last_poster_name'=> ($username != '') ? $username : '', ); if ($mode == 'post') { $topic_sql = array_merge($topic_sql, array( - 'topic_first_post_id' => intval($post_id), - 'topic_time' => $current_time, - 'topic_poster' => intval($user->data['user_id']), - 'topic_first_poster_name' => ($username != '') ? $username : '', + 'topic_first_post_id' => intval($post_id), + 'topic_time' => $current_time, + 'topic_poster' => intval($user->data['user_id']), + 'topic_first_poster_name' => ($username != '') ? $username : '', )); } $db->sql_query_array('UPDATE ' . TOPICS_TABLE . ' SET ' . $topic_replies_sql . ' WHERE topic_id = ' . intval($topic_id), $topic_sql); - if ($post_count_inc) + if ($post_count_inc && $user->data['user_id'] != ANONYMOUS) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts + 1 @@ -346,6 +425,21 @@ if ( isset($post) ) } } + // Topic notification + if (!empty($notify) && ($mode == 'post' || empty($notify_set))) + { + $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id) + VALUES (" . $user->data['user_id'] . ", $topic_id)"; + $db->sql_query($sql); + } + else if (empty($notify) && !empty($notify_set)) + { + $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " + WHERE user_id = " . $user->data['user_id'] . " + AND topic_id = $topic_id"; + $db->sql_query($sql); + } + $db->sql_transaction('commit'); $template->assign_vars(array( @@ -355,10 +449,14 @@ if ( isset($post) ) } // Houston, we have an error ... - $post_text = &$message; - $post_subject = $topic_title = &$subject; - $topic_icon = &$icon; - $topic_type = &$type; + $post_text = &$message; + $post_subject = $topic_title = &$subject; + $topic_icon = &$icon; + $topic_type = &$type; + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $err_msg) + ); } // @@ -367,6 +465,8 @@ if ( isset($post) ) + + // ----------------- // TEMPORARY SECTION! // @@ -393,33 +493,11 @@ $post_text = preg_replace($match, $replace, $post_text); + // ----------------------------- // MAIN POSTING PAGE BEGINS HERE // -// Notify user checkbox -if ($post || $refresh) -{ - $notify_user = (!empty($notify)) ? TRUE : 0; -} -else -{ - if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS) - { - $sql = "SELECT topic_id - FROM " . TOPICS_WATCH_TABLE . " - WHERE topic_id = $topic_id - AND user_id = " . $user->data['user_id']; - $result = $db->sql_query($sql); - - $notify_user = ($db->sql_fetchrow($result)) ? TRUE : $user->data['user_notify']; - } - else - { - $notify_user = ($user_id['user_id']) ? $user->data['user_notify'] : 0; - } -} - // Generate smilies and topic icon listings generate_smilies('inline'); @@ -438,7 +516,7 @@ if ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('topic_icon', array( 'ICON_ID' => $row['icons_id'], - 'ICON_IMG' => $board_config['icons_path'] . '/' . $row['icons_url'], + 'ICON_IMG' => $config['icons_path'] . '/' . $row['icons_url'], 'ICON_WIDTH' => $row['icons_width'], 'ICON_HEIGHT' => $row['icons_height'], @@ -479,11 +557,18 @@ if ($mode == 'post' || $mode == 'edit') } // HTML, BBCode, Smilies, Images and Flash status -$html_status = ($board_config['allow_html'] && $auth->acl_get('f_html', $forum_id)) ? true : false; -$bbcode_status = ($board_config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($board_config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; -$img_status = ($board_config['allow_img'] && $auth->acl_get('f_img', $forum_id)) ? true : false; -$flash_status = ($board_config['allow_flash'] && $auth->acl_get('f_flash', $forum_id)) ? true : false; +$html_status = ($config['allow_html'] && $auth->acl_get('f_html', $forum_id)) ? true : false; +$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; +$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; +$img_status = ($config['allow_img'] && $auth->acl_get('f_img', $forum_id)) ? true : false; +$flash_status = ($config['allow_flash'] && $auth->acl_get('f_flash', $forum_id)) ? true : false; + +$html_checked = (isset($enable_html)) ? !$enable_html : (($config['allow_html']) ? !$user->data['user_allowhtml'] : 1); +$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode']) ? !$user->data['user_allowbbcode'] : 1); +$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies']) ? !$user->data['user_allowsmile'] : 1); +$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0; +$sig_checked = (isset($attach_sig)) ? $attach_sig : (($config['allow_sigs']) ? $user->data['user_atachsig'] : 0); +$notify_checked = (isset($notify_set)) ? $notify_set : (($user->data['user_id'] != ANONYMOUS) ? $user->data['user_notify'] : 0); // Page title/hidden fields $s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" />'; @@ -572,12 +657,12 @@ $template->assign_vars(array( 'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&mode=moderators&f=' . $forum_id, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_HTML_CHECKED' => (!$html_on ) ? 'checked="checked"' : '', - 'S_BBCODE_CHECKED' => (!$bbcode_on ) ? 'checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$smilies_on ) ? 'checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$magic_urls_on ) ? 'checked="checked"' : '', - 'S_SIGNATURE_CHECKED' => ($attach_sig ) ? 'checked="checked"' : '', - 'S_NOTIFY_CHECKED' => ($notify_user ) ? 'checked="checked"' : '', + 'S_HTML_CHECKED' => ($html_checked) ? 'checked="checked"' : '', + 'S_BBCODE_CHECKED' => ($bbcode_checked) ? 'checked="checked"' : '', + 'S_SMILIES_CHECKED' => ($smilies_checked) ? 'checked="checked"' : '', + 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? 'checked="checked"' : '', + 'S_SIGNATURE_CHECKED' => ($sig_checked) ? 'checked="checked"' : '', + 'S_NOTIFY_CHECKED' => ($notify_checked) ? 'checked="checked"' : '', 'S_DISPLAY_USERNAME' => ($user->data['user_id'] == ANONYMOUS || ($mode == 'edit' && $post_username)) ? true : false, 'S_SAVE_ALLOWED' => ($auth->acl_get('f_save', $forum_id)) ? true : false, @@ -595,16 +680,17 @@ $template->assign_vars(array( ); // Poll entry -if ( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) ) && $auth->acl_get('f_poll', $forum_id) ) +if ((($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && empty($poll_last_vote))) && $auth->acl_get('f_poll', $forum_id)) || $auth->get_acl('a_')) { $template->assign_vars(array( 'S_SHOW_POLL_BOX' => true, - 'S_POLL_DELETE' => ($mode == 'edit' && $edit_poll) ? true : false, + 'S_POLL_DELETE' => ($mode == 'edit') ? true : false, 'L_ADD_A_POLL' => $user->lang['Add_poll'], 'L_ADD_POLL_EXPLAIN' => $user->lang['Add_poll_explain'], 'L_POLL_QUESTION' => $user->lang['Poll_question'], - 'L_POLL_OPTION' => $user->lang['Poll_option'], + 'L_POLL_OPTIONS' => $user->lang['Poll_options'], + 'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['Poll_options_explain'], $config['max_poll_options']), 'L_ADD_OPTION' => $user->lang['Add_option'], 'L_UPDATE_OPTION' => $user->lang['Update'], 'L_DELETE_OPTION' => $user->lang['Delete'], @@ -614,20 +700,9 @@ if ( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] 'L_POLL_DELETE' => $user->lang['Delete_poll'], 'POLL_TITLE' => $poll_title, + 'POLL_OPTIONS' => ($poll_options) ? implode("\n", $poll_options) : '', 'POLL_LENGTH' => $poll_length) ); - - if ( !empty($poll_options) ) - { - foreach ( $poll_options as $option_id => $option_text ) - { - $template->assign_block_vars('poll_options', array( - 'POLL_OPTION' => htmlspecialchars($option_text), - - 'S_POLL_OPTION_NUM' => $option_id) - ); - } - } } // Attachment entry diff --git a/phpBB/privmsg.php b/phpBB/privmsg.php index 2992b1f0ef..87113155ea 100644 --- a/phpBB/privmsg.php +++ b/phpBB/privmsg.php @@ -30,7 +30,7 @@ include($phpbb_root_path . 'includes/functions_posting.'.$phpEx); // // Is PM disabled? // -if ( !empty($board_config['privmsg_disable']) ) +if ( !empty($config['privmsg_disable']) ) { message_die(MESSAGE, 'PM_disabled'); } @@ -270,7 +270,7 @@ else if ( $mode == 'read' ) if ( $sent_info = $db->sql_fetchrow($result) ) { - if ( $sent_info['sent_items'] >= $board_config['max_sentbox_privmsgs'] ) + if ( $sent_info['sent_items'] >= $config['max_sentbox_privmsgs'] ) { $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . " @@ -448,7 +448,7 @@ else if ( $mode == 'read' ) if ( !empty($privmsg['user_viewemail']) || $auth->acl_get('a_') ) { - $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&u$user_id_from") : 'mailto:' . $privmsg['user_email']; + $email_uri = ( $config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&u$user_id_from") : 'mailto:' . $privmsg['user_email']; $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>'; $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>'; @@ -497,7 +497,7 @@ else if ( $mode == 'read' ) $private_message = $privmsg['privmsgs_text']; $bbcode_uid = $privmsg['privmsgs_bbcode_uid']; - if ( $board_config['allow_sig'] ) + if ( $config['allow_sig'] ) { $user_sig = ( $privmsg['privmsgs_from_userid'] == $userdata['user_id'] ) ? $userdata['user_sig'] : $privmsg['user_sig']; } @@ -512,7 +512,7 @@ else if ( $mode == 'read' ) // If the board has HTML off but the post has HTML // on then we process it, else leave it alone // - if ( !$board_config['allow_html'] ) + if ( !$config['allow_html'] ) { if ( $user_sig != '' && $privmsg['privmsgs_enable_sig'] && $userdata['user_allowhtml'] ) { @@ -527,12 +527,12 @@ else if ( $mode == 'read' ) if ( $user_sig != '' && $privmsg['privmsgs_attach_sig'] && $user_sig_bbcode_uid != '' ) { - $user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig); + $user_sig = ( $config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig); } if ( $bbcode_uid != '' ) { - $private_message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($private_message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $private_message); + $private_message = ( $config['allow_bbcode'] ) ? bbencode_second_pass($private_message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $private_message); } $private_message = make_clickable($private_message); @@ -548,7 +548,7 @@ else if ( $mode == 'read' ) $private_message = preg_replace($orig_word, $replacement_word, $private_message); } - if ( $board_config['allow_smilies'] && $privmsg['privmsgs_enable_smilies'] ) + if ( $config['allow_smilies'] && $privmsg['privmsgs_enable_smilies'] ) { $private_message = smilies_pass($private_message); } @@ -791,7 +791,7 @@ else if ( $save && $mark_list && $folder != 'savebox' && $folder != 'outbox' ) if ( $saved_info = $db->sql_fetchrow($result) ) { - if ( $saved_info['savebox_items'] >= $board_config['max_savebox_privmsgs'] ) + if ( $saved_info['savebox_items'] >= $config['max_savebox_privmsgs'] ) { $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . " @@ -859,7 +859,7 @@ else if ( $submit || $refresh || $mode != '' ) // // Toggles // - if ( !$board_config['allow_html'] ) + if ( !$config['allow_html'] ) { $html_on = 0; } @@ -868,7 +868,7 @@ else if ( $submit || $refresh || $mode != '' ) $html_on = ( $submit || $refresh ) ? ( ( !empty($_POST['disable_html']) ) ? 0 : TRUE ) : $userdata['user_allowhtml']; } - if ( !$board_config['allow_bbcode'] ) + if ( !$config['allow_bbcode'] ) { $bbcode_on = 0; } @@ -877,7 +877,7 @@ else if ( $submit || $refresh || $mode != '' ) $bbcode_on = ( $submit || $refresh ) ? ( ( !empty($_POST['disable_bbcode']) ) ? 0 : TRUE ) : $userdata['user_allowbbcode']; } - if ( !$board_config['allow_smilies'] ) + if ( !$config['allow_smilies'] ) { $smilies_on = 0; } @@ -887,7 +887,7 @@ else if ( $submit || $refresh || $mode != '' ) } $attach_sig = ( $submit || $refresh ) ? ( ( !empty($_POST['attach_sig']) ) ? TRUE : 0 ) : $userdata['user_attachsig']; - $user_sig = ( $userdata['user_sig'] != '' && $board_config['allow_sig'] ) ? $userdata['user_sig'] : ""; + $user_sig = ( $userdata['user_sig'] != '' && $config['allow_sig'] ) ? $userdata['user_sig'] : ""; if ( $submit && $mode != 'edit' ) { @@ -902,7 +902,7 @@ else if ( $submit || $refresh || $mode != '' ) $last_post_time = $db_row['last_post_time']; $current_time = time(); - if ( ( $current_time - $last_post_time ) < $board_config['flood_interval']) + if ( ( $current_time - $last_post_time ) < $config['flood_interval']) { message_die(MESSAGE, $lang['Flood_Error']); } @@ -990,7 +990,7 @@ else if ( $submit || $refresh || $mode != '' ) if ( $inbox_info = $db->sql_fetchrow($result) ) { - if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] ) + if ( $inbox_info['inbox_items'] >= $config['max_inbox_privmsgs'] ) { $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " @@ -1045,16 +1045,16 @@ else if ( $submit || $refresh || $mode != '' ) if ( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active'] ) { - $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; + $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n"; - $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path'])); + $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($config['script_path'])); $script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx; - $server_name = trim($board_config['server_name']); - $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; - $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; + $server_name = trim($config['server_name']); + $server_protocol = ( $config['cookie_secure'] ) ? 'https://' : 'http://'; + $server_port = ( $config['server_port'] <> 80 ) ? ':' . trim($config['server_port']) . '/' : '/'; include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer($board_config['smtp_delivery']); + $emailer = new emailer($config['smtp_delivery']); $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); $emailer->extra_headers($email_headers); @@ -1063,8 +1063,8 @@ else if ( $submit || $refresh || $mode != '' ) $emailer->assign_vars(array( 'USERNAME' => $to_username, - 'SITENAME' => $board_config['sitename'], - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), + 'SITENAME' => $config['sitename'], + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox') ); @@ -1106,14 +1106,14 @@ else if ( $submit || $refresh || $mode != '' ) { $page_title = $lang['Send_new_privmsg']; - $user_sig = ( $userdata['user_sig'] != '' && $board_config['allow_sig'] ) ? $userdata['user_sig'] : ''; + $user_sig = ( $userdata['user_sig'] != '' && $config['allow_sig'] ) ? $userdata['user_sig'] : ''; } else if ( $mode == 'reply' ) { $page_title = $lang['Reply_privmsg']; - $user_sig = ( $userdata['user_sig'] != '' && $board_config['allow_sig'] ) ? $userdata['user_sig'] : ''; + $user_sig = ( $userdata['user_sig'] != '' && $config['allow_sig'] ) ? $userdata['user_sig'] : ''; } else if ( $mode == 'edit' ) @@ -1133,7 +1133,7 @@ else if ( $submit || $refresh || $mode != '' ) message_die(MESSAGE, $lang['Sorry_edit_own_posts']); } - $user_sig = ( $postrow['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow['user_sig'] : ''; + $user_sig = ( $postrow['user_sig'] != '' && $config['allow_sig'] ) ? $postrow['user_sig'] : ''; } } } @@ -1195,7 +1195,7 @@ else if ( $submit || $refresh || $mode != '' ) $privmsg_message = str_replace('<br />', "\n", $privmsg_message); $privmsg_message = preg_replace('#</textarea>#si', '</textarea>', $privmsg_message); - $user_sig = ( $board_config['allow_sig'] ) ? $privmsg['user_sig'] : ''; + $user_sig = ( $config['allow_sig'] ) ? $privmsg['user_sig'] : ''; $to_username = $privmsg['username']; $to_userid = $privmsg['user_id']; @@ -1377,7 +1377,7 @@ else if ( $submit || $refresh || $mode != '' ) // // HTML toggle selection // - if ( $board_config['allow_html'] ) + if ( $config['allow_html'] ) { $html_status = $lang['HTML_is_ON']; $template->assign_block_vars('switch_html_checkbox', array()); @@ -1390,7 +1390,7 @@ else if ( $submit || $refresh || $mode != '' ) // // BBCode toggle selection // - if ( $board_config['allow_bbcode'] ) + if ( $config['allow_bbcode'] ) { $bbcode_status = $lang['BBCode_is_ON']; $template->assign_block_vars('switch_bbcode_checkbox', array()); @@ -1403,7 +1403,7 @@ else if ( $submit || $refresh || $mode != '' ) // // Smilies toggle selection // - if ( $board_config['allow_smilies'] ) + if ( $config['allow_smilies'] ) { $smilies_status = $lang['Smilies_are_ON']; $template->assign_block_vars('switch_smilies_checkbox', array()); @@ -1646,7 +1646,7 @@ else $post_days = 0; } -$sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . $board_config['topics_per_page']; +$sql .= $limit_msg_time . " ORDER BY pm.privmsgs_date DESC LIMIT $start, " . $config['topics_per_page']; $sql_all_tot = $sql_tot; $sql_tot .= $limit_msg_time_total; @@ -1717,25 +1717,25 @@ else if ( $folder == 'sentbox' ) // if ( $folder != 'outbox' ) { - if ( $board_config['max_' . $folder . '_privmsgs'] > 0 ) + if ( $config['max_' . $folder . '_privmsgs'] > 0 ) { - $inbox_limit_pct = round(( $pm_all_total / $board_config['max_' . $folder . '_privmsgs'] ) * 100); + $inbox_limit_pct = round(( $pm_all_total / $config['max_' . $folder . '_privmsgs'] ) * 100); } else { $inbox_limit_pct = 100; } - if ( $board_config['max_' . $folder . '_privmsgs'] > 0 ) + if ( $config['max_' . $folder . '_privmsgs'] > 0 ) { - $inbox_limit_img_length = round(( $pm_all_total / $board_config['max_' . $folder . '_privmsgs'] ) * $board_config['privmsg_graphic_length']); + $inbox_limit_img_length = round(( $pm_all_total / $config['max_' . $folder . '_privmsgs'] ) * $config['privmsg_graphic_length']); } else { - $inbox_limit_img_length = $board_config['privmsg_graphic_length']; + $inbox_limit_img_length = $config['privmsg_graphic_length']; } - if ( $board_config['max_' . $folder . '_privmsgs'] > 0 ) + if ( $config['max_' . $folder . '_privmsgs'] > 0 ) { - $inbox_limit_remain = $board_config['max_' . $folder . '_privmsgs'] - $pm_all_total; + $inbox_limit_remain = $config['max_' . $folder . '_privmsgs'] - $pm_all_total; } else { @@ -1865,8 +1865,8 @@ if ( $row = $db->sql_fetchrow($result) ) while( $row = $db->sql_fetchrow($result) ); $template->assign_vars(array( - 'PAGINATION' => generate_pagination("privmsg.$phpEx?folder=$folder", $pm_total, $board_config['topics_per_page'], $start), - 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $pm_total / $board_config['topics_per_page'] )), + 'PAGINATION' => generate_pagination("privmsg.$phpEx?folder=$folder", $pm_total, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $pm_total / $config['topics_per_page'] )), 'L_GOTO_PAGE' => $lang['Goto_page']) ); diff --git a/phpBB/profile.php b/phpBB/profile.php index 5443c5121d..20e33ce027 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -32,11 +32,11 @@ $auth->acl($user->data); // End session management // Set default email variables -$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path'])); +$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['script_path'])); $script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx; -$server_name = trim($board_config['server_name']); -$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; -$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; +$server_name = trim($config['server_name']); +$server_protocol = ( $config['cookie_secure'] ) ? 'https://' : 'http://'; +$server_port = ( $config['server_port'] <> 80 ) ? ':' . trim($config['server_port']) . '/' : '/'; $server_url = $server_protocol . $server_name . $server_port . $script_name; diff --git a/phpBB/search.php b/phpBB/search.php index 0b0176c79c..0cc1ea8fc5 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -206,8 +206,8 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } else if ( $search_keywords != '' ) { - $stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt'); - $synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_synonyms.txt'); + $stopword_array = @file($phpbb_root_path . 'language/lang_' . $config['default_lang'] . '/search_stopwords.txt'); + $synonym_array = @file($phpbb_root_path . 'language/lang_' . $config['default_lang'] . '/search_synonyms.txt'); $split_search = array(); $cleaned_search = clean_words('search', stripslashes($search_keywords), $stopword_array, $synonym_array); @@ -526,7 +526,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) // Store new result data // $search_results = implode(', ', $search_ids); - $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; + $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; // // Combine both results and search data (apart from original query) @@ -608,7 +608,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) AND u2.user_id = p2.poster_id"; } - $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; + $per_page = ( $show_results == 'posts' ) ? $config['posts_per_page'] : $config['topics_per_page']; $sql .= " ORDER BY "; switch ( $sort_by ) @@ -688,8 +688,8 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) $highlight_active = urlencode(trim($highlight_active)); - $tracking_topics = ( isset($_COOKIE[$board_config['cookie_name'] . '_t']) ) ? unserialize($_COOKIE[$board_config['cookie_name'] . '_t']) : array(); - $tracking_forums = ( isset($_COOKIE[$board_config['cookie_name'] . '_f']) ) ? unserialize($_COOKIE[$board_config['cookie_name'] . '_f']) : array(); + $tracking_topics = ( isset($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array(); + $tracking_forums = ( isset($_COOKIE[$config['cookie_name'] . '_f']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array(); for($i = 0; $i < count($searchset); $i++) { @@ -729,7 +729,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - if ( !$board_config['allow_html'] ) + if ( !$config['allow_html'] ) { if ( $postrow[$i]['enable_html'] ) { @@ -739,7 +739,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) if ( $bbcode_uid != '' ) { - $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); + $message = ( $config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); } $message = make_clickable($message); @@ -832,7 +832,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? $searchset[$i]['post_subject'] : $topic_title; } - if ($board_config['allow_smilies'] && $searchset[$i]['enable_smilies']) + if ($config['allow_smilies'] && $searchset[$i]['enable_smilies']) { $message = smilies_pass($message); } @@ -921,20 +921,20 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) $views = $searchset[$i]['topic_views']; $replies = $searchset[$i]['topic_replies']; - if ( ( $replies + 1 ) > $board_config['posts_per_page'] ) + if ( ( $replies + 1 ) > $config['posts_per_page'] ) { - $total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] ); + $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); $goto_page = ' [ ' . $user->img('icon_gotopost', $user->lang['Goto_page']) . $user->lang['Goto_page'] . ': '; $times = 1; - for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) + for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) { $goto_page .= '<a href="' . "viewtopic.$phpEx$SID&t=" . $topic_id . "&start=$j" . '">' . $times . '</a>'; if ( $times == 1 && $total_pages > 4 ) { $goto_page .= ' ... '; $times = $total_pages - 3; - $j += ( $total_pages - 4 ) * $board_config['posts_per_page']; + $j += ( $total_pages - 4 ) * $config['posts_per_page']; } else if ( $times < $total_pages ) { @@ -977,7 +977,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - if ( $replies >= $board_config['hot_threshold'] ) + if ( $replies >= $config['hot_threshold'] ) { $folder = 'folder_hot'; $folder_new ='folder_hot_new'; @@ -993,7 +993,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) { if ( $searchset[$i]['post_time'] > $user->data['session_last_visit'] ) { - if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$board_config['cookie_name'] . '_f_all']) ) + if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) { $unread_topics = true; @@ -1014,9 +1014,9 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } } - if ( isset($_COOKIE[$board_config['cookie_name'] . '_f_all']) ) + if ( isset($_COOKIE[$config['cookie_name'] . '_f_all']) ) { - if ( $_COOKIE[$board_config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) + if ( $_COOKIE[$config['cookie_name'] . '_f_all'] > $searchset[$i]['post_time'] ) { $unread_topics = false; } diff --git a/phpBB/templates/subSilver/posting_body.html b/phpBB/templates/subSilver/posting_body.html index 6c35f9c5fd..de485dd3eb 100644 --- a/phpBB/templates/subSilver/posting_body.html +++ b/phpBB/templates/subSilver/posting_body.html @@ -224,12 +224,22 @@ function storeCaret(textEl) { </table> {POST_PREVIEW_BOX} -{ERROR_BOX} <table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> <tr> <th class="thHead" colspan="2" height="25"><b>{L_POST_A}</b></th> </tr> + <!-- IF ERROR_MESSAGE neq '' --> + <tr> + <td class="row2" colspan="2" align="center"><span class="gen" style="color:red">{ERROR_MESSAGE}</span></td> + </tr> + <!-- ENDIF --> + <!-- IF S_DELETE_ALLOWED --> + <tr> + <td class="row1"><span class="gen"><b>{L_DELETE_POST}</b></span></td> + <td class="row2"><input type="checkbox" name="delete" /></td> + </tr> + <!-- ENDIF --> <!-- IF S_DISPLAY_USERNAME --> <tr> <td class="row1"><span class="gen"><b>{L_USERNAME}</b></span></td> @@ -378,12 +388,6 @@ function storeCaret(textEl) { <td><span class="gen">{L_NOTIFY_ON_REPLY}</span></td> </tr> <!-- ENDIF --> - <!-- IF S_DELETE_ALLOWED --> - <tr> - <td><input type="checkbox" name="delete" /></td> - <td><span class="gen">{L_DELETE_POST}</span></td> - </tr> - <!-- ENDIF --> <!-- IF S_TYPE_TOGGLE --> <tr> <td></td> @@ -403,15 +407,9 @@ function storeCaret(textEl) { <td class="row1"><span class="gen"><b>{L_POLL_QUESTION}</b></span></td> <td class="row2"><span class="genmed"><input type="text" name="poll_title" size="50" maxlength="255" class="post" value="{POLL_TITLE}" /></span></td> </tr> - <!-- BEGIN poll_options --> - <tr> - <td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td> - <td class="row2"><span class="genmed"><input type="text" name="poll_option_text[{poll_options.S_POLL_OPTION_NUM}]" size="50" class="post" maxlength="255" value="{poll_options.POLL_OPTION}" /></span> <input class="liteoption" type="submit" name="edit_poll_option" value="{L_UPDATE_OPTION}" /> <input class="liteoption" type="submit" name="del_poll_option[{poll_options.S_POLL_OPTION_NUM}]" value="{L_DELETE_OPTION}" /></td> - </tr> - <!-- END poll_options --> <tr> - <td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td> - <td class="row2"><span class="genmed"><input type="text" name="add_poll_option_text" size="50" maxlength="255" class="post" value="{ADD_POLL_OPTION}" /></span> <input class="liteoption" type="submit" name="add_poll_option" value="{L_ADD_OPTION}" /></td> + <td class="row1"><span class="gen"><b>{L_POLL_OPTIONS}</b></span><br /><span class="gensmall">{L_POLL_OPTIONS_EXPLAIN}</span></td> + <td class="row2"><span class="genmed"><textarea name="poll_option_text" rows="5" cols="35" wrap="virtual" style="width:450px" class="post">{POLL_OPTIONS}</textarea></td> </tr> <tr> <td class="row1"><span class="gen"><b>{L_POLL_LENGTH}</b></span></td> diff --git a/phpBB/templates/subSilver/viewtopic_body.html b/phpBB/templates/subSilver/viewtopic_body.html index 66eb3b5091..af4314ec23 100644 --- a/phpBB/templates/subSilver/viewtopic_body.html +++ b/phpBB/templates/subSilver/viewtopic_body.html @@ -54,9 +54,9 @@ <td><span class="gen">{poll_option.POLL_OPTION_CAPTION}</span></td> <td><table cellspacing="0" cellpadding="0" border="0"> <tr> - <td><img src="templates/subSilver/images/vote_lcap.gif" width="4" alt="" height="12" /></td> - <td><img src="{poll_option.POLL_OPTION_IMG}" width="{poll_option.POLL_OPTION_IMG_WIDTH}" height="12" alt="{poll_option.POLL_OPTION_PERCENT}" /></td> - <td><img src="templates/subSilver/images/vote_rcap.gif" width="4" alt="" height="12" /></td> + <td>{POLL_LEFT_CAP_IMG}</td> + <td>{poll_option.POLL_OPTION_IMG}</td> + <td>{POLL_RIGHT_CAP_IMG}</td> </tr> </table></td> <td align="center"><b><span class="gen"> {poll_option.POLL_OPTION_PERCENT} </span></b></td> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 8d971480cb..7b5e25f59f 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -155,8 +155,8 @@ foreach ($forum_branch as $row) } // Topic read tracking cookie info -$mark_topics = ( isset($_COOKIE[$board_config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_t'])) : array(); -$mark_forums = ( isset($_COOKIE[$board_config['cookie_name'] . '_f']) ) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_f'])) : array(); +$mark_topics = ( isset($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); +$mark_forums = ( isset($_COOKIE[$config['cookie_name'] . '_f']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array(); // Handle marking posts if ( $mark_read == 'topics' ) @@ -165,7 +165,7 @@ if ( $mark_read == 'topics' ) { $mark_forums[$forum_id] = time(); - setcookie($board_config['cookie_name'] . '_f', serialize($mark_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + setcookie($config['cookie_name'] . '_f', serialize($mark_forums), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); $template->assign_vars(array( 'META' => '<meta http-equiv="refresh" content="3;url=' . "viewforum.$phpEx$SID&f=$forum_id" . '">') @@ -178,7 +178,7 @@ if ( $mark_read == 'topics' ) // End handle marking posts // Do the forum Prune -if ( $auth->acl_get('m_prune', $forum_id) && $board_config['prune_enable'] ) +if ( $auth->acl_get('m_prune', $forum_id) && $config['prune_enable'] ) { if ( $forum_data['prune_next'] < time() && $forum_data['prune_enable'] ) { @@ -272,8 +272,8 @@ $template->assign_vars(array( 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_data['forum_name'], 'POST_IMG' => ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $user->img('post_locked', $post_alt) : $user->img('post_new', $post_alt), - 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start), - 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )), + 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&topicdays=$topic_days", $topics_count, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['topics_per_page'] ) + 1 ), ceil( $topics_count / $config['topics_per_page'] )), 'MOD_CP' => ( $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>') : '', 'FOLDER_IMG' => $user->img('folder', 'No_new_posts'), @@ -367,7 +367,7 @@ if ( $start ) AND u.user_id = t.topic_poster AND u2.user_id = t.topic_last_poster_id ORDER BY $sort_order - LIMIT " . $board_config['topics_per_page']; + LIMIT " . $config['topics_per_page']; $result = $db->sql_query($sql); while( $row = $db->sql_fetchrow($result) ) @@ -386,7 +386,7 @@ $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as i AND u2.user_id = t.topic_last_poster_id $limit_topics_time ORDER BY t.topic_type DESC, $sort_order - LIMIT $start, " . $board_config['topics_per_page']; + LIMIT $start, " . $config['topics_per_page']; $result = $db->sql_query($sql); while( $row = $db->sql_fetchrow($result) ) @@ -433,7 +433,7 @@ if ( $total_topics ) $folder_new = 'folder_locked_new'; break; default: - if ( $replies >= $board_config['hot_threshold'] ) + if ( $replies >= $config['hot_threshold'] ) { $folder = 'folder_hot'; $folder_new = 'folder_hot_new'; @@ -464,20 +464,20 @@ if ( $total_topics ) } // Goto message - if ( ( $replies + 1 ) > $board_config['posts_per_page'] ) + if ( ( $replies + 1 ) > $config['posts_per_page'] ) { - $total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] ); + $total_pages = ceil( ( $replies + 1 ) / $config['posts_per_page'] ); $goto_page = ' [ <img src=' . $theme['goto_post'] . ' alt="' . $user->lang['Goto_page'] . '" title="' . $user->lang['Goto_page'] . '" />' . $user->lang['Goto_page'] . ': '; $times = 1; - for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) + for($j = 0; $j < $replies + 1; $j += $config['posts_per_page']) { $goto_page .= '<a href="viewtopic.' . $phpEx . $SID . '&t=' . $topic_id . '&start=' . $j . '">' . $times . '</a>'; if ( $times == 1 && $total_pages > 4 ) { $goto_page .= ' ... '; $times = $total_pages - 3; - $j += ( $total_pages - 4 ) * $board_config['posts_per_page']; + $j += ( $total_pages - 4 ) * $config['posts_per_page']; } else if ( $times < $total_pages ) { @@ -500,7 +500,7 @@ if ( $total_topics ) $topic_author .= ( $topic_rowset[$i]['user_id'] ) ? '</a>' : ''; - $first_post_time = $user->format_date($topic_rowset[$i]['topic_time'], $board_config['board_timezone']); + $first_post_time = $user->format_date($topic_rowset[$i]['topic_time'], $config['board_timezone']); $last_post_time = $user->format_date($topic_rowset[$i]['topic_last_post_time']); @@ -526,7 +526,7 @@ if ( $total_topics ) 'VIEWS' => $topic_rowset[$i]['topic_views'], 'TOPIC_TITLE' => ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'], 'TOPIC_TYPE' => $topic_type, - 'TOPIC_ICON' => ( !empty($topic_rowset[$i]['topic_icon']) ) ? '<img src="' . $board_config['icons_path'] . '/' . $topic_icons[$topic_rowset[$i]['topic_icon']]['img'] . '" width="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['width'] . '" height="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['height'] . '" alt="" title="" />' : '', + 'TOPIC_ICON' => ( !empty($topic_rowset[$i]['topic_icon']) ) ? '<img src="' . $config['icons_path'] . '/' . $topic_icons[$topic_rowset[$i]['topic_icon']]['img'] . '" width="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['width'] . '" height="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['height'] . '" alt="" title="" />' : '', 'TOPIC_RATING' => ( !empty($topic_rowset[$i]['topic_rating']) ) ? '<img src=' . str_replace('{RATE}', $topic_rowset[$i]['topic_rating'], $theme['rating']) . ' alt="' . $topic_rowset[$i]['topic_rating'] . '" title="' . $topic_rowset[$i]['topic_rating'] . '" />' : '', 'S_ROW_COUNT' => $i, @@ -538,7 +538,7 @@ if ( $total_topics ) if ($user->data['user_id'] != ANONYMOUS) { - setcookie($board_config['cookie_name'] . '_t', serialize($mark_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + setcookie($config['cookie_name'] . '_t', serialize($mark_topics), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); } // Dump out the page header and load viewforum template @@ -546,7 +546,7 @@ $page_title = $user->lang['View_forum'] . ' - ' . $forum_data['forum_name']; $nav_links['up'] = array( 'url' => 'index.' . $phpEx . $SID, - 'title' => sprintf($user->lang['Forum_Index'], $board_config['sitename']) + 'title' => sprintf($user->lang['Forum_Index'], $config['sitename']) ); include($phpbb_root_path . 'includes/page_header.'.$phpEx); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1230369ac6..14e856aa68 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -45,9 +45,9 @@ if (isset($_GET['view']) && empty($post_id)) { if ( $_GET['view'] == 'newest' ) { - if ( isset($_COOKIE[$board_config['cookie_name'] . '_sid']) ) + if ( isset($_COOKIE[$config['cookie_name'] . '_sid']) ) { - $session_id = $_COOKIE[$board_config['cookie_name'] . '_sid']; + $session_id = $_COOKIE[$config['cookie_name'] . '_sid']; if ( $session_id ) { @@ -135,7 +135,7 @@ $join_sql = ( !$post_id ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND $count_sql = ( !$post_id ) ? '' : ", COUNT(p2.post_id) AS prev_posts"; $order_sql = ( !$post_id ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; -$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style" . $count_sql . " +$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_status, f.forum_id, f.forum_style" . $count_sql . " FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " WHERE $join_sql AND f.forum_id = t.forum_id @@ -172,7 +172,7 @@ if ( !$auth->acl_get('f_read', $forum_id) ) if ( !empty($post_id) ) { - $start = floor(($prev_posts - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page']; + $start = floor(($prev_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; } $s_watching_topic = ''; @@ -337,7 +337,7 @@ $topic_mod .= ( $auth->acl_get('m_merge', $forum_id) ) ? '<option value="merge"> // // If we've got a hightlight set pass it on to pagination. // -$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $_GET['highlight'], $topic_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order", $topic_replies, $board_config['posts_per_page'], $start); +$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $_GET['highlight'], $topic_replies, $config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order", $topic_replies, $config['posts_per_page'], $start); // // Post, reply and other URL generation for @@ -357,10 +357,10 @@ $post_img = ( $forum_status == FORUM_LOCKED ) ? $user->img('post_locked', $user- // if ($user->data['user_id'] != ANONYMOUS) { - $mark_topics = ( isset($_COOKIE[$board_config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_t'])) : array(); + $mark_topics = ( isset($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); $mark_topics[$forum_id][$topic_id] = 0; - setcookie($board_config['cookie_name'] . '_t', serialize($mark_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + setcookie($config['cookie_name'] . '_t', serialize($mark_topics), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); } @@ -388,7 +388,7 @@ $template->assign_vars(array( 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_title, 'PAGINATION' => $pagination, - 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $board_config['posts_per_page'] ) + 1 ), ceil( $topic_replies / $board_config['posts_per_page'] )), + 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['posts_per_page'] ) + 1 ), ceil( $topic_replies / $config['posts_per_page'] )), 'MOD_CP' => ( $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>') : '', 'POST_IMG' => $post_img, @@ -450,133 +450,75 @@ $nav_links['up'] = array( // // Does this topic contain a poll? // -if ( !empty($poll_start) ) +if (!empty($poll_start)) { - $sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result - FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr - WHERE vd.topic_id = $topic_id - AND vr.vote_id = vd.vote_id - ORDER BY vr.vote_option_id ASC"; + $sql = "SELECT * + FROM " . POLL_OPTIONS_TABLE . " + WHERE topic_id = $topic_id + ORDER BY poll_option_id"; $result = $db->sql_query($sql); - if ( $vote_info = $db->sql_fetchrowset($result) ) + while ( $row = $db->sql_fetchrow($result)) { - $db->sql_freeresult($result); - $vote_options = count($vote_info); - - $vote_id = $vote_info[0]['vote_id']; - $vote_title = $vote_info[0]['vote_text']; - - $sql = "SELECT vote_id - FROM " . VOTE_USERS_TABLE . " - WHERE vote_id = $vote_id - AND vote_user_id = " . $user->data['user_id']; - $result = $db->sql_query($sql); - - $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; - $db->sql_freeresult($result); - - if ( isset($_GET['vote']) || isset($_POST['vote']) ) - { - $view_result = ( ( ( isset($_GET['vote']) ) ? $_GET['vote'] : $_POST['vote'] ) == 'viewresult' ) ? TRUE : 0; - } - else - { - $view_result = 0; - } - - $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; - - if ( $user_voted || $view_result || $poll_expired || !$auth->acl_get('f_vote', $forum_id) || $topic_status == TOPIC_LOCKED ) - { - $vote_results_sum = 0; - for($i = 0; $i < $vote_options; $i++) - { - $vote_results_sum += $vote_info[$i]['vote_result']; - } - - for($i = 0; $i < $vote_options; $i++) - { - $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0; - $poll_length = round($vote_percent * $board_config['vote_graphic_length']); - $vote_percent = sprintf("%.1d%%", ($vote_percent * 100)); - $vote_graphic_img = $user->img($theme['voting_graphic'] . ' width="' . $poll_length . '"', $vote_percent); - - if ( count($orig_word) ) - { - $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); - } - - $template->assign_block_vars('poll_option', array( - 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], - 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], - 'POLL_OPTION_PERCENT' => $vote_percent, - - 'POLL_OPTION_IMG' => $vote_graphic_img) - ); - } - - $template->assign_vars(array( - 'S_HAS_POLL_DISPLAY' => true, + $poll_info[] = $row; + } + $db->sql_freeresult($result); - 'L_TOTAL_VOTES' => $user->lang['Total_votes'], - 'TOTAL_VOTES' => $vote_results_sum) - ); + $sql = "SELECT poll_option_id + FROM " . POLL_VOTES_TABLE . " + WHERE topic_id = $topic_id + AND vote_user_id = " . $user->data['user_id']; + $result = $db->sql_query($sql); - } - else - { - for($i = 0; $i < $vote_options; $i++) - { - if ( count($orig_word) ) - { - $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); - } + $voted_id = ($row = $db->sql_fetchrow($result)) ? $row['poll_option_id'] : false; + $db->sql_freeresult($result); - $template->assign_block_vars('poll_option', array( - 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], - 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text']) - ); - } + $display_results = ($voted_id || ($poll_length != 0 && $poll_start + $poll_length < time()) || $_GET['vote'] == 'viewresult' || !$auth->acl_get('f_vote', $forum_id) || $topic_status == TOPIC_LOCKED) ? true : false; - $template->assign_vars(array( - 'S_HAS_POLL_OPTIONS' => true, + $poll_total = 0; + foreach ($poll_info as $poll_option) + { + $poll_total += $poll_option['poll_option_total']; + } - 'L_SUBMIT_VOTE' => $user->lang['Submit_vote'], - 'L_VIEW_RESULTS' => $user->lang['View_results'], + foreach ($poll_info as $poll_option) + { + $poll_option['poll_option_text'] = (sizeof($orig_word)) ? preg_replace($orig_word, $replacement_word, $poll_option['poll_option_text']) : $poll_option['poll_option_text']; + $option_pct = ( $poll_total > 0 ) ? $poll_option['poll_option_total'] / $poll_total : 0; + $option_pct_txt = sprintf("%.1d%%", ($option_pct * 100)); + + $template->assign_block_vars('poll_option', array( + 'POLL_OPTION_ID' => $poll_option['poll_option_id'], + 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'], + 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'], + 'POLL_OPTION_PERCENT' => $vote_percent, + 'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * $user->theme['poll_length']), true)) + ); + } - 'U_VIEW_RESULTS' => "viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult") - ); + $poll_title = (sizeof($orig_word)) ? preg_replace($orig_word, $replacement_word, $poll_title) : $poll_title; - $s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '"><input type="hidden" name="mode" value="vote">'; - } + $template->assign_vars(array( + 'POLL_QUESTION' => $poll_title, + 'TOTAL_VOTES' => $poll_total, + 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), + 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), - if ( count($orig_word) ) - { - $vote_title = preg_replace($orig_word, $replacement_word, $vote_title); - } + 'S_HAS_POLL_OPTIONS' => !$display_results, + 'S_HAS_POLL_DISPLAY' => $display_results, - $template->assign_vars(array( - 'POLL_QUESTION' => $vote_title, + 'L_SUBMIT_VOTE' => $user->lang['Submit_vote'], + 'L_VIEW_RESULTS'=> $user->lang['View_results'], + 'L_TOTAL_VOTES' => $user->lang['Total_votes'], - 'S_HIDDEN_FIELDS' => ( !empty($s_hidden_fields) ) ? $s_hidden_fields : '', - 'S_POLL_ACTION' => "posting.$phpEx$SID&t=$topic_id") - ); - } + 'U_VIEW_RESULTS' => "viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult") + ); } -// // Container for user details, only process once -// $poster_details = array(); -// // Go ahead and pull all data for this topic -// -// FROM phpbb_posts2 p, " . USERS_TABLE . " u -// AND pt.post_id = p.post_id -// pt.post_text, pt.post_subject, pt.bbcode_uid - $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id @@ -585,7 +527,7 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, $limit_posts_time AND u.user_id = p.poster_id ORDER BY $sort_order - LIMIT $start, " . $board_config['posts_per_page']; + LIMIT $start, " . $config['posts_per_page']; $result = $db->sql_query($sql); if ( $row = $db->sql_fetchrow($result) ) @@ -611,13 +553,13 @@ if ( $row = $db->sql_fetchrow($result) ) switch( $row['user_avatar_type'] ) { case USER_AVATAR_UPLOAD: - $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_upload'] ) ? '<img src="' . $config['avatar_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; case USER_AVATAR_REMOTE: - $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; case USER_AVATAR_GALLERY: - $poster_details[$poster_id]['avatar'] = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_local'] ) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; } } @@ -677,7 +619,7 @@ if ( $row = $db->sql_fetchrow($result) ) if ( !empty($row['user_viewemail']) || $auth->acl_get('m_', $forum_id) ) { - $email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email']; + $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email']; $poster_details[$poster_id]['email_img'] = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>'; $poster_details[$poster_id]['email'] = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>'; @@ -939,7 +881,7 @@ if ( $row = $db->sql_fetchrow($result) ) // if ( !isset($poster_details[$poster_id]['sig']) ) { - $user_sig = ( $row['enable_sig'] && $row['user_sig'] != '' && $board_config['allow_sig'] ) ? $row['user_sig'] : ''; + $user_sig = ( $row['enable_sig'] && $row['user_sig'] != '' && $config['allow_sig'] ) ? $row['user_sig'] : ''; $user_sig_bbcode_uid = $row['user_sig_bbcode_uid']; if ( $user_sig != '' && $user_sig_bbcode_uid != '' && $auth->acl_get('f_sigs', $forum_id) ) |