From b776d02682492077a4fafd8835d7c4a17e50762d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 2 Jun 2009 14:12:23 +0000 Subject: Okay, a first ci of the new captcha plugins. We'll add dynamic template includes later, as well as documentation on how to use this. I'm prepared to get yelled at for bugs (oh, I know that there are plenty); but please blame spammers for broken styles and MODs. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9524 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_captcha.php | 177 +++-- phpBB/includes/auth/auth_db.php | 39 +- phpBB/includes/captcha/captcha_factory.php | 92 +++ phpBB/includes/captcha/captcha_gd_wave.php | 842 +++++++++++++++++++++ phpBB/includes/captcha/captcha_plugin.php | 97 +++ .../includes/captcha/plugins/captcha_abstract.php | 332 ++++++++ .../captcha/plugins/phpbb_captcha_gd_plugin.php | 122 +++ .../plugins/phpbb_captcha_gd_wave_plugin.php | 66 ++ .../captcha/plugins/phpbb_captcha_nogd_plugin.php | 68 ++ .../captcha/plugins/phpbb_recaptcha_plugin.php | 312 ++++++++ phpBB/includes/functions.php | 33 +- phpBB/includes/session.php | 40 +- phpBB/includes/ucp/ucp_confirm.php | 42 +- phpBB/includes/ucp/ucp_register.php | 168 ++-- 14 files changed, 2097 insertions(+), 333 deletions(-) create mode 100755 phpBB/includes/captcha/captcha_factory.php create mode 100755 phpBB/includes/captcha/captcha_gd_wave.php create mode 100755 phpBB/includes/captcha/captcha_plugin.php create mode 100755 phpBB/includes/captcha/plugins/captcha_abstract.php create mode 100755 phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php create mode 100755 phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php create mode 100755 phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php create mode 100644 phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 93505e1590..ed2ccf6ccc 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -10,6 +10,8 @@ /** * @ignore */ + + if (!defined('IN_PHPBB')) { exit; @@ -28,108 +30,119 @@ class acp_captcha global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); - $captcha_vars = array( - 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', - 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', - 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', - 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', - 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', - 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', - 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', - ); + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - if (isset($_GET['demo'])) + $selected = request_var('select_captcha', $config['captcha_plugin']); + $configure = request_var('configure', false); + + // Oh, they are just here for the view + if (isset($_GET['captcha_demo'])) { - $captcha_vars = array_keys($captcha_vars); - - foreach ($captcha_vars as $captcha_var) - { - $config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; - } - - if ($config['captcha_gd']) - { - include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); - } - else - { - include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); - } - - $captcha = new captcha(); - $captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time()); - exit; + $this->deliver_demo($selected); } - - $config_vars = array( - 'enable_confirm' => 'REG_ENABLE', - 'enable_post_confirm' => 'POST_ENABLE', - 'confirm_refresh' => 'CONFIRM_REFRESH', - 'captcha_gd' => 'CAPTCHA_GD', - ); - - $this->tpl_name = 'acp_captcha'; - $this->page_title = 'ACP_VC_SETTINGS'; - $form_key = 'acp_captcha'; - add_form_key($form_key); - - $submit = request_var('submit', ''); - - if ($submit && check_form_key($form_key)) + + // Delegate + if ($configure) { - $config_vars = array_keys($config_vars); + $config_captcha = phpbb_captcha_factory::get_instance($selected); + $config_captcha->acp_page($id, $this); + add_log('admin', 'LOG_CONFIG_VISUAL'); + } + else + { + $captchas = phpbb_captcha_factory::get_captcha_types(); + $config_vars = array( + 'enable_confirm' => 'REG_ENABLE', + 'enable_post_confirm' => 'POST_ENABLE', + 'confirm_refresh' => 'CONFIRM_REFRESH', + ); - foreach ($config_vars as $config_var) - { - set_config($config_var, request_var($config_var, '')); - } + $this->tpl_name = 'acp_captcha'; + $this->page_title = 'ACP_VC_SETTINGS'; + $form_key = 'acp_captcha'; + add_form_key($form_key); - $captcha_vars = array_keys($captcha_vars); + $submit = request_var('main_submit', false); - foreach ($captcha_vars as $captcha_var) + if ($submit && check_form_key($form_key)) { - $value = request_var($captcha_var, 0); - if ($value >= 0) + $config_vars = array_keys($config_vars); + foreach ($config_vars as $config_var) { - set_config($captcha_var, $value); + set_config($config_var, request_var($config_var, false)); } + if ($selected !== $config['captcha_plugin']) + { + // sanity check + if (isset($captchas['available'][$selected])) + { + $old_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $old_captcha->uninstall(); + set_config('captcha_plugin', $selected); + $new_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $old_captcha->install(); + add_log('admin', 'LOG_CONFIG_VISUAL'); + } + else + { + trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action)); + } + } + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } - - add_log('admin', 'LOG_CONFIG_VISUAL'); - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - else if ($submit) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action)); - } - else - { - $preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&demo=demo")); - - if (@extension_loaded('gd')) + else if ($submit) { - $template->assign_var('GD', true); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link()); } - - foreach ($config_vars as $config_var => $template_var) + else { - $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; - } + $captcha_select = ''; + foreach ($captchas['available'] as $value => $title) + { + $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; + $captcha_select .= ''; + } + foreach ($captchas['unavailable'] as $value => $title) + { + $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; + $captcha_select .= ''; + } - foreach ($captcha_vars as $captcha_var => $template_var) - { - $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; - $template->assign_var($template_var, $var); - $preview_image_src .= "&$captcha_var=" . $var; + $demo_captcha = phpbb_captcha_factory::get_instance($selected); + + foreach ($config_vars as $config_var => $template_var) + { + $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; + } + + $template->assign_vars(array( + 'CAPTCHA_PREVIEW' => $demo_captcha->get_demo_template($id), + 'CAPTCHA_SELECT' => $captcha_select, + )); } - $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $preview_image_src, - 'PREVIEW' => isset($_POST['preview']), - )); } } + + + /** + * Entry point for delivering image CAPTCHAs in the ACP. + */ + function deliver_demo($selected) + { + global $db, $user, $config; + + $captcha = phpbb_captcha_factory::get_instance($selected); + $captcha->init(CONFIRM_REG); + $captcha->execute_demo(); + garbage_collection(); + exit_handler(); + } + + + + } ?> \ No newline at end of file diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index 24d4c56614..bdafefa70b 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -81,42 +81,15 @@ function login_db(&$username, &$password) } else { - global $user; - - $sql = 'SELECT code - FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_LOGIN; - $result = $db->sql_query($sql); - $confirm_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($confirm_row) + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_LOGIN); + $vc_response = $captcha->validate(); + if ($vc_response) { - if (strcasecmp($confirm_row['code'], $confirm_code) === 0) - { - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_LOGIN; - $db->sql_query($sql); - } - else - { - return array( + return array( 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'CONFIRM_CODE_WRONG', + 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', 'user_row' => $row, - ); - } - } - else - { - return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'CONFIRM_CODE_WRONG', - 'user_row' => $row, ); } } diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php new file mode 100755 index 0000000000..e6f56172ec --- /dev/null +++ b/phpBB/includes/captcha/captcha_factory.php @@ -0,0 +1,92 @@ +width; + $img_y = $this->height; + + // Generate image + $img = imagecreatetruecolor($img_x, $img_y); + $x_grid = mt_rand(6, 10); + $y_grid = mt_rand(6, 10); + + // Ok, so lets cut to the chase. We could accurately represent this in 3d and + // do all the appropriate linear transforms. my questions is... why bother? + // The computational overhead is unnecessary when you consider the simple fact: + // we're not here to accurately represent a model, but to just show off some random-ish + // polygons + + // Conceive of 3 spaces. + // 1) planar-space (discrete "pixel" grid) + // 2) 3-space. (planar-space with z/height aspect) + // 3) image space (pixels on the screen) + // resolution of the planar-space we're embedding the text code in + $plane_x = 100; + $plane_y = 30; + + $subdivision_factor = 3; + // $box is the 4 points in img_space that correspond to the corners of the plane in 3-space + $box = array( + 'upper_left' => array( + 'x' => mt_rand(5, 15), + 'y' => mt_rand(10, 15) + ), + 'upper_right' => array( + 'x' => mt_rand($img_x - 35, $img_x - 19), + 'y' => mt_rand(10, 17) + ), + 'lower_left' => array( + 'x' => mt_rand($img_x - 5, $img_x - 45), + 'y' => mt_rand($img_y - 0, $img_y - 15) + ), + ); + $box['lower_right'] = array( + 'x' => $box['lower_left']['x'] + $box['upper_left']['x'] - $box['upper_right']['x'], + 'y' => $box['lower_left']['y'] + $box['upper_left']['y'] - $box['upper_right']['y'], + ); + + + // TODO + $background = imagecolorallocate($img, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255)); + imagefill($img, 0, 0, $background); + $black = imagecolorallocate($img, 0, 0, 0); + + $random = array(); + $fontcolors = array(); + + for ($i = 0; $i < 15; ++$i) + { + $random[$i] = imagecolorallocate($img, mt_rand(120, 255), mt_rand(120, 255), mt_rand(120, 255)); + } + + $fontcolors[0] = imagecolorallocate($img, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120)); + + $colors = array(); + + $minr = mt_rand(20, 30); + $ming = mt_rand(20, 30); + $minb = mt_rand(20, 30); + + $maxr = mt_rand(150, 230); + $maxg = mt_rand(150, 230); + $maxb = mt_rand(150, 230); + + for ($i = -30; $i <= 30; ++$i) + { + $coeff1 = ($i + 12) / 45; + $coeff2 = 1 - $coeff1; + $colors[$i] = imagecolorallocate($img, ($coeff2 * $maxr) + ($coeff1 * $minr), ($coeff2 * $maxg) + ($coeff1 * $ming), ($coeff2 * $maxb) + ($coeff1 * $minb)); + } + + // $img_buffer is the last row of 3-space positions (converted to img-space), cached + // (using this means we don't need to recalculate all 4 positions for each new polygon, + // merely the newest point that we're adding, which is then cached. + $img_buffer = array(array(), array()); + + // In image-space, the x- and y-offset necessary to move one unit in the x-direction in planar-space + $dxx = ($box['upper_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_x); + $dxy = ($box['upper_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_x); + + // In image-space, the x- and y-offset necessary to move one unit in the y-direction in planar-space + $dyx = ($box['lower_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_y); + $dyy = ($box['lower_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_y); + + // Initial captcha-letter offset in planar-space + $plane_offset_x = mt_rand(3, 8); + $plane_offset_y = mt_rand( 12, 15); + + // character map + $map = $this->captcha_bitmaps(); + + // matrix + $plane = array(); + + // for each character, we'll silkscreen it into our boolean pixel plane + for ($c = 0, $code_num = strlen($code); $c < $code_num; ++$c) + { + $letter = $code[$c]; + + for ($x = $map['width'] - 1; $x >= 0; --$x) + { + for ($y = $map['height'] - 1; $y >= 0; --$y) + { + if ($map['data'][$letter][$y][$x]) + { + $plane[$y + $plane_offset_y + (($c & 1) ? 1 : -1)][$x + $plane_offset_x] = true; + } + } + } + $plane_offset_x += 11; + } + + // calculate our first buffer, we can't actually draw polys with these yet + // img_pos_prev == screen x,y location to our immediate left. + // img_pos_cur == current screen x,y location + // we calculate screen position of our + // current cell based on the difference from the previous cell + // rather than recalculating from absolute coordinates + // What we cache into the $img_buffer contains the raised text coordinates. + $img_pos_prev = $img_buffer[0][0] = array($box['upper_left']['x'], $box['upper_left']['y']); + $cur_height = $prev_height = $this->wave_height(0, 0, $subdivision_factor); + $full_x = $plane_x * $subdivision_factor; + $full_y = $plane_y * $subdivision_factor; + + for ($x = 1; $x <= $full_x; ++$x) + { + $cur_height = $this->wave_height($x, 0, $subdivision_factor); + $offset = $cur_height - $prev_height; + $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); + + $img_buffer[0][$x] = $img_pos_cur; + $img_pos_prev = $img_pos_cur; + $prev_height = $cur_height; + } + + for ($y = 1; $y <= $full_y; ++$y) + { + // swap buffers + $buffer_cur = $y & 1; + $buffer_prev = 1 - $buffer_cur; + + $prev_height = $this->wave_height(0, $y, $subdivision_factor); + $offset = $prev_height - $this->wave_height(0, $y - 1, $subdivision_factor); + $img_pos_cur = array($img_buffer[$buffer_prev][0][0] + $dyx, min($img_buffer[$buffer_prev][0][1] + $dyy + $offset, $img_y - 1)); + + // make sure we don't try to write off the page + $img_pos_prev = $img_pos_cur; + + $img_buffer[$buffer_cur][0] = $img_pos_cur; + + for ($x = 1; $x <= $full_x; ++$x) + { + $cur_height = $this->wave_height($x, $y, $subdivision_factor) + $this->grid_height($x, $y, 1, $x_grid, $y_grid); + + // height is a z-factor, not a y-factor + $offset = $cur_height - $prev_height; + $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); + + // height is float, index it to an int, get closest color + $color = $colors[intval($cur_height)]; + $img_pos_prev = $img_pos_cur; + $prev_height = $cur_height; + + $y_index_old = intval(($y - 1) / $subdivision_factor); + $y_index_new = intval($y / $subdivision_factor); + $x_index_old = intval(($x - 1) / $subdivision_factor); + $x_index_new = intval($x / $subdivision_factor); + + if (!empty($plane[$y_index_new][$x_index_new])) + { + $img_pos_cur[1] += $this->wave_height($x, $y, $subdivision_factor, 1) - 30 - $cur_height; + $color = $colors[20]; + } + $img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1); + $img_buffer[$buffer_cur][$x] = $img_pos_cur; + + // Smooth the edges as much as possible by having not more than one low<->high traingle per square + // Otherwise, just + $diag_down = (empty($plane[$y_index_old][$x_index_old]) == empty($plane[$y_index_new][$x_index_new])); + $diag_up = (empty($plane[$y_index_old][$x_index_new]) == empty($plane[$y_index_new][$x_index_old])); + + // natural switching + $mode = ($x + $y) & 1; + + // override if it requires it + if ($diag_down != $diag_up) + { + $mode = $diag_up; + } + + if ($mode) + { + // +-/ / + // 1 |/ 2 /| + // / /-+ + $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x]); + $poly2 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_cur][$x], $img_buffer[$buffer_prev][$x]); + } + else + { + // \ \-+ + // 1 |\ 2 \| + // +-\ \ + $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_cur][$x]); + $poly2 = array_merge($img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x], $img_buffer[$buffer_cur][$x]); + } + + imagefilledpolygon($img, $poly1, 3, $color); + imagefilledpolygon($img, $poly2, 3, $color); + } + } + + // Output image + header('Content-Type: image/png'); + header('Cache-control: no-cache, no-store'); + //$mtime = explode(' ', microtime()); + //$totaltime = $mtime[0] + $mtime[1] - $starttime; + + //echo $totaltime . "
\n"; + //echo memory_get_usage() - $tmp; + imagepng($img); + imagedestroy($img); + } + + function wave_height($x, $y, $factor = 1, $tweak = 0.7) + { + // stretch the wave. TODO: pretty it up + $x = $x/5 + 180; + $y = $y/4; + return ((sin($x / (3 * $factor)) + sin($y / (3 * $factor))) * 10 * $tweak); + } + + function grid_height($x, $y, $factor = 1, $x_grid, $y_grid) + { + return ((!($x % ($x_grid * $factor)) || !($y % ($y_grid * $factor))) ? 3 : 0); + } + + function captcha_bitmaps() + { + return array( + 'width' => 9, + 'height' => 13, + 'data' => array( + 'A' => array( + array(0,0,1,1,1,1,0,0,0), + array(0,1,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'B' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'C' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'D' => array( + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'E' => array( + array(0,0,1,1,1,1,1,1,1), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'F' => array( + array(0,0,1,1,1,1,1,1,0), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'G' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'H' => array( + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'I' => array( + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'J' => array( + array(0,0,0,0,0,0,1,1,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'K' => array( + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,1,0,0,0,0,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'L' => array( + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'M' => array( + array(0,1,0,0,0,0,0,1,0), + array(0,1,1,0,0,0,1,1,0), + array(0,1,0,1,0,1,0,1,0), + array(0,1,0,0,1,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'N' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,1,0,0,0,0,0,0,1), + array(1,0,1,0,0,0,0,0,1), + array(1,0,0,1,0,0,0,0,1), + array(1,0,0,0,1,0,0,0,1), + array(1,0,0,0,0,1,0,0,1), + array(1,0,0,0,0,0,1,0,1), + array(1,0,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'O' => array( + array(0,0,0,1,1,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'P' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Q' => array( + array(0,0,1,1,1,1,0,0,0), + array(0,1,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,1,0,0,1,0), + array(1,0,0,0,0,1,0,1,0), + array(0,1,0,0,0,0,1,0,0), + array(0,0,1,1,1,1,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'R' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'S' => array( + array(0,0,1,1,1,1,1,1,1), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'T' => array( + array(1,1,1,1,1,1,1,1,1), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'U' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'V' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'W' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,1,0,0,0,1), + array(1,0,0,1,0,1,0,0,1), + array(1,0,1,0,0,0,1,0,1), + array(1,1,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'X' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Y' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Z' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,0,0,0,0), + array(0,0,1,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,1), + array(1,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '1' => array( + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,1,0,0,0,0), + array(0,0,1,0,1,0,0,0,0), + array(0,1,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '2' => array( + array(0,0,0,1,1,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,0,0,0,0), + array(0,0,1,0,0,0,0,0,0), + array(0,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + ), + '3' => array( + array(0,0,0,1,1,1,1,0,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '4' => array( + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,1,0), + array(0,0,0,0,0,1,0,1,0), + array(0,0,0,0,1,0,0,1,0), + array(0,0,0,1,0,0,0,1,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '5' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '6' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,1,1,1,1,0,0), + array(1,0,1,0,0,0,0,1,0), + array(1,1,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '7' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '8' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '9' => array( + array(0,0,0,1,1,1,1,0,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,1), + array(0,0,1,1,1,1,1,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + ) + ); + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/captcha/captcha_plugin.php b/phpBB/includes/captcha/captcha_plugin.php new file mode 100755 index 0000000000..08a149764c --- /dev/null +++ b/phpBB/includes/captcha/captcha_plugin.php @@ -0,0 +1,97 @@ +confirm_id = request_var('confirm_id', ''); + $this->confirm_code = request_var('confirm_code', ''); + $refresh = request_var('refresh_vc', false) && $config['confirm_refresh']; + + $this->type = (int) $type; + + if (!strlen($this->confirm_id)) + { + // we have no confirm ID, better get ready to display something + $this->generate_code(); + } + else if ($refresh) + { + $this->regenerate_code(); + } + + } + + function execute_demo() + { + global $user; + + $this->code = gen_rand_string(mt_rand(5, 8)); + $this->seed = hexdec(substr(unique_id(), 4, 10)); + + // compute $seed % 0x7fffffff + $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); + + $captcha = new captcha(); + $captcha->execute($this->code, $this->seed); + } + + + function execute() + { + if (empty($this->code)) + { + if (!$this->load_code()) + { + // invalid request, bail out + return false; + } + } + $captcha = new captcha(); + $captcha->execute($this->code, $this->seed); + } + + + function get_template() + { + global $config, $user, $template, $phpEx, $phpbb_root_path; + + $template->set_filenames(array( + 'captcha' => 'captcha_default.html') + ); + + $template->assign_vars(array( + 'CONFIRM_IMAGE' => append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type), + 'CONFIRM_ID' => $this->confirm_id, + 'S_REFRESH' => (bool) $config['confirm_refresh'], + + )); + + return $template->assign_display('captcha'); + } + + function get_demo_template($id) + { + global $config, $user, $template, $phpbb_admin_path, $phpEx; + + $template->set_filenames(array( + 'captcha_demo' => 'captcha_default_acp_demo.html') + ); + // acp_captcha has a delivery function; let's use it + $template->assign_vars(array( + 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx . '?captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()), + 'CONFIRM_ID' => $this->confirm_id, + )); + + return $template->assign_display('captcha_demo'); + } + + function get_hidden_fields() + { + $hidden_fields = array(); + + // this is required for postig.php - otherwise we would forget about the captcha being already solved + if ($this->solved) + { + $hidden_fields['confirm_code'] = $this->confirm_code; + } + $hidden_fields['confirm_id'] = $this->confirm_id; + return $hidden_fields; + } + + function garbage_collect($type) + { + global $db, $config; + + $sql = 'SELECT DISTINCT c.session_id + FROM ' . CONFIRM_TABLE . ' c + LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) + WHERE s.session_id IS NULL' . + ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $sql_in = array(); + do + { + $sql_in[] = (string) $row['session_id']; + } + while ($row = $db->sql_fetchrow($result)); + + if (sizeof($sql_in)) + { + $sql = 'DELETE FROM ' . CONFIRM_TABLE . ' + WHERE ' . $db->sql_in_set('session_id', $sql_in); + $db->sql_query($sql); + } + } + $db->sql_freeresult($result); + } + + function uninstall() + { + self::garbage_collect(0); + } + + function install() + { + return; + } + + function validate() + { + global $config, $db, $user; + + $this->confirm_code = request_var('confirm_code', ''); + if (!$this->confirm_id) + { + $error = $user->lang['CONFIRM_CODE_WRONG']; + } + else + { + if ($this->check_code()) + { + // $this->delete_code(); commented out to allow posting.php to repeat the question + $this->solved = true; + } + else + { + $error = $user->lang['CONFIRM_CODE_WRONG']; + } + } + + if (strlen($error)) + { + // okay, inorect answer. Let's ask a new question + $this->generate_code(); + return $error; + } + else + { + return false; + } + } + + + /** + * The old way to generate code, suitable for GD and non-GD. Resets the internal state. + */ + function generate_code() + { + global $db, $user; + + $this->code = gen_rand_string(mt_rand(5, 8)); + $this->confirm_id = md5(unique_id($user->ip)); + $this->seed = hexdec(substr(unique_id(), 4, 10)); + $this->solved = false; + // compute $seed % 0x7fffffff + $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); + + $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'confirm_id' => (string) $this->confirm_id, + 'session_id' => (string) $user->session_id, + 'confirm_type' => (int) $this->type, + 'code' => (string) $this->code, + 'seed' => (int) $this->seed) + ); + $db->sql_query($sql); + } + + /** + * New Question, if desired. + */ + function regenerate_code() + { + global $db, $user; + + $this->code = gen_rand_string(mt_rand(5, 8)); + $this->seed = hexdec(substr(unique_id(), 4, 10)); + $this->solved = false; + // compute $seed % 0x7fffffff + $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); + $sql = 'UPDATE ' . CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'code' => (string) $this->code, + 'seed' => (int) $this->seed)) . ' + WHERE + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND + session_id = \'' . $db->sql_escape($user->session_id) . '\''; + $db->sql_query($sql); + } + + /** + * Look up everything we need for painting&checking. + */ + function load_code() + { + global $db, $user; + $sql = 'SELECT code, seed + FROM ' . CONFIRM_TABLE . " + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + if ($row) + { + $this->code = $row['code']; + $this->seed = $row['seed']; + return true; + } + return false; + + } + + function check_code() + { + global $db; + + if (empty($this->code)) + { + if (!$this->load_code()) + { + return false; + } + } + return (strcasecmp($this->code, $this->confirm_code) === 0); + } + + function delete_code() + { + global $db, $user; + + $sql = 'DELETE FROM ' . CONFIRM_TABLE . " + WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; + $db->sql_query($sql); + } + + function get_attempt_count() + { + global $db, $user; + + $sql = 'SELECT COUNT(session_id) AS attempts + FROM ' . CONFIRM_TABLE . " + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; + $result = $db->sql_query($sql); + $attempts = (int) $db->sql_fetchfield('attempts'); + $db->sql_freeresult($result); + + return $attempts; + } + + + function reset() + { + global $db, $user; + + $sql = 'DELETE FROM ' . CONFIRM_TABLE . " + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . (int) $this->type; + $db->sql_query($sql); + + // we leave the class usable by generating a new question + $this->generate_code(); + } + +} + diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php new file mode 100755 index 0000000000..850794e133 --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -0,0 +1,122 @@ +add_lang('acp/board'); + $captcha_vars = array( + 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', + 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', + 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', + 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', + 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', + 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', + 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', + + ); + + $config_vars = array( + 'enable_confirm' => 'REG_ENABLE', + 'enable_post_confirm' => 'POST_ENABLE', + 'confirm_refresh' => 'CONFIRM_REFRESH', + 'captcha_gd' => 'CAPTCHA_GD', + ); + + + $module->tpl_name = 'captcha_gd_acp'; + $module->page_title = 'ACP_VC_SETTINGS'; + $form_key = 'acp_captcha'; + add_form_key($form_key); + + $submit = request_var('submit', ''); + + if ($submit && check_form_key($form_key)) + { + $captcha_vars = array_keys($captcha_vars); + foreach ($captcha_vars as $captcha_var) + { + $value = request_var($captcha_var, 0); + if ($value >= 0) + { + set_config($captcha_var, $value); + } + } + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); + } + else if ($submit) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + } + else + { + foreach ($captcha_vars as $captcha_var => $template_var) + { + $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; + $template->assign_var($template_var, $var); + } + $template->assign_vars(array( + 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), + 'CAPTCHA_NAME' => $this->get_class_name(), + )); + + } + } +} + diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php new file mode 100755 index 0000000000..769867655c --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -0,0 +1,66 @@ +lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action)); + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php new file mode 100755 index 0000000000..c5a32137d7 --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -0,0 +1,68 @@ +lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action)); + } +} + diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php new file mode 100644 index 0000000000..7a3c406324 --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -0,0 +1,312 @@ +add_lang('recaptcha'); + parent::init($type); + $this->challenge = request_var('recaptcha_challenge_field', ''); + $this->response = request_var('recaptcha_response_field', ''); + } + + + function get_instance() + { + return new phpbb_recaptcha(); + } + + function is_available() + { + global $config, $user; + $user->add_lang('recaptcha'); + return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); + } + + function get_name() + { + return 'CAPTCHA_RECAPTCHA'; + } + + function get_class_name() + { + return 'phpbb_recaptcha'; + } + + function acp_page($id, &$module) + { + global $config, $db, $template, $user; + + $captcha_vars = array( + 'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', + 'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY', + ); + + $module->tpl_name = 'captcha_recaptcha_acp'; + $module->page_title = 'ACP_VC_SETTINGS'; + $form_key = 'acp_captcha'; + add_form_key($form_key); + + $submit = request_var('submit', ''); + + if ($submit && check_form_key($form_key)) + { + $captcha_vars = array_keys($captcha_vars); + foreach ($captcha_vars as $captcha_var) + { + $value = request_var($captcha_var, ''); + if ($value) + { + set_config($captcha_var, $value); + } + } + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); + } + else if ($submit) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + } + else + { + foreach ($captcha_vars as $captcha_var => $template_var) + { + $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); + $template->assign_var($template_var, $var); + } + $template->assign_vars(array( + 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), + 'CAPTCHA_NAME' => $this->get_class_name(), + )); + + } + } + + + // not needed + function execute_demo() + { + } + + + // not needed + function execute() + { + } + + + function get_template() + { + global $config, $user, $template; + + $template->set_filenames(array( + 'captcha' => 'captcha_recaptcha.html') + ); + + $template->assign_vars(array( + 'RECAPTCHA_SERVER' => $this->recaptcha_server, + 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', + 'RECAPTCHA_ERRORGET' => '', + 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + )); + + return $template->assign_display('captcha'); + } + + function get_demo_template($id) + { + return $this->get_template(); + } + + function get_hidden_fields() + { + $hidden_fields = array(); + + // this is required for postig.php - otherwise we would forget about the captcha being already solved + if ($this->solved) + { + $hidden_fields['confirm_code'] = $this->confirm_code; + } + $hidden_fields['confirm_id'] = $this->confirm_id; + return $hidden_fields; + } + + function uninstall() + { + self::garbage_collect(0); + } + + function install() + { + return; + } + + function validate() + { + if (!parent::validate()) + { + return false; + } + else + { + return $this->recaptcha_check_answer(); + } + } + + +// Code from here on is based on recaptchalib.php +/* + * This is a PHP library that handles calling reCAPTCHA. + * - Documentation and latest version + * http://recaptcha.net/plugins/php/ + * - Get a reCAPTCHA API Key + * http://recaptcha.net/api/getkey + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net + * AUTHORS: + * Mike Crawford + * Ben Maurer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + /** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ + function _recaptcha_http_post($host, $path, $data, $port = 80) + { + $req = $this->_recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP/phpBB\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; + } + + + /** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ + function recaptcha_check_answer ($extra_params = array()) + { + global $config, $user; + //discard spam submissions + if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) + { + return $user->lang['RECAPTCHA_INCORRECT']; + } + + $response = $this->_recaptcha_http_post ($this->recaptcha_verify_server, "/verify", + array ( + 'privatekey' => $config['recaptcha_privkey'], + 'remoteip' => $user->ip, + 'challenge' => $this->challenge, + 'response' => $this->response + ) + $extra_params + ); + + $answers = explode ("\n", $response[1]); + + if (trim ($answers[0]) === 'true') + { + $this->solved = true; + return false; + } + else + { + if ($answers[1] === 'incorrect-captcha-sol') + { + return $user->lang['RECAPTCHA_INCORRECT']; + } + } + } + + /** + * Encodes the given data into a query string format + * @param $data - array of string elements to be encoded + * @return string - encoded request + */ + function _recaptcha_qsencode ($data) + { + $req = ''; + foreach ( $data as $key => $value ) + { + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + } + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; + } +} + diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 476565452c..58601be65b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2520,6 +2520,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; + if (!class_exists('phpbb_captcha_factory')) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + } + $err = ''; // Make sure user->setup() has been called @@ -2630,34 +2635,14 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { case LOGIN_ERROR_ATTEMPTS: - // Show confirm image - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_LOGIN; - $db->sql_query($sql); - - // Generate code - $code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); - $confirm_id = md5(unique_id($user->ip)); - $seed = hexdec(substr(unique_id(), 4, 10)); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_LOGIN); + $captcha->reset(); - // compute $seed % 0x7fffffff - $seed -= 0x7fffffff * floor($seed / 0x7fffffff); - - $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $confirm_id, - 'session_id' => (string) $user->session_id, - 'confirm_type' => (int) CONFIRM_LOGIN, - 'code' => (string) $code, - 'seed' => (int) $seed) - ); - $db->sql_query($sql); $template->assign_vars(array( 'S_CONFIRM_CODE' => true, - 'CONFIRM_ID' => $confirm_id, - 'CONFIRM_IMAGE' => '', - 'L_LOGIN_CONFIRM_EXPLAIN' => sprintf($user->lang['LOGIN_CONFIRM_EXPLAIN'], '', ''), + 'CONFIRM' => $captcha->get_template(''), )); $err = $user->lang[$result['error_msg']]; diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 043a637584..e039fce6e1 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -891,7 +891,7 @@ class session */ function session_gc() { - global $db, $config; + global $db, $config, $phpbb_root_path, $phpEx; $batch_size = 10; @@ -949,40 +949,16 @@ class session WHERE last_login < ' . (time() - (86400 * (int) $config['max_autologin_time'])); $db->sql_query($sql); } - $this->confirm_gc(); - } - - return; - } - - function confirm_gc($type = 0) - { - global $db, $config; - - $sql = 'SELECT DISTINCT c.session_id - FROM ' . CONFIRM_TABLE . ' c - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) - WHERE s.session_id IS NULL' . - ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $sql_in = array(); - do - { - $sql_in[] = (string) $row['session_id']; - } - while ($row = $db->sql_fetchrow($result)); - - if (sizeof($sql_in)) + + // only called from CRON; should be a safe workaround until the infrastructure gets going + if (!class_exists('captcha_factory')) { - $sql = 'DELETE FROM ' . CONFIRM_TABLE . ' - WHERE ' . $db->sql_in_set('session_id', $sql_in); - $db->sql_query($sql); + include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); } + captcha_factory::garbage_collect($config['captcha_plugin']); } - $db->sql_freeresult($result); + + return; } diff --git a/phpBB/includes/ucp/ucp_confirm.php b/phpBB/includes/ucp/ucp_confirm.php index b91c88b7e8..445f7c7d2a 100644 --- a/phpBB/includes/ucp/ucp_confirm.php +++ b/phpBB/includes/ucp/ucp_confirm.php @@ -3,7 +3,7 @@ * * @package VC * @version $Id$ -* @copyright (c) 2005 phpBB Group +* @copyright (c) 2005 2008 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -37,42 +37,10 @@ class ucp_confirm { global $db, $user, $phpbb_root_path, $config, $phpEx; - // Do we have an id? No, then just exit - $confirm_id = request_var('id', ''); - $type = request_var('type', 0); - - if (!$confirm_id || !$type) - { - exit; - } - - // Try and grab code for this id and session - $sql = 'SELECT code, seed - FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND confirm_type = $type"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // If we have a row then grab data else create a new id - if (!$row) - { - exit; - } - - if ($config['captcha_gd']) - { - include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); - } - else - { - include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); - } - - $captcha = new captcha(); - $captcha->execute($row['code'], $row['seed']); + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(request_var('type', 0)); + $captcha->execute(); garbage_collection(); exit_handler(); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index e42ad8369d..958369a03e 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -37,14 +37,12 @@ class ucp_register include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); - $confirm_id = request_var('confirm_id', ''); - $confirm_refresh = (isset($_POST['confirm_refresh']) && $config['confirm_refresh']) ? ((!empty($_POST['confirm_refresh'])) ? 1 : 0) : false; - $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; - $agreed = (!empty($_POST['agreed'])) ? 1 : 0; - $submit = (isset($_POST['submit'])) ? true : false; - $change_lang = request_var('change_lang', ''); - $user_lang = request_var('lang', $user->lang_name); - + $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; + $agreed = (!empty($_POST['agreed'])) ? 1 : 0; + $submit = (isset($_POST['submit'])) ? true : false; + $change_lang = request_var('change_lang', ''); + $user_lang = request_var('lang', $user->lang_name); + $confirm_refresh = (isset($_POST['confirm_refresh']) && $config['confirm_refresh']) ? ((!empty($_POST['confirm_refresh'])) ? 1 : 0) : false; if ($agreed) { add_form_key('ucp_register'); @@ -54,7 +52,14 @@ class ucp_register add_form_key('ucp_register_terms'); } - + + if ($config['enable_confirm']) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_REG); + } + if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); @@ -89,8 +94,8 @@ class ucp_register { $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; - - $s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array(); + + $s_hidden_fields = array(); // If we change the language, we want to pass on some more possible parameter. if ($change_lang) @@ -100,11 +105,14 @@ class ucp_register 'username' => utf8_normalize_nfc(request_var('username', '', true)), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), - 'confirm_code' => request_var('confirm_code', ''), - 'confirm_id' => request_var('confirm_id', ''), 'lang' => $user->lang_name, 'tz' => request_var('tz', (float) $config['board_timezone']), )); + + if ($config['enable_confirm']) + { + $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); + } } if ($coppa === false && $config['coppa_enable']) @@ -168,7 +176,6 @@ class ucp_register 'password_confirm' => request_var('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), - 'confirm_code' => request_var('confirm_code', ''), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (float) $timezone), ); @@ -188,7 +195,6 @@ class ucp_register array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), - 'confirm_code' => array('string', !$config['enable_confirm'], CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS), 'tz' => array('num', false, -14, 14), 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), )); @@ -199,6 +205,22 @@ class ucp_register // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); + if ($config['enable_confirm']) + { + $vc_response = $captcha->validate(); + if ($vc_response) + { + $error[] = $vc_response; + } + else + { + $captcha->reset(); + } + if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) + { + $error[] = $user->lang['TOO_MANY_REGISTERS']; + } + } // DNSBL check if ($config['check_dnsbl']) { @@ -211,50 +233,6 @@ class ucp_register // validate custom profile fields $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); - // Visual Confirmation handling - $wrong_confirm = false; - if ($config['enable_confirm']) - { - if (!$confirm_id) - { - $error[] = $user->lang['CONFIRM_CODE_WRONG']; - $wrong_confirm = true; - } - else - { - $sql = 'SELECT code - FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_REG; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if (strcasecmp($row['code'], $data['confirm_code']) === 0) - { - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_REG; - $db->sql_query($sql); - } - else - { - $error[] = $user->lang['CONFIRM_CODE_WRONG']; - $wrong_confirm = true; - } - } - else - { - $error[] = $user->lang['CONFIRM_CODE_WRONG']; - $wrong_confirm = true; - } - } - } - if (!sizeof($error)) { if ($data['new_password'] != $data['password_confirm']) @@ -452,74 +430,17 @@ class ucp_register if ($change_lang || $confirm_refresh) { $str = '&change_lang=' . $change_lang; - $sql = 'SELECT code - FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_REG; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - $confirm_id = ''; - } - $db->sql_freeresult($result); } else { $str = ''; - } - if (!$change_lang || !$confirm_id || !$confirm_refresh) - { - $user->confirm_gc(CONFIRM_REG); - $sql = 'SELECT COUNT(session_id) AS attempts - FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_REG; - $result = $db->sql_query($sql); - $attempts = (int) $db->sql_fetchfield('attempts'); - $db->sql_freeresult($result); - - if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) - { - trigger_error('TOO_MANY_REGISTERS'); - } - - $code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); - $confirm_id = md5(unique_id($user->ip)); - $seed = hexdec(substr(unique_id(), 4, 10)); - - // compute $seed % 0x7fffffff - $seed -= 0x7fffffff * floor($seed / 0x7fffffff); - - $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $confirm_id, - 'session_id' => (string) $user->session_id, - 'confirm_type' => (int) CONFIRM_REG, - 'code' => (string) $code, - 'seed' => (int) $seed) - ); - $db->sql_query($sql); - } - else if ($confirm_refresh) - { - $code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); - $confirm_id = md5(unique_id($user->ip)); - $seed = hexdec(substr(unique_id(), 4, 10)); - // compute $seed % 0x7fffffff - $seed -= 0x7fffffff * floor($seed / 0x7fffffff); - $sql = 'UPDATE ' . CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( - 'confirm_type' => (int) CONFIRM_REG, - 'code' => (string) $code, - 'seed' => (int) $seed)) . " - WHERE - confirm_id = '" . $db->sql_escape($confirm_id) . "' AND - session_id = '" . $db->sql_escape($session_id) . "' AND - confirm_type = " . (int) CONFIRM_REG; - $db->sql_query($sql); } - $confirm_image = ''; - $s_hidden_fields .= ''; + $template->assign_vars(array( + 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), + 'S_CAPTCHA' => $captcha->get_template(), + )); + } // @@ -534,7 +455,7 @@ class ucp_register $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; break; } - + $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'USERNAME' => $data['username'], @@ -542,16 +463,13 @@ class ucp_register 'PASSWORD_CONFIRM' => $data['password_confirm'], 'EMAIL' => $data['email'], 'EMAIL_CONFIRM' => $data['email_confirm'], - 'CONFIRM_IMG' => $confirm_image, - 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), 'L_REG_COND' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_TZ_OPTIONS' => tz_select($data['tz']), - 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false, 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, -- cgit v1.2.1 From ffbc25e17a64146cb988ba01e536e10a75b8322d Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 2 Jun 2009 21:29:51 +0000 Subject: New caching plugin, won't cache anything git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9526 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_null.php | 163 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 phpBB/includes/acm/acm_null.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_null.php b/phpBB/includes/acm/acm_null.php new file mode 100644 index 0000000000..c2363b9ddf --- /dev/null +++ b/phpBB/includes/acm/acm_null.php @@ -0,0 +1,163 @@ + \ No newline at end of file -- cgit v1.2.1 From be8457d3c418441317177bfcdf7378410ac28d55 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 3 Jun 2009 10:19:17 +0000 Subject: Correctly determine writable status of files on Windows operating system. #39035 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9528 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 2 +- phpBB/includes/functions.php | 61 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 8a92c06e04..365290e909 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -504,7 +504,7 @@ class acp_main $template->assign_var('S_REMOVE_INSTALL', true); } - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) + if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) { // World-Writable? (000x) $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 58601be65b..78905beff6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -669,6 +669,67 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) return $result; } +/** + * Test if a file/directory is writable + * + * This function calls the native is_writable() when not running under + * Windows and it is not disabled. + * + * @param string $file Path to perform write test on + * @return bool True when the path is writable, otherwise false. + */ +function phpbb_is_writable($file) +{ + if (substr(PHP_OS, 0, 3) === 'WIN' || !function_exists('is_writable')) + { + if (file_exists($file)) + { + // Canonicalise path to absolute path + $file = phpbb_realpath($file); + + if (is_dir($file)) + { + // Test directory by creating a file inside the directory + $result = @tempnam($file, 'i_w'); + + if (is_string($result) && file_exists($result)) + { + unlink($result); + + // Ensure the file is actually in the directory (returned realpathed) + return (strpos($result, $file) === 0) ? true : false; + } + } + else + { + $handle = @fopen($file, 'r+'); + + if (is_resource($handle)) + { + fclose($handle); + return true; + } + } + } + else + { + // file does not exist test if we can write to the directory + + $dir = dirname($file); + + if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir)) + { + return true; + } + } + return false; + } + else + { + return is_writable($file); + } +} + // Compatibility functions if (!function_exists('array_combine')) -- cgit v1.2.1 From 8fc412f26aa1b6e580b8aa200db79608b19aeae9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 3 Jun 2009 12:13:01 +0000 Subject: #44955 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9529 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 027db39751..ee9867b1f1 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2077,8 +2077,8 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $sub_file)) { $avatar_list[$file][$avatar_row_count][$avatar_col_count] = array( - 'file' => "$file/$sub_file", - 'filename' => $sub_file, + 'file' => rawurlencode ($file) . '/' . rawurlencode ($sub_file), + 'filename' => rawurlencode ($sub_file), 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))), ); $avatar_col_count++; -- cgit v1.2.1 From 05548f8f05d1f64945a4fdb615f0e4e1620323c2 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 3 Jun 2009 16:29:26 +0000 Subject: Correctly split UTF-8 encoded strings when using mail(). #45815 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9530 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 4fd5fd19e0..4916ee41d7 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -408,6 +408,8 @@ class messenger $this->from = '<' . $config['board_contact'] . '>'; } + $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; + // Build to, cc and bcc strings $to = $cc = $bcc = ''; foreach ($this->addresses as $type => $address_ary) @@ -419,7 +421,7 @@ class messenger foreach ($address_ary as $which_ary) { - $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name']) . '" <' . $which_ary['email'] . '>' : $which_ary['email']); + $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name'], $encode_eol) . '" <' . $which_ary['email'] . '>' : $which_ary['email']); } } @@ -443,7 +445,7 @@ class messenger $headers = implode($this->eol, $headers); ob_start(); - $result = $config['email_function_name']($mail_to, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers); + $result = $config['email_function_name']($mail_to, mail_encode($this->subject, $this->eol), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers); $err_msg = ob_get_clean(); } @@ -688,7 +690,7 @@ class queue else { ob_start(); - $result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode($this->eol, $headers)); + $result = $config['email_function_name']($to, mail_encode($subject, $this->eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode($this->eol, $headers)); $err_msg = ob_get_clean(); } @@ -1441,13 +1443,15 @@ class smtp_class * is basically doomed with an unreadable subject. * * Please note that this version fully supports RFC 2045 section 6.8. +* +* @param string $eol End of line we are using (optional to be backwards compatible) */ -function mail_encode($str) +function mail_encode($str, $eol = "\r\n") { // define start delimimter, end delimiter and spacer $start = "=?UTF-8?B?"; $end = "?="; - $delimiter = "\r\n "; + $delimiter = "$eol "; // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!! $split_length = 60; -- cgit v1.2.1 From 5478ef15d33eec696ded6a5402a329b77916597e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 12:29:34 +0000 Subject: Backport memcache ACM module from Ascraeus git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9531 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_memcache.php | 419 ++++++++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 phpBB/includes/acm/acm_memcache.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php new file mode 100644 index 0000000000..1fe9218104 --- /dev/null +++ b/phpBB/includes/acm/acm_memcache.php @@ -0,0 +1,419 @@ +memcache = new Memcache; + $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); + $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; + + $this->cache_dir = $phpbb_root_path . 'cache/'; + } + + /** + * Load global cache + */ + function load() + { + // grab the global cache + $this->vars = $this->memcache->get('global'); + + if ($this->vars !== false) + { + return true; + } + + return false; + } + + /** + * Unload cache object + */ + function unload() + { + $this->save(); + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + + $this->memcache->close(); + } + + /** + * Save modified objects + */ + function save() + { + if (!$this->is_modified) + { + return; + } + + $this->memcache->set('global', $this->vars, $this->flags, 2592000); + + $this->is_modified = false; + } + + /** + * Tidy cache + */ + function tidy() + { + // cache has auto GC, no need to have any code here :) + + set_config('cache_last_gc', time(), true); + } + + /** + * Get saved cache object + */ + function get($var_name) + { + if ($var_name[0] == '_') + { + return $this->memcache->get($var_name); + } + else + { + return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; + } + } + + /** + * Put data into cache + */ + function put($var_name, $var, $ttl = 2592000) + { + if ($var_name[0] == '_') + { + $this->memcache->set($var_name, $var, $this->flags, $ttl); + } + else + { + $this->vars[$var_name] = $var; + $this->is_modified = true; + } + } + + /** + * Purge cache data + */ + function purge() + { + // Purge all phpbb cache files + $dir = @opendir($this->cache_dir); + + if (!$dir) + { + return; + } + + while (($entry = readdir($dir)) !== false) + { + if (strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + { + continue; + } + + $this->remove_file($this->cache_dir . $entry); + } + closedir($dir); + + $this->memcache->flush(); + + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + + $this->is_modified = false; + } + + + /** + * Destroy cache data + */ + function destroy($var_name, $table = '') + { + if ($var_name == 'sql' && !empty($table)) + { + if (!is_array($table)) + { + $table = array($table); + } + + foreach ($table as $table_name) + { + // gives us the md5s that we want + $temp = $this->memcache->get('sql_' . $table_name); + + if ($temp === false) + { + continue; + } + + // delete each query ref + foreach ($temp as $md5_id => $void) + { + $this->memcache->delete('sql_' . $md5_id); + } + + // delete the table ref + $this->memcache->delete('sql_' . $table_name); + } + + return; + } + + if (!$this->_exists($var_name)) + { + return; + } + + if ($var_name[0] == '_') + { + $this->memcache->delete($var_name); + } + else + { + $this->is_modified = true; + unset($this->vars[$var_name]); + + // We save here to let the following cache hits succeed + $this->save(); + } + } + + /** + * Check if a given cache entry exist + */ + function _exists($var_name) + { + if ($var_name[0] == '_') + { + return true; + } + else + { + if (!sizeof($this->vars)) + { + $this->load(); + } + + return isset($this->vars[$var_name]); + } + } + + /** + * Load cached sql query + */ + function sql_load($query) + { + // Remove extra spaces and tabs + $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + $query_id = sizeof($this->sql_rowset); + + if (($result = $this->memcache->get('sql_' . md5($query))) === false) + { + return false; + } + + $this->sql_rowset[$query_id] = $result; + $this->sql_row_pointer[$query_id] = 0; + + return $query_id; + } + + /** + * Save sql query + */ + function sql_save($query, &$query_result, $ttl) + { + global $db; + + // Remove extra spaces and tabs + $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + $hash = md5($query); + + // determine which tables this query belongs to + preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs); + $tables = array_map('trim', explode(',', $regs[1])); + + foreach ($tables as $table_name) + { + if (($pos = strpos($table_name, ' ')) !== false) + { + $table_name = substr($table_name, 0, $pos); + } + + $temp = $this->memcache->get('sql_' . $table_name); + + if ($temp === false) + { + $temp = array(); + } + + $temp[$hash] = true; + + $this->memcache->set('sql_' . $table_name, $temp, $this->flags, $ttl); + } + + // store them in the right place + $query_id = sizeof($this->sql_rowset); + $this->sql_rowset[$query_id] = array(); + $this->sql_row_pointer[$query_id] = 0; + + while ($row = $db->sql_fetchrow($query_result)) + { + $this->sql_rowset[$query_id][] = $row; + } + $db->sql_freeresult($query_result); + + $this->memcache->set('sql_' . $hash, $this->sql_rowset[$query_id], $this->flags, $ttl); + + $query_result = $query_id; + } + + /** + * Ceck if a given sql query exist in cache + */ + function sql_exists($query_id) + { + return isset($this->sql_rowset[$query_id]); + } + + /** + * Fetch row from cache (database) + */ + function sql_fetchrow($query_id) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; + } + + return false; + } + + /** + * Fetch a field from the current row of a cached database result (database) + */ + function sql_fetchfield($query_id, $field) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false; + } + + return false; + } + + /** + * Seek a specific row in an a cached database result (database) + */ + function sql_rowseek($rownum, $query_id) + { + if ($rownum >= sizeof($this->sql_rowset[$query_id])) + { + return false; + } + + $this->sql_row_pointer[$query_id] = $rownum; + return true; + } + + /** + * Free memory used for a cached database result (database) + */ + function sql_freeresult($query_id) + { + if (!isset($this->sql_rowset[$query_id])) + { + return false; + } + + unset($this->sql_rowset[$query_id]); + unset($this->sql_row_pointer[$query_id]); + + return true; + } + + /** + * Removes/unlinks file + */ + function remove_file($filename, $check = false) + { + if ($check && !@is_writable($this->cache_dir)) + { + // E_USER_ERROR - not using language entry - intended. + trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); + } + + return @unlink($filename); + } +} + +?> \ No newline at end of file -- cgit v1.2.1 From a975f8454aea77f1e42332b8fb52e66a77415e76 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 13:30:01 +0000 Subject: Fix up and tidy :) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9532 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/captcha_factory.php | 8 +++++--- phpBB/includes/captcha/captcha_gd_wave.php | 12 ++++++------ phpBB/includes/captcha/captcha_plugin.php | 6 ++++-- phpBB/includes/captcha/plugins/captcha_abstract.php | 7 ++++--- phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php | 14 ++++++++------ .../captcha/plugins/phpbb_captcha_gd_wave_plugin.php | 4 +++- .../includes/captcha/plugins/phpbb_captcha_nogd_plugin.php | 12 +++++++----- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 8 ++++---- 8 files changed, 41 insertions(+), 30 deletions(-) mode change 100755 => 100644 phpBB/includes/captcha/captcha_factory.php mode change 100755 => 100644 phpBB/includes/captcha/captcha_gd_wave.php mode change 100755 => 100644 phpBB/includes/captcha/captcha_plugin.php mode change 100755 => 100644 phpBB/includes/captcha/plugins/captcha_abstract.php mode change 100755 => 100644 phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php mode change 100755 => 100644 phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php mode change 100755 => 100644 phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php old mode 100755 new mode 100644 index e6f56172ec..fbe615a043 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -1,8 +1,8 @@ - \ No newline at end of file diff --git a/phpBB/includes/captcha/captcha_gd_wave.php b/phpBB/includes/captcha/captcha_gd_wave.php old mode 100755 new mode 100644 index 0356538a4d..41dfcdd9d4 --- a/phpBB/includes/captcha/captcha_gd_wave.php +++ b/phpBB/includes/captcha/captcha_gd_wave.php @@ -2,15 +2,15 @@ /** * * @package VC -* @version $Id: captcha_gd.php,v 1.19 2007/01/26 16:07:43 acydburn Exp $ +* @version $Id$ * @copyright (c) 2006 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ - - -/** -Wave3D CAPTCHA by Robert Hetzler + + +/** +* Wave3D CAPTCHA by Robert Hetzler */ class captcha { @@ -836,7 +836,7 @@ class captcha ), ) ); - } + } } ?> \ No newline at end of file diff --git a/phpBB/includes/captcha/captcha_plugin.php b/phpBB/includes/captcha/captcha_plugin.php old mode 100755 new mode 100644 index 08a149764c..7c601caa93 --- a/phpBB/includes/captcha/captcha_plugin.php +++ b/phpBB/includes/captcha/captcha_plugin.php @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php old mode 100755 new mode 100644 index f5c135dc74..f88d82b2a0 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -1,9 +1,9 @@ - \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php old mode 100755 new mode 100644 index 850794e133..5b3c09f32d --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -1,12 +1,13 @@ - \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php old mode 100755 new mode 100644 index 769867655c..38e5aabedd --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -3,10 +3,11 @@ * * @package VC * @version $Id$ -* @copyright (c) 2006 2008 phpBB Group +* @copyright (c) 2006, 2008 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ + /** * @ignore */ @@ -29,6 +30,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha function phpbb_captcha_gd_wave() { global $phpbb_root_path, $phpEx; + if (!class_exists('captcha')) { include_once($phpbb_root_path . 'includes/captcha/captcha_gd_wave.' . $phpEx); diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php old mode 100755 new mode 100644 index c5a32137d7..8df11bfe8a --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -1,12 +1,13 @@ - Date: Thu, 4 Jun 2009 13:52:37 +0000 Subject: ACM memory abstract class git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9533 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_memory.php | 401 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 401 insertions(+) create mode 100644 phpBB/includes/acm/acm_memory.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php new file mode 100644 index 0000000000..964fdb2db4 --- /dev/null +++ b/phpBB/includes/acm/acm_memory.php @@ -0,0 +1,401 @@ +cache_dir = $phpbb_root_path . 'cache/'; + } + + /** + * Load global cache + */ + function load() + { + // grab the global cache + $this->vars = $this->read('global'); + + if ($this->vars !== false) + { + return true; + } + + return false; + } + + /** + * Unload cache object + */ + function unload() + { + $this->save(); + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + } + + /** + * Save modified objects + */ + function save() + { + if (!$this->is_modified) + { + return; + } + + $this->write('global', $this->vars, 2592000); + + $this->is_modified = false; + } + + /** + * Tidy cache + */ + function tidy() + { + // cache has auto GC, no need to have any code here :) + + set_config('cache_last_gc', time(), true); + } + + /** + * Get saved cache object + */ + function get($var_name) + { + if ($var_name[0] == '_') + { + if (!$this->_exists($var_name)) + { + return false; + } + + return $this->read($var_name); + } + else + { + return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; + } + } + + /** + * Put data into cache + */ + function put($var_name, $var, $ttl = 2592000) + { + if ($var_name[0] == '_') + { + $this->write($var_name, $var, $ttl); + } + else + { + $this->vars[$var_name] = $var; + $this->is_modified = true; + } + } + + /** + * Purge cache data + */ + function purge() + { + // Purge all phpbb cache files + $dir = @opendir($this->cache_dir); + + if (!$dir) + { + return; + } + + while (($entry = readdir($dir)) !== false) + { + if (strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + { + continue; + } + + $this->remove_file($this->cache_dir . $entry); + } + closedir($dir); + + unset($this->vars); + unset($this->sql_rowset); + unset($this->sql_row_pointer); + + $this->vars = array(); + $this->sql_rowset = array(); + $this->sql_row_pointer = array(); + + $this->is_modified = false; + } + + + /** + * Destroy cache data + */ + function destroy($var_name, $table = '') + { + if ($var_name == 'sql' && !empty($table)) + { + if (!is_array($table)) + { + $table = array($table); + } + + foreach ($table as $table_name) + { + // gives us the md5s that we want + $temp = $this->read('sql_' . $table_name); + + if ($temp === false) + { + continue; + } + + // delete each query ref + foreach ($temp as $md5_id => $void) + { + $this->delete('sql_' . $md5_id); + } + + // delete the table ref + $this->delete('sql_' . $table_name); + } + + return; + } + + if (!$this->_exists($var_name)) + { + return; + } + + if ($var_name[0] == '_') + { + $this->delete($var_name); + } + else if (isset($this->vars[$var_name])) + { + $this->is_modified = true; + unset($this->vars[$var_name]); + + // We save here to let the following cache hits succeed + $this->save(); + } + } + + /** + * Check if a given cache entry exist + */ + function _exists($var_name) + { + if ($var_name[0] == '_') + { + return true; + } + else + { + if (!sizeof($this->vars)) + { + $this->load(); + } + + return isset($this->vars[$var_name]); + } + } + + /** + * Load cached sql query + */ + function sql_load($query) + { + // Remove extra spaces and tabs + $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + $query_id = sizeof($this->sql_rowset); + + if (($result = $this->read('sql_' . md5($query))) === false) + { + return false; + } + + $this->sql_rowset[$query_id] = $result; + $this->sql_row_pointer[$query_id] = 0; + + return $query_id; + } + + /** + * Save sql query + */ + function sql_save($query, &$query_result, $ttl) + { + global $db; + + // Remove extra spaces and tabs + $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + $hash = md5($query); + + // determine which tables this query belongs to + // Some queries use backticks, namely the get_database_size() query + // don't check for conformity, the SQL would error and not reach here. + if (!preg_match('/FROM \\(?(`?\\w+`?(?: \\w+)?(?:, ?`?\\w+`?(?: \\w+)?)*)\\)?/', $query, $regs)) + { + // Bail out if the match fails. + return; + } + $tables = array_map('trim', explode(',', $regs[1])); + + foreach ($tables as $table_name) + { + // Remove backticks + $table_name = ($table_name[0] == '`') ? substr($table_name, 1, -1) : $table_name; + + if (($pos = strpos($table_name, ' ')) !== false) + { + $table_name = substr($table_name, 0, $pos); + } + + $temp = $this->read('sql_' . $table_name); + + if ($temp === false) + { + $temp = array(); + } + + $temp[$hash] = true; + + // This must never expire + $this->write('sql_' . $table_name, $temp, 0); + } + + // store them in the right place + $query_id = sizeof($this->sql_rowset); + $this->sql_rowset[$query_id] = array(); + $this->sql_row_pointer[$query_id] = 0; + + while ($row = $db->sql_fetchrow($query_result)) + { + $this->sql_rowset[$query_id][] = $row; + } + $db->sql_freeresult($query_result); + + $this->write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); + + $query_result = $query_id; + } + + /** + * Ceck if a given sql query exist in cache + */ + function sql_exists($query_id) + { + return isset($this->sql_rowset[$query_id]); + } + + /** + * Fetch row from cache (database) + */ + function sql_fetchrow($query_id) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; + } + + return false; + } + + /** + * Fetch a field from the current row of a cached database result (database) + */ + function sql_fetchfield($query_id, $field) + { + if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + { + return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false; + } + + return false; + } + + /** + * Seek a specific row in an a cached database result (database) + */ + function sql_rowseek($rownum, $query_id) + { + if ($rownum >= sizeof($this->sql_rowset[$query_id])) + { + return false; + } + + $this->sql_row_pointer[$query_id] = $rownum; + return true; + } + + /** + * Free memory used for a cached database result (database) + */ + function sql_freeresult($query_id) + { + if (!isset($this->sql_rowset[$query_id])) + { + return false; + } + + unset($this->sql_rowset[$query_id]); + unset($this->sql_row_pointer[$query_id]); + + return true; + } + + /** + * Removes/unlinks file + */ + function remove_file($filename, $check = false) + { + if ($check && !@is_writable($this->cache_dir)) + { + // E_USER_ERROR - not using language entry - intended. + trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); + } + + return @unlink($filename); + } +} + +?> \ No newline at end of file -- cgit v1.2.1 From 6c025db9ec5754c4a66b88ed0e5a7041f15065b3 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 14:00:34 +0000 Subject: Add APC Modify Memcache to use the memory abstract git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9534 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 63 +++++++ phpBB/includes/acm/acm_memcache.php | 358 ++---------------------------------- 2 files changed, 81 insertions(+), 340 deletions(-) create mode 100644 phpBB/includes/acm/acm_apc.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php new file mode 100644 index 0000000000..409854bc26 --- /dev/null +++ b/phpBB/includes/acm/acm_apc.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 1fe9218104..4950738522 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -3,7 +3,7 @@ * * @package acm * @version $Id$ -* @copyright (c) 2005 phpBB Group +* @copyright (c) 2005, 2009 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -26,6 +26,12 @@ if (!extension_loaded('memcache') || !defined('PHPBB_ACM_MEMCACHE_HOST')) return; } +// Include the abstract base +if (!class_exists('acm_memory')) +{ + require("${phpbb_root_path}includes/acm/acm_memory.$phpEx"); +} + if (!defined('PHPBB_ACM_MEMCACHE_PORT')) { define('PHPBB_ACM_MEMCACHE_PORT', 11211); @@ -40,379 +46,51 @@ if (!defined('PHPBB_ACM_MEMCACHE_COMPRESS')) * ACM for Memcached * @package acm */ -class acm +class acm extends acm_memory { - var $vars = array(); - var $is_modified = false; - - var $sql_rowset = array(); - var $sql_row_pointer = array(); - var $cache_dir = ''; - var $memcache; var $flags = 0; - /** - * Set cache path - */ function acm() { - global $phpbb_root_path; + // Call the parent constructor + parent::acm_memory(); $this->memcache = new Memcache; $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; - - $this->cache_dir = $phpbb_root_path . 'cache/'; - } - - /** - * Load global cache - */ - function load() - { - // grab the global cache - $this->vars = $this->memcache->get('global'); - - if ($this->vars !== false) - { - return true; - } - - return false; } - /** - * Unload cache object - */ function unload() { - $this->save(); - unset($this->vars); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); + parent::unload(); $this->memcache->close(); } - /** - * Save modified objects - */ - function save() - { - if (!$this->is_modified) - { - return; - } - - $this->memcache->set('global', $this->vars, $this->flags, 2592000); - - $this->is_modified = false; - } - - /** - * Tidy cache - */ - function tidy() - { - // cache has auto GC, no need to have any code here :) - - set_config('cache_last_gc', time(), true); - } - - /** - * Get saved cache object - */ - function get($var_name) - { - if ($var_name[0] == '_') - { - return $this->memcache->get($var_name); - } - else - { - return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; - } - } - - /** - * Put data into cache - */ - function put($var_name, $var, $ttl = 2592000) - { - if ($var_name[0] == '_') - { - $this->memcache->set($var_name, $var, $this->flags, $ttl); - } - else - { - $this->vars[$var_name] = $var; - $this->is_modified = true; - } - } - /** * Purge cache data */ function purge() { - // Purge all phpbb cache files - $dir = @opendir($this->cache_dir); - - if (!$dir) - { - return; - } - - while (($entry = readdir($dir)) !== false) - { - if (strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) - { - continue; - } - - $this->remove_file($this->cache_dir . $entry); - } - closedir($dir); - $this->memcache->flush(); - unset($this->vars); - unset($this->sql_rowset); - unset($this->sql_row_pointer); - - $this->vars = array(); - $this->sql_rowset = array(); - $this->sql_row_pointer = array(); - - $this->is_modified = false; - } - - - /** - * Destroy cache data - */ - function destroy($var_name, $table = '') - { - if ($var_name == 'sql' && !empty($table)) - { - if (!is_array($table)) - { - $table = array($table); - } - - foreach ($table as $table_name) - { - // gives us the md5s that we want - $temp = $this->memcache->get('sql_' . $table_name); - - if ($temp === false) - { - continue; - } - - // delete each query ref - foreach ($temp as $md5_id => $void) - { - $this->memcache->delete('sql_' . $md5_id); - } - - // delete the table ref - $this->memcache->delete('sql_' . $table_name); - } - - return; - } - - if (!$this->_exists($var_name)) - { - return; - } - - if ($var_name[0] == '_') - { - $this->memcache->delete($var_name); - } - else - { - $this->is_modified = true; - unset($this->vars[$var_name]); - - // We save here to let the following cache hits succeed - $this->save(); - } + parent::purge(); } - /** - * Check if a given cache entry exist - */ - function _exists($var_name) + function read($var) { - if ($var_name[0] == '_') - { - return true; - } - else - { - if (!sizeof($this->vars)) - { - $this->load(); - } - - return isset($this->vars[$var_name]); - } + return $this->memcache->get($var); } - /** - * Load cached sql query - */ - function sql_load($query) - { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); - - if (($result = $this->memcache->get('sql_' . md5($query))) === false) - { - return false; - } - - $this->sql_rowset[$query_id] = $result; - $this->sql_row_pointer[$query_id] = 0; - - return $query_id; - } - - /** - * Save sql query - */ - function sql_save($query, &$query_result, $ttl) + function write($var, $data, $ttl = 2592000) { - global $db; - - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $hash = md5($query); - - // determine which tables this query belongs to - preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs); - $tables = array_map('trim', explode(',', $regs[1])); - - foreach ($tables as $table_name) - { - if (($pos = strpos($table_name, ' ')) !== false) - { - $table_name = substr($table_name, 0, $pos); - } - - $temp = $this->memcache->get('sql_' . $table_name); - - if ($temp === false) - { - $temp = array(); - } - - $temp[$hash] = true; - - $this->memcache->set('sql_' . $table_name, $temp, $this->flags, $ttl); - } - - // store them in the right place - $query_id = sizeof($this->sql_rowset); - $this->sql_rowset[$query_id] = array(); - $this->sql_row_pointer[$query_id] = 0; - - while ($row = $db->sql_fetchrow($query_result)) - { - $this->sql_rowset[$query_id][] = $row; - } - $db->sql_freeresult($query_result); - - $this->memcache->set('sql_' . $hash, $this->sql_rowset[$query_id], $this->flags, $ttl); - - $query_result = $query_id; + return $this->memcache->set($var, $data, $this->flags, $ttl); } - /** - * Ceck if a given sql query exist in cache - */ - function sql_exists($query_id) + function delete($var) { - return isset($this->sql_rowset[$query_id]); - } - - /** - * Fetch row from cache (database) - */ - function sql_fetchrow($query_id) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; - } - - return false; - } - - /** - * Fetch a field from the current row of a cached database result (database) - */ - function sql_fetchfield($query_id, $field) - { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) - { - return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false; - } - - return false; - } - - /** - * Seek a specific row in an a cached database result (database) - */ - function sql_rowseek($rownum, $query_id) - { - if ($rownum >= sizeof($this->sql_rowset[$query_id])) - { - return false; - } - - $this->sql_row_pointer[$query_id] = $rownum; - return true; - } - - /** - * Free memory used for a cached database result (database) - */ - function sql_freeresult($query_id) - { - if (!isset($this->sql_rowset[$query_id])) - { - return false; - } - - unset($this->sql_rowset[$query_id]); - unset($this->sql_row_pointer[$query_id]); - - return true; - } - - /** - * Removes/unlinks file - */ - function remove_file($filename, $check = false) - { - if ($check && !@is_writable($this->cache_dir)) - { - // E_USER_ERROR - not using language entry - intended. - trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); - } - - return @unlink($filename); + return $this->memcache->delete($var); } } -- cgit v1.2.1 From aec3a498de31b380d0eb48154de0b2bd56054dfa Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 14:34:07 +0000 Subject: Lets follow some PHP4 conventions underscores for internal methods. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9536 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 31 ++++++++++++++++++++++++++++--- phpBB/includes/acm/acm_memcache.php | 36 +++++++++++++++++++++++++++++++++--- phpBB/includes/acm/acm_memory.php | 26 ++++++++++++++------------ 3 files changed, 75 insertions(+), 18 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index 409854bc26..cbda86bec0 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -36,6 +36,8 @@ class acm extends acm_memory /** * Purge cache data + * + * @return void */ function purge() { @@ -44,17 +46,40 @@ class acm extends acm_memory parent::purge(); } - function read($var) + /** + * Fetch an item from the cache + * + * @access protected + * @param string $var Cache key + * @return mixed Cached data + */ + function _read($var) { return apc_fetch($var); } - function write($var, $data, $ttl = 2592000) + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) { return apc_store($var, $data, $ttl); } - function delete($var) + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) { return apc_delete($var); } diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 4950738522..1ec37f1b3b 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -61,6 +61,11 @@ class acm extends acm_memory $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; } + /** + * Unload the cache resources + * + * @return void + */ function unload() { parent::unload(); @@ -70,6 +75,8 @@ class acm extends acm_memory /** * Purge cache data + * + * @return void */ function purge() { @@ -78,17 +85,40 @@ class acm extends acm_memory parent::purge(); } - function read($var) + /** + * Fetch an item from the cache + * + * @access protected + * @param string $var Cache key + * @return mixed Cached data + */ + function _read($var) { return $this->memcache->get($var); } - function write($var, $data, $ttl = 2592000) + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) { return $this->memcache->set($var, $data, $this->flags, $ttl); } - function delete($var) + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) { return $this->memcache->delete($var); } diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index 964fdb2db4..7875c3441e 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -34,6 +34,8 @@ class acm_memory */ function acm_memory() { + global $phpbb_root_path; + $this->cache_dir = $phpbb_root_path . 'cache/'; } @@ -43,7 +45,7 @@ class acm_memory function load() { // grab the global cache - $this->vars = $this->read('global'); + $this->vars = $this->_read('global'); if ($this->vars !== false) { @@ -78,7 +80,7 @@ class acm_memory return; } - $this->write('global', $this->vars, 2592000); + $this->_write('global', $this->vars, 2592000); $this->is_modified = false; } @@ -105,7 +107,7 @@ class acm_memory return false; } - return $this->read($var_name); + return $this->_read($var_name); } else { @@ -120,7 +122,7 @@ class acm_memory { if ($var_name[0] == '_') { - $this->write($var_name, $var, $ttl); + $this->_write($var_name, $var, $ttl); } else { @@ -180,7 +182,7 @@ class acm_memory foreach ($table as $table_name) { // gives us the md5s that we want - $temp = $this->read('sql_' . $table_name); + $temp = $this->_read('sql_' . $table_name); if ($temp === false) { @@ -190,11 +192,11 @@ class acm_memory // delete each query ref foreach ($temp as $md5_id => $void) { - $this->delete('sql_' . $md5_id); + $this->_delete('sql_' . $md5_id); } // delete the table ref - $this->delete('sql_' . $table_name); + $this->_delete('sql_' . $table_name); } return; @@ -207,7 +209,7 @@ class acm_memory if ($var_name[0] == '_') { - $this->delete($var_name); + $this->_delete($var_name); } else if (isset($this->vars[$var_name])) { @@ -248,7 +250,7 @@ class acm_memory $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query_id = sizeof($this->sql_rowset); - if (($result = $this->read('sql_' . md5($query))) === false) + if (($result = $this->_read('sql_' . md5($query))) === false) { return false; } @@ -290,7 +292,7 @@ class acm_memory $table_name = substr($table_name, 0, $pos); } - $temp = $this->read('sql_' . $table_name); + $temp = $this->_read('sql_' . $table_name); if ($temp === false) { @@ -300,7 +302,7 @@ class acm_memory $temp[$hash] = true; // This must never expire - $this->write('sql_' . $table_name, $temp, 0); + $this->_write('sql_' . $table_name, $temp, 0); } // store them in the right place @@ -314,7 +316,7 @@ class acm_memory } $db->sql_freeresult($query_result); - $this->write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); + $this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); $query_result = $query_id; } -- cgit v1.2.1 From 0cdad21cb38337255761b53513d5626674ab7986 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 15:04:36 +0000 Subject: Introduce XCache and eAccelerator, make some small changes to the abstract, forgot a period in the command for r9537 :( git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9538 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_eaccelerator.php | 123 ++++++++++++++++++++++++++++++++ phpBB/includes/acm/acm_memory.php | 15 +++- phpBB/includes/acm/acm_xcache.php | 106 +++++++++++++++++++++++++++ 3 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/acm/acm_eaccelerator.php create mode 100644 phpBB/includes/acm/acm_xcache.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php new file mode 100644 index 0000000000..3697fb5202 --- /dev/null +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -0,0 +1,123 @@ +serialize_header . 'O:') === 0) + { + $result = unserialize(substr($result, strlen($this->serialize_header))); + } + + return $result; + } + + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) + { + // Serialize objects and make them easy to detect + $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data; + + return eaccelerator_put($var, $data, $ttl); + } + + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) + { + return eaccelerator_rm($var); + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index 7875c3441e..a97f680d1e 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -228,7 +228,7 @@ class acm_memory { if ($var_name[0] == '_') { - return true; + return $this->_isset($var_name); } else { @@ -398,6 +398,19 @@ class acm_memory return @unlink($filename); } + + /** + * Check if a cache var exists + * + * @access protected + * @param string $var Cache key + * @return bool True if it exists, otherwise false + */ + function _isset($var) + { + // Most caches don't need to check + return true; + } } ?> \ No newline at end of file diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php new file mode 100644 index 0000000000..36a32c167e --- /dev/null +++ b/phpBB/includes/acm/acm_xcache.php @@ -0,0 +1,106 @@ + \ No newline at end of file -- cgit v1.2.1 From 710604caa328be820d6240cb9cfccf568bc874d2 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 15:09:59 +0000 Subject: Fix DOS line endings, evil<3 this doesn't count as spam you told me to :P git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9539 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/captcha_gd_wave.php | 1682 ++++++++++++++-------------- 1 file changed, 841 insertions(+), 841 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/captcha_gd_wave.php b/phpBB/includes/captcha/captcha_gd_wave.php index 41dfcdd9d4..d911d574f7 100644 --- a/phpBB/includes/captcha/captcha_gd_wave.php +++ b/phpBB/includes/captcha/captcha_gd_wave.php @@ -1,842 +1,842 @@ -width; - $img_y = $this->height; - - // Generate image - $img = imagecreatetruecolor($img_x, $img_y); - $x_grid = mt_rand(6, 10); - $y_grid = mt_rand(6, 10); - - // Ok, so lets cut to the chase. We could accurately represent this in 3d and - // do all the appropriate linear transforms. my questions is... why bother? - // The computational overhead is unnecessary when you consider the simple fact: - // we're not here to accurately represent a model, but to just show off some random-ish - // polygons - - // Conceive of 3 spaces. - // 1) planar-space (discrete "pixel" grid) - // 2) 3-space. (planar-space with z/height aspect) - // 3) image space (pixels on the screen) - // resolution of the planar-space we're embedding the text code in - $plane_x = 100; - $plane_y = 30; - - $subdivision_factor = 3; - // $box is the 4 points in img_space that correspond to the corners of the plane in 3-space - $box = array( - 'upper_left' => array( - 'x' => mt_rand(5, 15), - 'y' => mt_rand(10, 15) - ), - 'upper_right' => array( - 'x' => mt_rand($img_x - 35, $img_x - 19), - 'y' => mt_rand(10, 17) - ), - 'lower_left' => array( - 'x' => mt_rand($img_x - 5, $img_x - 45), - 'y' => mt_rand($img_y - 0, $img_y - 15) - ), - ); - $box['lower_right'] = array( - 'x' => $box['lower_left']['x'] + $box['upper_left']['x'] - $box['upper_right']['x'], - 'y' => $box['lower_left']['y'] + $box['upper_left']['y'] - $box['upper_right']['y'], - ); - - - // TODO - $background = imagecolorallocate($img, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255)); - imagefill($img, 0, 0, $background); - $black = imagecolorallocate($img, 0, 0, 0); - - $random = array(); - $fontcolors = array(); - - for ($i = 0; $i < 15; ++$i) - { - $random[$i] = imagecolorallocate($img, mt_rand(120, 255), mt_rand(120, 255), mt_rand(120, 255)); - } - - $fontcolors[0] = imagecolorallocate($img, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120)); - - $colors = array(); - - $minr = mt_rand(20, 30); - $ming = mt_rand(20, 30); - $minb = mt_rand(20, 30); - - $maxr = mt_rand(150, 230); - $maxg = mt_rand(150, 230); - $maxb = mt_rand(150, 230); - - for ($i = -30; $i <= 30; ++$i) - { - $coeff1 = ($i + 12) / 45; - $coeff2 = 1 - $coeff1; - $colors[$i] = imagecolorallocate($img, ($coeff2 * $maxr) + ($coeff1 * $minr), ($coeff2 * $maxg) + ($coeff1 * $ming), ($coeff2 * $maxb) + ($coeff1 * $minb)); - } - - // $img_buffer is the last row of 3-space positions (converted to img-space), cached - // (using this means we don't need to recalculate all 4 positions for each new polygon, - // merely the newest point that we're adding, which is then cached. - $img_buffer = array(array(), array()); - - // In image-space, the x- and y-offset necessary to move one unit in the x-direction in planar-space - $dxx = ($box['upper_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_x); - $dxy = ($box['upper_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_x); - - // In image-space, the x- and y-offset necessary to move one unit in the y-direction in planar-space - $dyx = ($box['lower_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_y); - $dyy = ($box['lower_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_y); - - // Initial captcha-letter offset in planar-space - $plane_offset_x = mt_rand(3, 8); - $plane_offset_y = mt_rand( 12, 15); - - // character map - $map = $this->captcha_bitmaps(); - - // matrix - $plane = array(); - - // for each character, we'll silkscreen it into our boolean pixel plane - for ($c = 0, $code_num = strlen($code); $c < $code_num; ++$c) - { - $letter = $code[$c]; - - for ($x = $map['width'] - 1; $x >= 0; --$x) - { - for ($y = $map['height'] - 1; $y >= 0; --$y) - { - if ($map['data'][$letter][$y][$x]) - { - $plane[$y + $plane_offset_y + (($c & 1) ? 1 : -1)][$x + $plane_offset_x] = true; - } - } - } - $plane_offset_x += 11; - } - - // calculate our first buffer, we can't actually draw polys with these yet - // img_pos_prev == screen x,y location to our immediate left. - // img_pos_cur == current screen x,y location - // we calculate screen position of our - // current cell based on the difference from the previous cell - // rather than recalculating from absolute coordinates - // What we cache into the $img_buffer contains the raised text coordinates. - $img_pos_prev = $img_buffer[0][0] = array($box['upper_left']['x'], $box['upper_left']['y']); - $cur_height = $prev_height = $this->wave_height(0, 0, $subdivision_factor); - $full_x = $plane_x * $subdivision_factor; - $full_y = $plane_y * $subdivision_factor; - - for ($x = 1; $x <= $full_x; ++$x) - { - $cur_height = $this->wave_height($x, 0, $subdivision_factor); - $offset = $cur_height - $prev_height; - $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); - - $img_buffer[0][$x] = $img_pos_cur; - $img_pos_prev = $img_pos_cur; - $prev_height = $cur_height; - } - - for ($y = 1; $y <= $full_y; ++$y) - { - // swap buffers - $buffer_cur = $y & 1; - $buffer_prev = 1 - $buffer_cur; - - $prev_height = $this->wave_height(0, $y, $subdivision_factor); - $offset = $prev_height - $this->wave_height(0, $y - 1, $subdivision_factor); - $img_pos_cur = array($img_buffer[$buffer_prev][0][0] + $dyx, min($img_buffer[$buffer_prev][0][1] + $dyy + $offset, $img_y - 1)); - - // make sure we don't try to write off the page - $img_pos_prev = $img_pos_cur; - - $img_buffer[$buffer_cur][0] = $img_pos_cur; - - for ($x = 1; $x <= $full_x; ++$x) - { - $cur_height = $this->wave_height($x, $y, $subdivision_factor) + $this->grid_height($x, $y, 1, $x_grid, $y_grid); - - // height is a z-factor, not a y-factor - $offset = $cur_height - $prev_height; - $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); - - // height is float, index it to an int, get closest color - $color = $colors[intval($cur_height)]; - $img_pos_prev = $img_pos_cur; - $prev_height = $cur_height; - - $y_index_old = intval(($y - 1) / $subdivision_factor); - $y_index_new = intval($y / $subdivision_factor); - $x_index_old = intval(($x - 1) / $subdivision_factor); - $x_index_new = intval($x / $subdivision_factor); - - if (!empty($plane[$y_index_new][$x_index_new])) - { - $img_pos_cur[1] += $this->wave_height($x, $y, $subdivision_factor, 1) - 30 - $cur_height; - $color = $colors[20]; - } - $img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1); - $img_buffer[$buffer_cur][$x] = $img_pos_cur; - - // Smooth the edges as much as possible by having not more than one low<->high traingle per square - // Otherwise, just - $diag_down = (empty($plane[$y_index_old][$x_index_old]) == empty($plane[$y_index_new][$x_index_new])); - $diag_up = (empty($plane[$y_index_old][$x_index_new]) == empty($plane[$y_index_new][$x_index_old])); - - // natural switching - $mode = ($x + $y) & 1; - - // override if it requires it - if ($diag_down != $diag_up) - { - $mode = $diag_up; - } - - if ($mode) - { - // +-/ / - // 1 |/ 2 /| - // / /-+ - $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x]); - $poly2 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_cur][$x], $img_buffer[$buffer_prev][$x]); - } - else - { - // \ \-+ - // 1 |\ 2 \| - // +-\ \ - $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_cur][$x]); - $poly2 = array_merge($img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x], $img_buffer[$buffer_cur][$x]); - } - - imagefilledpolygon($img, $poly1, 3, $color); - imagefilledpolygon($img, $poly2, 3, $color); - } - } - - // Output image - header('Content-Type: image/png'); - header('Cache-control: no-cache, no-store'); - //$mtime = explode(' ', microtime()); - //$totaltime = $mtime[0] + $mtime[1] - $starttime; - - //echo $totaltime . "
\n"; - //echo memory_get_usage() - $tmp; - imagepng($img); - imagedestroy($img); - } - - function wave_height($x, $y, $factor = 1, $tweak = 0.7) - { - // stretch the wave. TODO: pretty it up - $x = $x/5 + 180; - $y = $y/4; - return ((sin($x / (3 * $factor)) + sin($y / (3 * $factor))) * 10 * $tweak); - } - - function grid_height($x, $y, $factor = 1, $x_grid, $y_grid) - { - return ((!($x % ($x_grid * $factor)) || !($y % ($y_grid * $factor))) ? 3 : 0); - } - - function captcha_bitmaps() - { - return array( - 'width' => 9, - 'height' => 13, - 'data' => array( - 'A' => array( - array(0,0,1,1,1,1,0,0,0), - array(0,1,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,1,1,1,1,1,1,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'B' => array( - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,1,0,0), - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,1,0,0), - array(1,1,1,1,1,1,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'C' => array( - array(0,0,1,1,1,1,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'D' => array( - array(1,1,1,1,1,1,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,1,0), - array(1,1,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'E' => array( - array(0,0,1,1,1,1,1,1,1), - array(0,1,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,1,1,1,1,1,1,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,1,0,0,0,0,0,0,0), - array(0,0,1,1,1,1,1,1,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'F' => array( - array(0,0,1,1,1,1,1,1,0), - array(0,1,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'G' => array( - array(0,0,1,1,1,1,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,1,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'H' => array( - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,1,1,1,1,1,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'I' => array( - array(0,1,1,1,1,1,1,1,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,1,1,1,1,1,1,1,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'J' => array( - array(0,0,0,0,0,0,1,1,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,0,1,0,0,0,0,1,0), - array(0,0,0,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'K' => array( - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,1,0,0,0), - array(1,0,0,0,1,0,0,0,0), - array(1,0,0,1,0,0,0,0,0), - array(1,0,1,0,0,0,0,0,0), - array(1,1,0,0,0,0,0,0,0), - array(1,0,1,0,0,0,0,0,0), - array(1,0,0,1,0,0,0,0,0), - array(1,0,0,0,1,0,0,0,0), - array(1,0,0,0,0,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'L' => array( - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,1,0,0,0,0,0,0,0), - array(0,0,1,1,1,1,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'M' => array( - array(0,1,0,0,0,0,0,1,0), - array(0,1,1,0,0,0,1,1,0), - array(0,1,0,1,0,1,0,1,0), - array(0,1,0,0,1,0,0,1,0), - array(0,1,0,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'N' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,1,0,0,0,0,0,0,1), - array(1,0,1,0,0,0,0,0,1), - array(1,0,0,1,0,0,0,0,1), - array(1,0,0,0,1,0,0,0,1), - array(1,0,0,0,0,1,0,0,1), - array(1,0,0,0,0,0,1,0,1), - array(1,0,0,0,0,0,0,1,1), - array(1,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'O' => array( - array(0,0,0,1,1,1,0,0,0), - array(0,0,1,0,0,0,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,0,0,0,1,0,0), - array(0,0,0,1,1,1,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'P' => array( - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,1,0,0), - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'Q' => array( - array(0,0,1,1,1,1,0,0,0), - array(0,1,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,1,0,0,1,0), - array(1,0,0,0,0,1,0,1,0), - array(0,1,0,0,0,0,1,0,0), - array(0,0,1,1,1,1,0,1,0), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'R' => array( - array(1,1,1,1,1,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,1,0,0), - array(1,1,1,1,1,1,0,0,0), - array(1,0,1,0,0,0,0,0,0), - array(1,0,0,1,0,0,0,0,0), - array(1,0,0,0,1,0,0,0,0), - array(1,0,0,0,0,1,0,0,0), - array(1,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'S' => array( - array(0,0,1,1,1,1,1,1,1), - array(0,1,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,1,0,0,0,0,0,0,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,1,0), - array(1,1,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'T' => array( - array(1,1,1,1,1,1,1,1,1), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'U' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'V' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,0,0,0,1,0,0), - array(0,0,0,1,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'W' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,1,0,0,0,1), - array(1,0,0,1,0,1,0,0,1), - array(1,0,1,0,0,0,1,0,1), - array(1,1,0,0,0,0,0,1,1), - array(1,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'X' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,0,0,0,1,0,0), - array(0,0,0,1,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,1,0,1,0,0,0), - array(0,0,1,0,0,0,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'Y' => array( - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,0,0,0,1,0,0), - array(0,0,0,1,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - 'Z' => array( - array(1,1,1,1,1,1,1,1,1), - array(1,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,1,0,0,0,0,0), - array(0,0,1,0,0,0,0,0,0), - array(0,1,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,1), - array(1,1,1,1,1,1,1,1,1), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '1' => array( - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,1,1,0,0,0,0), - array(0,0,1,0,1,0,0,0,0), - array(0,1,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,1,1,1,1,1,1,1,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '2' => array( - array(0,0,0,1,1,1,0,0,0), - array(0,0,1,0,0,0,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,1,0,0,0,0,0), - array(0,0,1,0,0,0,0,0,0), - array(0,1,1,1,1,1,1,1,1), - array(0,0,0,0,0,0,0,0,0), - ), - '3' => array( - array(0,0,0,1,1,1,1,0,0), - array(0,0,1,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,1,1,0,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,0,1,0,0,0,0,1,0), - array(0,0,0,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '4' => array( - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,1,1,0), - array(0,0,0,0,0,1,0,1,0), - array(0,0,0,0,1,0,0,1,0), - array(0,0,0,1,0,0,0,1,0), - array(0,0,1,0,0,0,0,1,0), - array(0,1,1,1,1,1,1,1,1), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '5' => array( - array(1,1,1,1,1,1,1,1,1), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(0,1,0,0,0,0,0,0,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '6' => array( - array(0,0,1,1,1,1,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,0,0,0,0,0,0), - array(1,0,0,1,1,1,1,0,0), - array(1,0,1,0,0,0,0,1,0), - array(1,1,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '7' => array( - array(1,1,1,1,1,1,1,1,1), - array(1,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,1,0), - array(0,0,0,0,0,0,1,0,0), - array(0,0,0,0,0,1,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,1,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '8' => array( - array(0,0,1,1,1,1,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,1,0,0,0,0,0,1,0), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(1,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,0), - array(0,0,1,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - '9' => array( - array(0,0,0,1,1,1,1,0,0), - array(0,0,1,0,0,0,0,1,0), - array(0,1,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,1,1), - array(0,0,1,1,1,1,1,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,0,0,0,0,0,0,0,1), - array(0,1,0,0,0,0,0,0,1), - array(0,0,1,0,0,0,0,1,0), - array(0,0,0,1,1,1,1,0,0), - array(0,0,0,0,0,0,0,0,0), - array(0,0,0,0,0,0,0,0,0), - ), - ) - ); - } -} - +width; + $img_y = $this->height; + + // Generate image + $img = imagecreatetruecolor($img_x, $img_y); + $x_grid = mt_rand(6, 10); + $y_grid = mt_rand(6, 10); + + // Ok, so lets cut to the chase. We could accurately represent this in 3d and + // do all the appropriate linear transforms. my questions is... why bother? + // The computational overhead is unnecessary when you consider the simple fact: + // we're not here to accurately represent a model, but to just show off some random-ish + // polygons + + // Conceive of 3 spaces. + // 1) planar-space (discrete "pixel" grid) + // 2) 3-space. (planar-space with z/height aspect) + // 3) image space (pixels on the screen) + // resolution of the planar-space we're embedding the text code in + $plane_x = 100; + $plane_y = 30; + + $subdivision_factor = 3; + // $box is the 4 points in img_space that correspond to the corners of the plane in 3-space + $box = array( + 'upper_left' => array( + 'x' => mt_rand(5, 15), + 'y' => mt_rand(10, 15) + ), + 'upper_right' => array( + 'x' => mt_rand($img_x - 35, $img_x - 19), + 'y' => mt_rand(10, 17) + ), + 'lower_left' => array( + 'x' => mt_rand($img_x - 5, $img_x - 45), + 'y' => mt_rand($img_y - 0, $img_y - 15) + ), + ); + $box['lower_right'] = array( + 'x' => $box['lower_left']['x'] + $box['upper_left']['x'] - $box['upper_right']['x'], + 'y' => $box['lower_left']['y'] + $box['upper_left']['y'] - $box['upper_right']['y'], + ); + + + // TODO + $background = imagecolorallocate($img, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255)); + imagefill($img, 0, 0, $background); + $black = imagecolorallocate($img, 0, 0, 0); + + $random = array(); + $fontcolors = array(); + + for ($i = 0; $i < 15; ++$i) + { + $random[$i] = imagecolorallocate($img, mt_rand(120, 255), mt_rand(120, 255), mt_rand(120, 255)); + } + + $fontcolors[0] = imagecolorallocate($img, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120)); + + $colors = array(); + + $minr = mt_rand(20, 30); + $ming = mt_rand(20, 30); + $minb = mt_rand(20, 30); + + $maxr = mt_rand(150, 230); + $maxg = mt_rand(150, 230); + $maxb = mt_rand(150, 230); + + for ($i = -30; $i <= 30; ++$i) + { + $coeff1 = ($i + 12) / 45; + $coeff2 = 1 - $coeff1; + $colors[$i] = imagecolorallocate($img, ($coeff2 * $maxr) + ($coeff1 * $minr), ($coeff2 * $maxg) + ($coeff1 * $ming), ($coeff2 * $maxb) + ($coeff1 * $minb)); + } + + // $img_buffer is the last row of 3-space positions (converted to img-space), cached + // (using this means we don't need to recalculate all 4 positions for each new polygon, + // merely the newest point that we're adding, which is then cached. + $img_buffer = array(array(), array()); + + // In image-space, the x- and y-offset necessary to move one unit in the x-direction in planar-space + $dxx = ($box['upper_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_x); + $dxy = ($box['upper_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_x); + + // In image-space, the x- and y-offset necessary to move one unit in the y-direction in planar-space + $dyx = ($box['lower_right']['x'] - $box['upper_left']['x']) / ($subdivision_factor * $plane_y); + $dyy = ($box['lower_right']['y'] - $box['upper_left']['y']) / ($subdivision_factor * $plane_y); + + // Initial captcha-letter offset in planar-space + $plane_offset_x = mt_rand(3, 8); + $plane_offset_y = mt_rand( 12, 15); + + // character map + $map = $this->captcha_bitmaps(); + + // matrix + $plane = array(); + + // for each character, we'll silkscreen it into our boolean pixel plane + for ($c = 0, $code_num = strlen($code); $c < $code_num; ++$c) + { + $letter = $code[$c]; + + for ($x = $map['width'] - 1; $x >= 0; --$x) + { + for ($y = $map['height'] - 1; $y >= 0; --$y) + { + if ($map['data'][$letter][$y][$x]) + { + $plane[$y + $plane_offset_y + (($c & 1) ? 1 : -1)][$x + $plane_offset_x] = true; + } + } + } + $plane_offset_x += 11; + } + + // calculate our first buffer, we can't actually draw polys with these yet + // img_pos_prev == screen x,y location to our immediate left. + // img_pos_cur == current screen x,y location + // we calculate screen position of our + // current cell based on the difference from the previous cell + // rather than recalculating from absolute coordinates + // What we cache into the $img_buffer contains the raised text coordinates. + $img_pos_prev = $img_buffer[0][0] = array($box['upper_left']['x'], $box['upper_left']['y']); + $cur_height = $prev_height = $this->wave_height(0, 0, $subdivision_factor); + $full_x = $plane_x * $subdivision_factor; + $full_y = $plane_y * $subdivision_factor; + + for ($x = 1; $x <= $full_x; ++$x) + { + $cur_height = $this->wave_height($x, 0, $subdivision_factor); + $offset = $cur_height - $prev_height; + $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); + + $img_buffer[0][$x] = $img_pos_cur; + $img_pos_prev = $img_pos_cur; + $prev_height = $cur_height; + } + + for ($y = 1; $y <= $full_y; ++$y) + { + // swap buffers + $buffer_cur = $y & 1; + $buffer_prev = 1 - $buffer_cur; + + $prev_height = $this->wave_height(0, $y, $subdivision_factor); + $offset = $prev_height - $this->wave_height(0, $y - 1, $subdivision_factor); + $img_pos_cur = array($img_buffer[$buffer_prev][0][0] + $dyx, min($img_buffer[$buffer_prev][0][1] + $dyy + $offset, $img_y - 1)); + + // make sure we don't try to write off the page + $img_pos_prev = $img_pos_cur; + + $img_buffer[$buffer_cur][0] = $img_pos_cur; + + for ($x = 1; $x <= $full_x; ++$x) + { + $cur_height = $this->wave_height($x, $y, $subdivision_factor) + $this->grid_height($x, $y, 1, $x_grid, $y_grid); + + // height is a z-factor, not a y-factor + $offset = $cur_height - $prev_height; + $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); + + // height is float, index it to an int, get closest color + $color = $colors[intval($cur_height)]; + $img_pos_prev = $img_pos_cur; + $prev_height = $cur_height; + + $y_index_old = intval(($y - 1) / $subdivision_factor); + $y_index_new = intval($y / $subdivision_factor); + $x_index_old = intval(($x - 1) / $subdivision_factor); + $x_index_new = intval($x / $subdivision_factor); + + if (!empty($plane[$y_index_new][$x_index_new])) + { + $img_pos_cur[1] += $this->wave_height($x, $y, $subdivision_factor, 1) - 30 - $cur_height; + $color = $colors[20]; + } + $img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1); + $img_buffer[$buffer_cur][$x] = $img_pos_cur; + + // Smooth the edges as much as possible by having not more than one low<->high traingle per square + // Otherwise, just + $diag_down = (empty($plane[$y_index_old][$x_index_old]) == empty($plane[$y_index_new][$x_index_new])); + $diag_up = (empty($plane[$y_index_old][$x_index_new]) == empty($plane[$y_index_new][$x_index_old])); + + // natural switching + $mode = ($x + $y) & 1; + + // override if it requires it + if ($diag_down != $diag_up) + { + $mode = $diag_up; + } + + if ($mode) + { + // +-/ / + // 1 |/ 2 /| + // / /-+ + $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x]); + $poly2 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_cur][$x], $img_buffer[$buffer_prev][$x]); + } + else + { + // \ \-+ + // 1 |\ 2 \| + // +-\ \ + $poly1 = array_merge($img_buffer[$buffer_cur][$x - 1], $img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_cur][$x]); + $poly2 = array_merge($img_buffer[$buffer_prev][$x - 1], $img_buffer[$buffer_prev][$x], $img_buffer[$buffer_cur][$x]); + } + + imagefilledpolygon($img, $poly1, 3, $color); + imagefilledpolygon($img, $poly2, 3, $color); + } + } + + // Output image + header('Content-Type: image/png'); + header('Cache-control: no-cache, no-store'); + //$mtime = explode(' ', microtime()); + //$totaltime = $mtime[0] + $mtime[1] - $starttime; + + //echo $totaltime . "
\n"; + //echo memory_get_usage() - $tmp; + imagepng($img); + imagedestroy($img); + } + + function wave_height($x, $y, $factor = 1, $tweak = 0.7) + { + // stretch the wave. TODO: pretty it up + $x = $x/5 + 180; + $y = $y/4; + return ((sin($x / (3 * $factor)) + sin($y / (3 * $factor))) * 10 * $tweak); + } + + function grid_height($x, $y, $factor = 1, $x_grid, $y_grid) + { + return ((!($x % ($x_grid * $factor)) || !($y % ($y_grid * $factor))) ? 3 : 0); + } + + function captcha_bitmaps() + { + return array( + 'width' => 9, + 'height' => 13, + 'data' => array( + 'A' => array( + array(0,0,1,1,1,1,0,0,0), + array(0,1,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'B' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'C' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'D' => array( + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'E' => array( + array(0,0,1,1,1,1,1,1,1), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'F' => array( + array(0,0,1,1,1,1,1,1,0), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'G' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'H' => array( + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'I' => array( + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'J' => array( + array(0,0,0,0,0,0,1,1,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'K' => array( + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,1,0,0,0,0,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'L' => array( + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'M' => array( + array(0,1,0,0,0,0,0,1,0), + array(0,1,1,0,0,0,1,1,0), + array(0,1,0,1,0,1,0,1,0), + array(0,1,0,0,1,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'N' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,1,0,0,0,0,0,0,1), + array(1,0,1,0,0,0,0,0,1), + array(1,0,0,1,0,0,0,0,1), + array(1,0,0,0,1,0,0,0,1), + array(1,0,0,0,0,1,0,0,1), + array(1,0,0,0,0,0,1,0,1), + array(1,0,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'O' => array( + array(0,0,0,1,1,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,1,1,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'P' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Q' => array( + array(0,0,1,1,1,1,0,0,0), + array(0,1,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,1,0,0,1,0), + array(1,0,0,0,0,1,0,1,0), + array(0,1,0,0,0,0,1,0,0), + array(0,0,1,1,1,1,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'R' => array( + array(1,1,1,1,1,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,1,0,0), + array(1,1,1,1,1,1,0,0,0), + array(1,0,1,0,0,0,0,0,0), + array(1,0,0,1,0,0,0,0,0), + array(1,0,0,0,1,0,0,0,0), + array(1,0,0,0,0,1,0,0,0), + array(1,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'S' => array( + array(0,0,1,1,1,1,1,1,1), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(1,1,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'T' => array( + array(1,1,1,1,1,1,1,1,1), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'U' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'V' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'W' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,1,0,0,0,1), + array(1,0,0,1,0,1,0,0,1), + array(1,0,1,0,0,0,1,0,1), + array(1,1,0,0,0,0,0,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'X' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Y' => array( + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,0,0,0,1,0,0), + array(0,0,0,1,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + 'Z' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,0,0,0,0), + array(0,0,1,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,1), + array(1,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '1' => array( + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,1,0,0,0,0), + array(0,0,1,0,1,0,0,0,0), + array(0,1,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,1,1,1,1,1,1,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '2' => array( + array(0,0,0,1,1,1,0,0,0), + array(0,0,1,0,0,0,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,1,0,0,0,0,0), + array(0,0,1,0,0,0,0,0,0), + array(0,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,0,0), + ), + '3' => array( + array(0,0,0,1,1,1,1,0,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '4' => array( + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,1,0), + array(0,0,0,0,0,1,0,1,0), + array(0,0,0,0,1,0,0,1,0), + array(0,0,0,1,0,0,0,1,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,1,1,1,1,1,1,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '5' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(0,1,0,0,0,0,0,0,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '6' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,0,0,0,0,0,0), + array(1,0,0,1,1,1,1,0,0), + array(1,0,1,0,0,0,0,1,0), + array(1,1,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '7' => array( + array(1,1,1,1,1,1,1,1,1), + array(1,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,1,0), + array(0,0,0,0,0,0,1,0,0), + array(0,0,0,0,0,1,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,1,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '8' => array( + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,1,0,0,0,0,0,1,0), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(1,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,0), + array(0,0,1,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + '9' => array( + array(0,0,0,1,1,1,1,0,0), + array(0,0,1,0,0,0,0,1,0), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,1,1), + array(0,0,1,1,1,1,1,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,0,0,0,0,0,0,0,1), + array(0,1,0,0,0,0,0,0,1), + array(0,0,1,0,0,0,0,1,0), + array(0,0,0,1,1,1,1,0,0), + array(0,0,0,0,0,0,0,0,0), + array(0,0,0,0,0,0,0,0,0), + ), + ) + ); + } +} + ?> \ No newline at end of file -- cgit v1.2.1 From cd1c5de3a508ec851b11baf4095449c66ee6c770 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 15:37:53 +0000 Subject: Finished I hope, appropriate errors when modules are missing. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9540 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 2 ++ phpBB/includes/acm/acm_eaccelerator.php | 2 ++ phpBB/includes/acm/acm_memcache.php | 17 +++++++---------- phpBB/includes/acm/acm_memory.php | 7 +++++++ phpBB/includes/acm/acm_xcache.php | 2 ++ 5 files changed, 20 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index cbda86bec0..14159f6826 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -28,6 +28,8 @@ if (!class_exists('acm_memory')) */ class acm extends acm_memory { + var $extension = 'apc'; + function acm() { // Call the parent constructor diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php index 3697fb5202..bce6c53f1c 100644 --- a/phpBB/includes/acm/acm_eaccelerator.php +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -29,6 +29,8 @@ if (!class_exists('acm_memory')) */ class acm extends acm_memory { + var $extension = 'eaccelerator'; + var $serialize_header = '#phpbb-serialized#'; function acm() diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 1ec37f1b3b..0544d23996 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -16,16 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!extension_loaded('memcache') || !defined('PHPBB_ACM_MEMCACHE_HOST')) -{ - // Memcached will not work, include the null ACM at least the - // board will still work. - // @todo Could change this for a simple error though. - require("${phpbb_root_path}includes/acm/acm_null.$phpEx"); - - return; -} - // Include the abstract base if (!class_exists('acm_memory')) { @@ -48,6 +38,8 @@ if (!defined('PHPBB_ACM_MEMCACHE_COMPRESS')) */ class acm extends acm_memory { + var $extension = 'memcache'; + var $memcache; var $flags = 0; @@ -56,6 +48,11 @@ class acm extends acm_memory // Call the parent constructor parent::acm_memory(); + if (!defined('PHPBB_ACM_MEMCACHE_HOST')) + { + trigger_error('Missing required constant [PHPBB_ACM_MEMCACHE_HOST] for memcache ACM module.', E_USER_ERROR); + } + $this->memcache = new Memcache; $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index a97f680d1e..85e7a7b9d7 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -37,6 +37,13 @@ class acm_memory global $phpbb_root_path; $this->cache_dir = $phpbb_root_path . 'cache/'; + + if (!isset($this->extension) || !extension_loaded($this->extension)) + { + global $acm_type; + + trigger_error("Could not find required extension [{$this->extension}] for the ACM module $acm_type.", E_USER_ERROR); + } } /** diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index 36a32c167e..5b4ecd68d8 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -28,6 +28,8 @@ if (!class_exists('acm_memory')) */ class acm extends acm_memory { + var $extension = 'xcache'; + function acm() { // Call the parent constructor -- cgit v1.2.1 From 832c6b2f62917b0c456c7a9f33f40d2ebeb75387 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 4 Jun 2009 15:59:42 +0000 Subject: Use unique per board cache keys per [1] important when using shared memory from opcode caches with multiple boards on one server. [1] http://area51.phpbb.com/phpBB/viewtopic.php?p=201739#p201739 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9541 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 6 +++--- phpBB/includes/acm/acm_eaccelerator.php | 7 ++++--- phpBB/includes/acm/acm_memcache.php | 6 +++--- phpBB/includes/acm/acm_memory.php | 7 +++++-- phpBB/includes/acm/acm_xcache.php | 8 ++++---- 5 files changed, 19 insertions(+), 15 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index 14159f6826..ff24dfa0d8 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -57,7 +57,7 @@ class acm extends acm_memory */ function _read($var) { - return apc_fetch($var); + return apc_fetch($this->key_prefix . $var); } /** @@ -71,7 +71,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return apc_store($var, $data, $ttl); + return apc_store($this->key_prefix . $var, $data, $ttl); } /** @@ -83,7 +83,7 @@ class acm extends acm_memory */ function _delete($var) { - return apc_delete($var); + return apc_delete($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php index bce6c53f1c..7530043e83 100644 --- a/phpBB/includes/acm/acm_eaccelerator.php +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -49,6 +49,7 @@ class acm extends acm_memory foreach (eaccelerator_list_keys() as $var) { // @todo Check why the substr() + // @todo Only unset vars matching $this->key_prefix eaccelerator_rm(substr($var['name'], 1)); } @@ -76,7 +77,7 @@ class acm extends acm_memory */ function _read($var) { - $result = eaccelerator_get($var); + $result = eaccelerator_get($this->key_prefix . $var); if ($result === null) { @@ -106,7 +107,7 @@ class acm extends acm_memory // Serialize objects and make them easy to detect $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data; - return eaccelerator_put($var, $data, $ttl); + return eaccelerator_put($this->key_prefix . $var, $data, $ttl); } /** @@ -118,7 +119,7 @@ class acm extends acm_memory */ function _delete($var) { - return eaccelerator_rm($var); + return eaccelerator_rm($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 0544d23996..b22205578e 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -91,7 +91,7 @@ class acm extends acm_memory */ function _read($var) { - return $this->memcache->get($var); + return $this->memcache->get($this->key_prefix . $var); } /** @@ -105,7 +105,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return $this->memcache->set($var, $data, $this->flags, $ttl); + return $this->memcache->set($this->key_prefix . $var, $data, $this->flags, $ttl); } /** @@ -117,7 +117,7 @@ class acm extends acm_memory */ function _delete($var) { - return $this->memcache->delete($var); + return $this->memcache->delete($this->key_prefix . $var); } } diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index 85e7a7b9d7..c7b5d34a47 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -22,6 +22,8 @@ if (!defined('IN_PHPBB')) */ class acm_memory { + var $key_prefix; + var $vars = array(); var $is_modified = false; @@ -34,9 +36,10 @@ class acm_memory */ function acm_memory() { - global $phpbb_root_path; + global $phpbb_root_path, $dbname, $table_prefix; - $this->cache_dir = $phpbb_root_path . 'cache/'; + $this->cache_dir = $phpbb_root_path . 'cache/'; + $this->key_prefix = md5($dbname, $table_prefix) . '_'; if (!isset($this->extension) || !extension_loaded($this->extension)) { diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index 5b4ecd68d8..9cb8eae272 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -62,7 +62,7 @@ class acm extends acm_memory */ function _read($var) { - return xcache_get($var); + return xcache_get($this->key_prefix . $var); } /** @@ -76,7 +76,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return xcache_set($var, $data, $ttl); + return xcache_set($this->key_prefix . $var, $data, $ttl); } /** @@ -88,7 +88,7 @@ class acm extends acm_memory */ function _delete($var) { - return xcache_unset($var); + return xcache_unset($this->key_prefix . $var); } /** @@ -101,7 +101,7 @@ class acm extends acm_memory function _isset($var) { // Most caches don't need to check - return xcache_isset($var); + return xcache_isset($this->key_prefix . $var); } } -- cgit v1.2.1 From a7c7f6a6a80f99dfd6443d5bd905987361812318 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Jun 2009 14:51:17 +0000 Subject: Here we go! New data format for the file ACM module: - No longer PHP files that are included - Contain a simple PHP header to stop people attempting to read them - Read using file system functions only reading as much data as required Result is: - Better performance by minimising file system reads - Injected HTML from nasty scripts no longer contaminates the board - Opcode caches are no longer thrashed and fragmented by the many files we generate git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9543 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_file.php | 415 +++++++++++++++++++++++++++++----------- 1 file changed, 305 insertions(+), 110 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index f9ff92e19d..234be5c5d1 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -3,7 +3,7 @@ * * @package acm * @version $Id$ -* @copyright (c) 2005 phpBB Group +* @copyright (c) 2005, 2009 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -44,17 +44,7 @@ class acm */ function load() { - global $phpEx; - if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) - { - @include($this->cache_dir . 'data_global.' . $phpEx); - } - else - { - return false; - } - - return true; + return $this->_read('data_global'); } /** @@ -86,22 +76,7 @@ class acm global $phpEx; - if ($fp = @fopen($this->cache_dir . 'data_global.' . $phpEx, 'wb')) - { - @flock($fp, LOCK_EX); - fwrite($fp, "vars = " . var_export($this->vars, true) . ";\n\n\$this->var_expires = " . var_export($this->var_expires, true) . "\n?>"); - @flock($fp, LOCK_UN); - fclose($fp); - - if (!function_exists('phpbb_chmod')) - { - global $phpbb_root_path; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } - - phpbb_chmod($this->cache_dir . 'data_global.' . $phpEx, CHMOD_READ | CHMOD_WRITE); - } - else + if (!$this->_write('data_global')) { // Now, this occurred how often? ... phew, just tell the user then... if (!@is_writable($this->cache_dir)) @@ -132,6 +107,8 @@ class acm return; } + $time = time(); + while (($entry = readdir($dir)) !== false) { if (!preg_match('/^(sql_|data_(?!global))/', $entry)) @@ -139,9 +116,20 @@ class acm continue; } - $expired = true; - @include($this->cache_dir . $entry); - if ($expired) + if (!($handle = @fopen($this->cache_dir . $entry, 'rb'))) + { + continue; + } + + // Skip the PHP header + fgets($handle); + + // Skip expiration + $expires = (int) fgets($handle); + + fclose($handle); + + if ($time >= $expires) { $this->remove_file($this->cache_dir . $entry); } @@ -157,7 +145,7 @@ class acm foreach ($this->var_expires as $var_name => $expires) { - if (time() > $expires) + if ($time >= $expires) { $this->destroy($var_name); } @@ -181,8 +169,7 @@ class acm return false; } - @include($this->cache_dir . "data{$var_name}.$phpEx"); - return (isset($data)) ? $data : false; + return $this->_read('data' . $var_name); } else { @@ -197,23 +184,7 @@ class acm { if ($var_name[0] == '_') { - global $phpEx; - - if ($fp = @fopen($this->cache_dir . "data{$var_name}.$phpEx", 'wb')) - { - @flock($fp, LOCK_EX); - fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$data = " . (sizeof($var) ? "unserialize(" . var_export(serialize($var), true) . ");" : 'array();') . "\n\n?>"); - @flock($fp, LOCK_UN); - fclose($fp); - - if (!function_exists('phpbb_chmod')) - { - global $phpbb_root_path; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } - - phpbb_chmod($this->cache_dir . "data{$var_name}.$phpEx", CHMOD_READ | CHMOD_WRITE); - } + $this->_write('data' . $var_name, $var, time() + $ttl); } else { @@ -288,32 +259,31 @@ class acm continue; } - // The following method is more failproof than simply assuming the query is on line 3 (which it should be) - $check_line = @file_get_contents($this->cache_dir . $entry); - - if (empty($check_line)) + if (!($handle = @fopen($this->cache_dir . $entry, 'rb'))) { continue; } - // Now get the contents between /* and */ - $check_line = substr($check_line, strpos($check_line, '/* ') + 3, strpos($check_line, ' */') - strpos($check_line, '/* ') - 3); + // Skip the PHP header + fgets($handle); + + // Skip expiration + fgets($handle); + + // Grab the query, remove the LF + $query = substr(fgets($handle), 0, -1); + + fclose($handle); - $found = false; foreach ($table as $check_table) { // Better catch partial table names than no table names. ;) - if (strpos($check_line, $check_table) !== false) + if (strpos($query, $check_table) !== false) { - $found = true; + $this->remove_file($this->cache_dir . $entry); break; } } - - if ($found) - { - $this->remove_file($this->cache_dir . $entry); - } } closedir($dir); @@ -371,29 +341,16 @@ class acm */ function sql_load($query) { - global $phpEx; - // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); - - if (!file_exists($this->cache_dir . 'sql_' . md5($query) . ".$phpEx")) - { - return false; - } - - @include($this->cache_dir . 'sql_' . md5($query) . ".$phpEx"); - if (!isset($expired)) - { - return false; - } - else if ($expired) + if (($rowset = $this->_read('sql_' . md5($query))) === false) { - $this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx", true); return false; } + $query_id = sizeof($this->sql_rowset); + $this->sql_rowset[$query_id] = $rowset; $this->sql_row_pointer[$query_id] = 0; return $query_id; @@ -404,41 +361,23 @@ class acm */ function sql_save($query, &$query_result, $ttl) { - global $db, $phpEx; + global $db; // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $filename = $this->cache_dir . 'sql_' . md5($query) . '.' . $phpEx; - - if ($fp = @fopen($filename, 'wb')) - { - @flock($fp, LOCK_EX); - - $query_id = sizeof($this->sql_rowset); - $this->sql_rowset[$query_id] = array(); - $this->sql_row_pointer[$query_id] = 0; - - while ($row = $db->sql_fetchrow($query_result)) - { - $this->sql_rowset[$query_id][] = $row; - } - $db->sql_freeresult($query_result); - - $file = " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n"; - - fwrite($fp, $file . "\n\$this->sql_rowset[\$query_id] = " . (sizeof($this->sql_rowset[$query_id]) ? "unserialize(" . var_export(serialize($this->sql_rowset[$query_id]), true) . ");" : 'array();') . "\n\n?>"); - @flock($fp, LOCK_UN); - fclose($fp); - if (!function_exists('phpbb_chmod')) - { - global $phpbb_root_path; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } + $query_id = sizeof($this->sql_rowset); + $this->sql_rowset[$query_id] = array(); + $this->sql_row_pointer[$query_id] = 0; - phpbb_chmod($filename, CHMOD_READ | CHMOD_WRITE); + while ($row = $db->sql_fetchrow($query_result)) + { + $this->sql_rowset[$query_id][] = $row; + } + $db->sql_freeresult($query_result); + if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query)) + { $query_result = $query_id; } } @@ -507,6 +446,262 @@ class acm return true; } + /** + * Read cached data from a specified file + * + * @access private + * @param string $filename Filename to write + * @return mixed False if an error was encountered, otherwise the data type of the cached data + */ + function _read($filename) + { + global $phpEx; + + $file = "{$this->cache_dir}$filename.$phpEx"; + + $type = substr($filename, 0, strpos($filename, '_')); + + if (!file_exists($file)) + { + return false; + } + + if (!($handle = @fopen($file, 'rb'))) + { + return false; + } + + // Skip the PHP header + fgets($handle); + + if ($filename == 'data_global') + { + $this->vars = $this->var_expires = array(); + + $time = time(); + + while (($expires = (int) fgets($handle)) && !feof($handle)) + { + // Number of bytes of data + $bytes = substr(fgets($handle), 0, -1); + + if (!is_numeric($bytes) || ($bytes = (int) $bytes) === 0) + { + // We cannot process the file without a valid number of bytes + // so we discard it + fclose($handle); + + $this->vars = $this->var_expires = array(); + $this->is_modified = false; + + $this->remove_file($file); + + return false; + } + + if ($time >= $expires) + { + fseek($handle, $bytes, SEEK_CUR); + + continue; + } + + $var_name = substr(fgets($handle), 0, -1); + + // Read the length of bytes that consists of data. + $data = fread($handle, $bytes - strlen($var_name)); + $data = @unserialize($data); + + // Don't use the data if it was invalid + if ($data !== false) + { + $this->vars[$var_name] = $data; + $this->var_expires[$var_name] = $expires; + } + + // Absorb the LF + fgets($handle); + } + + fclose($handle); + + $this->is_modified = false; + + return true; + } + else + { + $data = false; + $line = 0; + + while (($buffer = fgets($handle)) && !feof($handle)) + { + $buffer = substr($buffer, 0, -1); // Remove the LF + + // $buffer is only used to read integers + // if it is non numeric we have an invalid + // cache file, which we will now remove. + if (!is_numeric($buffer)) + { + break; + } + + if ($line == 0) + { + $expires = (int) $buffer; + + if (time() >= $expires) + { + break; + } + + if ($type == 'sql') + { + // Skip the query + fgets($handle); + } + } + else if ($line == 1) + { + $bytes = (int) $buffer; + + // Never should have 0 bytes + if (!$bytes) + { + break; + } + + // Grab the serialized data + $data = fread($handle, $bytes); + + // Read 1 byte, to trigger EOF + fread($handle, 1); + + if (!feof($handle)) + { + // Somebody tampered with our data + $data = false; + } + break; + } + else + { + // Something went wrong + break; + } + $line++; + } + fclose($handle); + + // unserialize if we got some data + $data = ($data !== false) ? @unserialize($data) : $data; + + if ($data === false) + { + $this->remove_file($file); + return false; + } + + return $data; + } + } + + /** + * Write cache data to a specified file + * + * 'data_global' is a special case and the generated format is different for this file: + * + * + * (expiration) + * (length of var and serialised data) + * (var) + * (serialised data) + * ... (repeat) + * + * + * The other files have a similar format: + * + * + * (expiration) + * (query) [SQL files only] + * (length of serialised data) + * (serialised data) + * + * + * @access private + * @param string $filename Filename to write + * @param mixed $data Data to store + * @param int $expires Timestamp when the data expires + * @param string $query Query when caching SQL queries + * @return bool True if the file was successfully created, otherwise false + */ + function _write($filename, $data = null, $expires = 0, $query = '') + { + global $phpEx; + + $file = "{$this->cache_dir}$filename.$phpEx"; + + if ($handle = @fopen($file, 'wb')) + { + @flock($handle, LOCK_EX); + + // File header + fwrite($handle, '<' . '?php exit; ?' . '>'); + + if ($filename == 'data_global') + { + // Global data is a different format + foreach ($this->vars as $var => $data) + { + if (strpos($var, "\r") !== false || strpos($var, "\n") !== false) + { + // CR/LF would cause fgets() to read the cache file incorrectly + // do not cache test entries, they probably won't be read back + // the cache keys should really be alphanumeric with a few symbols. + continue; + } + $data = serialize($data); + + // Write out the expiration time + fwrite($handle, "\n" . $this->var_expires[$var] . "\n"); + + // Length of the remaining data for this var (ignoring two LF's) + fwrite($handle, strlen($data . $var) . "\n"); + fwrite($handle, $var . "\n"); + fwrite($handle, $data); + } + } + else + { + fwrite($handle, "\n" . $expires . "\n"); + + if (strpos($filename, 'sql_') === 0) + { + fwrite($handle, $query . "\n"); + } + $data = serialize($data); + + fwrite($handle, strlen($data) . "\n"); + fwrite($handle, $data); + } + + @flock($handle, LOCK_UN); + fclose($handle); + + if (!function_exists('phpbb_chmod')) + { + global $phpbb_root_path; + include($phpbb_root_path . 'includes/functions.' . $phpEx); + } + + phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); + + return true; + } + + return false; + } + /** * Removes/unlinks file */ -- cgit v1.2.1 From 9c00496ff5f5d940d34692c4800e209887d7e9fa Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Jun 2009 15:40:56 +0000 Subject: Fix a small bug with xcache (thanks bantu), and some code consistency changes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9544 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_apc.php | 8 +------- phpBB/includes/acm/acm_eaccelerator.php | 8 +------- phpBB/includes/acm/acm_memcache.php | 2 +- phpBB/includes/acm/acm_xcache.php | 13 ++++--------- 4 files changed, 7 insertions(+), 24 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index ff24dfa0d8..1a487f94ad 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) // Include the abstract base if (!class_exists('acm_memory')) { - require("${phpbb_root_path}includes/acm/acm_memory.$phpEx"); + require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx"); } /** @@ -30,12 +30,6 @@ class acm extends acm_memory { var $extension = 'apc'; - function acm() - { - // Call the parent constructor - parent::acm_memory(); - } - /** * Purge cache data * diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php index 7530043e83..1a3cf3c0f7 100644 --- a/phpBB/includes/acm/acm_eaccelerator.php +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) // Include the abstract base if (!class_exists('acm_memory')) { - require("${phpbb_root_path}includes/acm/acm_memory.$phpEx"); + require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx"); } /** @@ -33,12 +33,6 @@ class acm extends acm_memory var $serialize_header = '#phpbb-serialized#'; - function acm() - { - // Call the parent constructor - parent::acm_memory(); - } - /** * Purge cache data * diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index b22205578e..5a34a2a51d 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) // Include the abstract base if (!class_exists('acm_memory')) { - require("${phpbb_root_path}includes/acm/acm_memory.$phpEx"); + require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx"); } if (!defined('PHPBB_ACM_MEMCACHE_PORT')) diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index 9cb8eae272..ad527b8220 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) // Include the abstract base if (!class_exists('acm_memory')) { - require("${phpbb_root_path}includes/acm/acm_memory.$phpEx"); + require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx"); } /** @@ -30,12 +30,6 @@ class acm extends acm_memory { var $extension = 'xcache'; - function acm() - { - // Call the parent constructor - parent::acm_memory(); - } - /** * Purge cache data * @@ -62,7 +56,9 @@ class acm extends acm_memory */ function _read($var) { - return xcache_get($this->key_prefix . $var); + $result = xcache_get($this->key_prefix . $var); + + return ($result !== null) ? $result : false; } /** @@ -100,7 +96,6 @@ class acm extends acm_memory */ function _isset($var) { - // Most caches don't need to check return xcache_isset($this->key_prefix . $var); } } -- cgit v1.2.1 From e63b76b22af4ef2d67abb4799a225e0ce38787cf Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 6 Jun 2009 22:07:59 +0000 Subject: copy of Zend's base Exception file, needs to be updated manually :/ git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9551 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/Zend/Exception.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 phpBB/includes/Zend/Exception.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/Zend/Exception.php b/phpBB/includes/Zend/Exception.php new file mode 100644 index 0000000000..599d8a033e --- /dev/null +++ b/phpBB/includes/Zend/Exception.php @@ -0,0 +1,30 @@ + Date: Sat, 6 Jun 2009 23:20:10 +0000 Subject: - Class loaders for both frameworks: eZComponents through a loader object Zend Framework with an autoload function Example usage: require("{$phpbb_root_path}includes/ezcomponents/loader.$phpEx"); require("{$phpbb_root_path}includes/Zend/loader.$phpEx"); $loader = new phpbb_ezcomponents_loader(); $loader->load_component('search'); $handler = new ezcSearchZendLuceneHandler( '/tmp/lucene' ); git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9552 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/Zend/loader.php | 58 +++++++++++++++++++++++++++ phpBB/includes/ezcomponents/loader.php | 73 ++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 phpBB/includes/Zend/loader.php create mode 100644 phpBB/includes/ezcomponents/loader.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/Zend/loader.php b/phpBB/includes/Zend/loader.php new file mode 100644 index 0000000000..99a5543901 --- /dev/null +++ b/phpBB/includes/Zend/loader.php @@ -0,0 +1,58 @@ += 5.2.4 and spl_autoload_register() required', E_USER_ERROR); +} + +/** +* Autoload function for Zend framework classes +*/ +function phpbb_zend_autoload($class_name) +{ + global $phpbb_root_path; + + if (strpos($class_name, '_') !== false) + { + $path = str_replace('_', '/', $class_name) . '.php'; + require("{$phpbb_root_path}includes/" . $path); + return true; + } +} + +/** +* @ignore +*/ +// make sure Zend is in the include path +ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . $phpbb_root_path . 'includes' ); + +// check whether a regular autoload function already exists, so we can load it into the spl stack afterwards +$register_autoload = false; +if (function_exists('__autoload')) +{ + $register_autoload = true; +} + +spl_autoload_register('phpbb_zend_autoload'); + +// load the old autoload function into the spl stack if necessary +if ($register_autoload) +{ + spl_autoload_register('__autoload'); +} \ No newline at end of file diff --git a/phpBB/includes/ezcomponents/loader.php b/phpBB/includes/ezcomponents/loader.php new file mode 100644 index 0000000000..62aaa7667d --- /dev/null +++ b/phpBB/includes/ezcomponents/loader.php @@ -0,0 +1,73 @@ +loaded = array(); + if (version_compare(PHP_VERSION, '5.2.1', '<')) + { + trigger_error('PHP >= 5.2.1 required', E_USER_ERROR); + } + } + + /** + * Loads all classes of a particular component. + * The base component is always loaded first. + * + * @param $component string Lower case component name + */ + function load_component($component) + { + global $phpbb_root_path; + + // don't allow loading the same component twice + if (isset($this->loaded[$component]) && $this->loaded[$component]) + { + return; + } + + // make sure base is always loaded first + if ($component != 'base' && !isset($this->loaded['base'])) + { + $this->load_component('base'); + } + + $ezc_path = $phpbb_root_path . 'includes/ezcomponents/'; + + // retrieve the autoload list + $classes = include($ezc_path . ucfirst($component) . '/' . $component . '_autoload.php'); + + // include all files related to this component + foreach ($classes as $class => $path) + { + include($ezc_path . $path); + } + } +} \ No newline at end of file -- cgit v1.2.1 From a539fca62b10f53a5f5dadf07f9ab07340fdabf9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 7 Jun 2009 11:34:01 +0000 Subject: some corrections, only very minor things. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9554 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_memcache.php | 10 +- phpBB/includes/acm/acm_memory.php | 4 +- phpBB/includes/acm/acm_null.php | 7 - phpBB/includes/acp/acp_captcha.php | 29 ++--- phpBB/includes/auth/auth_db.php | 10 +- phpBB/includes/captcha/captcha_factory.php | 25 ++-- phpBB/includes/captcha/captcha_gd_wave.php | 45 ++++--- .../includes/captcha/plugins/captcha_abstract.php | 139 ++++++++++---------- .../captcha/plugins/phpbb_captcha_gd_plugin.php | 16 ++- .../plugins/phpbb_captcha_gd_wave_plugin.php | 5 +- .../captcha/plugins/phpbb_captcha_nogd_plugin.php | 21 +-- .../captcha/plugins/phpbb_recaptcha_plugin.php | 142 +++++++++++---------- phpBB/includes/functions.php | 24 ++-- phpBB/includes/functions_user.php | 4 +- phpBB/includes/session.php | 3 +- phpBB/includes/ucp/ucp_register.php | 23 ++-- 16 files changed, 257 insertions(+), 250 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 5a34a2a51d..3077ee9615 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -32,6 +32,11 @@ if (!defined('PHPBB_ACM_MEMCACHE_COMPRESS')) define('PHPBB_ACM_MEMCACHE_COMPRESS', false); } +if (!defined('PHPBB_ACM_MEMCACHE_HOST')) +{ + define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); +} + /** * ACM for Memcached * @package acm @@ -48,11 +53,6 @@ class acm extends acm_memory // Call the parent constructor parent::acm_memory(); - if (!defined('PHPBB_ACM_MEMCACHE_HOST')) - { - trigger_error('Missing required constant [PHPBB_ACM_MEMCACHE_HOST] for memcache ACM module.', E_USER_ERROR); - } - $this->memcache = new Memcache; $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index c7b5d34a47..fd9b9ff342 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -156,7 +156,7 @@ class acm_memory while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) { continue; } @@ -415,7 +415,7 @@ class acm_memory * @access protected * @param string $var Cache key * @return bool True if it exists, otherwise false - */ + */ function _isset($var) { // Most caches don't need to check diff --git a/phpBB/includes/acm/acm_null.php b/phpBB/includes/acm/acm_null.php index c2363b9ddf..fca67115a7 100644 --- a/phpBB/includes/acm/acm_null.php +++ b/phpBB/includes/acm/acm_null.php @@ -27,7 +27,6 @@ class acm */ function acm() { - } /** @@ -43,7 +42,6 @@ class acm */ function unload() { - } /** @@ -51,7 +49,6 @@ class acm */ function save() { - } /** @@ -76,7 +73,6 @@ class acm */ function put($var_name, $var, $ttl = 0) { - } /** @@ -84,7 +80,6 @@ class acm */ function purge() { - } /** @@ -92,7 +87,6 @@ class acm */ function destroy($var_name, $table = '') { - } /** @@ -116,7 +110,6 @@ class acm */ function sql_save($query, &$query_result, $ttl) { - } /** diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index ed2ccf6ccc..7c7a5acc9f 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -10,8 +10,6 @@ /** * @ignore */ - - if (!defined('IN_PHPBB')) { exit; @@ -35,13 +33,13 @@ class acp_captcha $selected = request_var('select_captcha', $config['captcha_plugin']); $configure = request_var('configure', false); - + // Oh, they are just here for the view if (isset($_GET['captcha_demo'])) { $this->deliver_demo($selected); } - + // Delegate if ($configure) { @@ -52,6 +50,7 @@ class acp_captcha else { $captchas = phpbb_captcha_factory::get_captcha_types(); + $config_vars = array( 'enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', @@ -68,10 +67,12 @@ class acp_captcha if ($submit && check_form_key($form_key)) { $config_vars = array_keys($config_vars); + foreach ($config_vars as $config_var) { set_config($config_var, request_var($config_var, false)); } + if ($selected !== $config['captcha_plugin']) { // sanity check @@ -79,9 +80,11 @@ class acp_captcha { $old_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $old_captcha->uninstall(); + set_config('captcha_plugin', $selected); $new_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $old_captcha->install(); + $new_captcha->install(); + add_log('admin', 'LOG_CONFIG_VISUAL'); } else @@ -103,14 +106,15 @@ class acp_captcha $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; $captcha_select .= ''; } + foreach ($captchas['unavailable'] as $value => $title) { $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; - $captcha_select .= ''; + $captcha_select .= ''; } $demo_captcha = phpbb_captcha_factory::get_instance($selected); - + foreach ($config_vars as $config_var => $template_var) { $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; @@ -121,28 +125,23 @@ class acp_captcha 'CAPTCHA_SELECT' => $captcha_select, )); } - } } - - + /** * Entry point for delivering image CAPTCHAs in the ACP. */ function deliver_demo($selected) { global $db, $user, $config; - + $captcha = phpbb_captcha_factory::get_instance($selected); $captcha->init(CONFIRM_REG); $captcha->execute_demo(); + garbage_collection(); exit_handler(); } - - - - } ?> \ No newline at end of file diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index bdafefa70b..f798264ada 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -68,7 +68,6 @@ function login_db(&$username, &$password) if ($config['max_login_attempts'] && $row['user_login_attempts'] >= $config['max_login_attempts']) { $confirm_id = request_var('confirm_id', ''); - $confirm_code = request_var('confirm_code', ''); // Visual Confirmation handling if (!$confirm_id) @@ -84,12 +83,13 @@ function login_db(&$username, &$password) $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); $vc_response = $captcha->validate(); + if ($vc_response) { return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', - 'user_row' => $row, + 'status' => LOGIN_ERROR_ATTEMPTS, + 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', + 'user_row' => $row, ); } } @@ -130,7 +130,7 @@ function login_db(&$username, &$password) $row['user_pass_convert'] = 0; $row['user_password'] = $hash; } - else + else { // Although we weren't able to convert this password we have to // increase login attempt count to make sure this cannot be exploited diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index fbe615a043..b5fa69990d 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -16,8 +16,11 @@ if (!defined('IN_PHPBB')) exit; } - -/** A small class until we get the autoloader done */ +/** +* A small class for 3.0.x (no autoloader in 3.0.x) +* +* @package VC +*/ class phpbb_captcha_factory { /** @@ -26,7 +29,7 @@ class phpbb_captcha_factory function get_instance($name) { global $phpbb_root_path, $phpEx; - + $name = basename($name); if (!class_exists($name)) { @@ -34,7 +37,7 @@ class phpbb_captcha_factory } return call_user_func(array($name, 'get_instance')); } - + /** * Call the garbage collector */ @@ -49,18 +52,19 @@ class phpbb_captcha_factory } call_user_func(array($name, 'garbage_collect'), 0); } - + /** * return a list of all discovered CAPTCHA plugins */ function get_captcha_types() { global $phpbb_root_path, $phpEx; - - $captchas = array(); - $captchas['available'] = array(); - $captchas['unavailable'] = array(); - + + $captchas = array( + 'available' => array(), + 'unavailable' => array(), + ); + $dp = @opendir($phpbb_root_path . 'includes/captcha/plugins'); if ($dp) @@ -74,6 +78,7 @@ class phpbb_captcha_factory { include($phpbb_root_path . "includes/captcha/plugins/$file"); } + if (call_user_func(array($name, 'is_available'))) { $captchas['available'][$name] = call_user_func(array($name, 'get_name')); diff --git a/phpBB/includes/captcha/captcha_gd_wave.php b/phpBB/includes/captcha/captcha_gd_wave.php index d911d574f7..f706c98d43 100644 --- a/phpBB/includes/captcha/captcha_gd_wave.php +++ b/phpBB/includes/captcha/captcha_gd_wave.php @@ -1,16 +1,18 @@ width; $img_y = $this->height; @@ -32,7 +34,7 @@ class captcha $img = imagecreatetruecolor($img_x, $img_y); $x_grid = mt_rand(6, 10); $y_grid = mt_rand(6, 10); - + // Ok, so lets cut to the chase. We could accurately represent this in 3d and // do all the appropriate linear transforms. my questions is... why bother? // The computational overhead is unnecessary when you consider the simple fact: @@ -47,28 +49,29 @@ class captcha $plane_x = 100; $plane_y = 30; - $subdivision_factor = 3; + $subdivision_factor = 3; + // $box is the 4 points in img_space that correspond to the corners of the plane in 3-space $box = array( 'upper_left' => array( 'x' => mt_rand(5, 15), 'y' => mt_rand(10, 15) - ), + ), 'upper_right' => array( 'x' => mt_rand($img_x - 35, $img_x - 19), 'y' => mt_rand(10, 17) - ), + ), 'lower_left' => array( 'x' => mt_rand($img_x - 5, $img_x - 45), 'y' => mt_rand($img_y - 0, $img_y - 15) - ), + ), ); + $box['lower_right'] = array( - 'x' => $box['lower_left']['x'] + $box['upper_left']['x'] - $box['upper_right']['x'], - 'y' => $box['lower_left']['y'] + $box['upper_left']['y'] - $box['upper_right']['y'], + 'x' => $box['lower_left']['x'] + $box['upper_left']['x'] - $box['upper_right']['x'], + 'y' => $box['lower_left']['y'] + $box['upper_left']['y'] - $box['upper_right']['y'], ); - // TODO $background = imagecolorallocate($img, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255)); imagefill($img, 0, 0, $background); @@ -83,7 +86,7 @@ class captcha } $fontcolors[0] = imagecolorallocate($img, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120)); - + $colors = array(); $minr = mt_rand(20, 30); @@ -159,7 +162,7 @@ class captcha $cur_height = $this->wave_height($x, 0, $subdivision_factor); $offset = $cur_height - $prev_height; $img_pos_cur = array($img_pos_prev[0] + $dxx, $img_pos_prev[1] + $dxy + $offset); - + $img_buffer[0][$x] = $img_pos_cur; $img_pos_prev = $img_pos_cur; $prev_height = $cur_height; @@ -170,7 +173,7 @@ class captcha // swap buffers $buffer_cur = $y & 1; $buffer_prev = 1 - $buffer_cur; - + $prev_height = $this->wave_height(0, $y, $subdivision_factor); $offset = $prev_height - $this->wave_height(0, $y - 1, $subdivision_factor); $img_pos_cur = array($img_buffer[$buffer_prev][0][0] + $dyx, min($img_buffer[$buffer_prev][0][1] + $dyy + $offset, $img_y - 1)); @@ -179,7 +182,7 @@ class captcha $img_pos_prev = $img_pos_cur; $img_buffer[$buffer_cur][0] = $img_pos_cur; - + for ($x = 1; $x <= $full_x; ++$x) { $cur_height = $this->wave_height($x, $y, $subdivision_factor) + $this->grid_height($x, $y, 1, $x_grid, $y_grid); @@ -496,7 +499,7 @@ class captcha array(0,0,0,0,0,0,0,0,0), array(0,0,0,0,0,0,0,0,0), array(0,0,0,0,0,0,0,0,0), - ), + ), 'O' => array( array(0,0,0,1,1,1,0,0,0), array(0,0,1,0,0,0,1,0,0), diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index f88d82b2a0..0666a3ca67 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -18,7 +18,9 @@ if (!defined('IN_PHPBB')) /** -* This class holds the code shared by the two default 3.0 CAPTCHAs. +* This class holds the code shared by the two default 3.0.x CAPTCHAs. +* +* @package VC */ class phpbb_default_captcha { @@ -29,18 +31,17 @@ class phpbb_default_captcha var $type; var $solved = false; - function init($type) { global $config, $db, $user; - + // read input $this->confirm_id = request_var('confirm_id', ''); $this->confirm_code = request_var('confirm_code', ''); $refresh = request_var('refresh_vc', false) && $config['confirm_refresh']; - + $this->type = (int) $type; - + if (!strlen($this->confirm_id)) { // we have no confirm ID, better get ready to display something @@ -50,24 +51,22 @@ class phpbb_default_captcha { $this->regenerate_code(); } - } - + function execute_demo() { global $user; - - $this->code = gen_rand_string(mt_rand(5, 8)); + + $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); - + // compute $seed % 0x7fffffff $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); - + $captcha = new captcha(); $captcha->execute($this->code, $this->seed); } - - + function execute() { if (empty($this->code)) @@ -81,46 +80,46 @@ class phpbb_default_captcha $captcha = new captcha(); $captcha->execute($this->code, $this->seed); } - - + function get_template() { global $config, $user, $template, $phpEx, $phpbb_root_path; - + $template->set_filenames(array( 'captcha' => 'captcha_default.html') ); - + $template->assign_vars(array( 'CONFIRM_IMAGE' => append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type), - 'CONFIRM_ID' => $this->confirm_id, + 'CONFIRM_ID' => $this->confirm_id, 'S_REFRESH' => (bool) $config['confirm_refresh'], )); - + return $template->assign_display('captcha'); } - + function get_demo_template($id) { global $config, $user, $template, $phpbb_admin_path, $phpEx; - + $template->set_filenames(array( 'captcha_demo' => 'captcha_default_acp_demo.html') ); + // acp_captcha has a delivery function; let's use it $template->assign_vars(array( 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx . '?captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()), 'CONFIRM_ID' => $this->confirm_id, )); - + return $template->assign_display('captcha_demo'); } - + function get_hidden_fields() { $hidden_fields = array(); - + // this is required for postig.php - otherwise we would forget about the captcha being already solved if ($this->solved) { @@ -129,16 +128,16 @@ class phpbb_default_captcha $hidden_fields['confirm_id'] = $this->confirm_id; return $hidden_fields; } - + function garbage_collect($type) { global $db, $config; $sql = 'SELECT DISTINCT c.session_id - FROM ' . CONFIRM_TABLE . ' c - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) - WHERE s.session_id IS NULL' . - ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); + FROM ' . CONFIRM_TABLE . ' c + LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) + WHERE s.session_id IS NULL' . + ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) @@ -159,21 +158,21 @@ class phpbb_default_captcha } $db->sql_freeresult($result); } - + function uninstall() { - self::garbage_collect(0); + $this->garbage_collect(0); } - + function install() { return; } - + function validate() { global $config, $db, $user; - + $this->confirm_code = request_var('confirm_code', ''); if (!$this->confirm_id) { @@ -191,10 +190,10 @@ class phpbb_default_captcha $error = $user->lang['CONFIRM_CODE_WRONG']; } } - + if (strlen($error)) { - // okay, inorect answer. Let's ask a new question + // okay, incorrect answer. Let's ask a new question. $this->generate_code(); return $error; } @@ -203,16 +202,15 @@ class phpbb_default_captcha return false; } } - - + /** * The old way to generate code, suitable for GD and non-GD. Resets the internal state. */ function generate_code() { global $db, $user; - - $this->code = gen_rand_string(mt_rand(5, 8)); + + $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->confirm_id = md5(unique_id($user->ip)); $this->seed = hexdec(substr(unique_id(), 4, 10)); $this->solved = false; @@ -228,19 +226,20 @@ class phpbb_default_captcha ); $db->sql_query($sql); } - + /** * New Question, if desired. */ function regenerate_code() { global $db, $user; - - $this->code = gen_rand_string(mt_rand(5, 8)); + + $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); $this->solved = false; // compute $seed % 0x7fffffff $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); + $sql = 'UPDATE ' . CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( 'code' => (string) $this->code, 'seed' => (int) $this->seed)) . ' @@ -249,35 +248,37 @@ class phpbb_default_captcha session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } - + /** - * Look up everything we need for painting&checking. + * Look up everything we need for painting&checking. */ function load_code() { global $db, $user; + $sql = 'SELECT code, seed - FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; + FROM ' . CONFIRM_TABLE . " + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); + if ($row) { $this->code = $row['code']; $this->seed = $row['seed']; return true; } + return false; - } - + function check_code() { global $db; - + if (empty($this->code)) { if (!$this->load_code()) @@ -287,47 +288,45 @@ class phpbb_default_captcha } return (strcasecmp($this->code, $this->confirm_code) === 0); } - + function delete_code() { global $db, $user; - + $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; + WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; $db->sql_query($sql); } - + function get_attempt_count() { global $db, $user; - + $sql = 'SELECT COUNT(session_id) AS attempts - FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; + FROM ' . CONFIRM_TABLE . " + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; $result = $db->sql_query($sql); $attempts = (int) $db->sql_fetchfield('attempts'); $db->sql_freeresult($result); - + return $attempts; } - - + function reset() { global $db, $user; - + $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . (int) $this->type; + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . (int) $this->type; $db->sql_query($sql); - + // we leave the class usable by generating a new question $this->generate_code(); } - } ?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index 5b3c09f32d..ac78b3d1c4 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -16,7 +16,7 @@ if (!defined('IN_PHPBB')) exit; } -/** +/** * Placeholder for autoload */ if (!class_exists('phpbb_default_captcha')) @@ -24,6 +24,9 @@ if (!class_exists('phpbb_default_captcha')) include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } +/** +* @package VC +*/ class phpbb_captcha_gd extends phpbb_default_captcha { function phpbb_captcha_gd() @@ -35,7 +38,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); } } - + function get_instance() { return new phpbb_captcha_gd(); @@ -45,17 +48,17 @@ class phpbb_captcha_gd extends phpbb_default_captcha { return (@extension_loaded('gd') || can_load_dll('gd')); } - + function get_name() { return 'CAPTCHA_GD'; } - + function get_class_name() { return 'phpbb_captcha_gd'; } - + function acp_page($id, &$module) { global $db, $user, $auth, $template; @@ -80,7 +83,6 @@ class phpbb_captcha_gd extends phpbb_default_captcha 'captcha_gd' => 'CAPTCHA_GD', ); - $module->tpl_name = 'captcha_gd_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; @@ -112,11 +114,11 @@ class phpbb_captcha_gd extends phpbb_default_captcha $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); } + $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), )); - } } } diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index 38e5aabedd..36cbaf7d79 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -24,6 +24,9 @@ if (!class_exists('captcha_abstract')) include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } +/** +* @package VC +*/ class phpbb_captcha_gd_wave extends phpbb_default_captcha { @@ -60,7 +63,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha function acp_page($id, &$module) { global $config, $db, $template, $user; - + trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action)); } } diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php index 8df11bfe8a..517b55f09e 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -16,7 +16,7 @@ if (!defined('IN_PHPBB')) exit; } -/** +/** * Placeholder for autoload */ if (!class_exists('phpbb_default_captcha')) @@ -24,6 +24,9 @@ if (!class_exists('phpbb_default_captcha')) include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } +/** +* @package VC +*/ class phpbb_captcha_nogd extends phpbb_default_captcha { @@ -36,7 +39,7 @@ class phpbb_captcha_nogd extends phpbb_default_captcha include_once($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); } } - + function get_instance() { return new phpbb_captcha_nogd(); @@ -46,25 +49,23 @@ class phpbb_captcha_nogd extends phpbb_default_captcha { return true; } - + function get_name() { - global $user; - - return 'CAPTCHA_NO_GD'; + return 'CAPTCHA_NO_GD'; } - + function get_class_name() { return 'phpbb_captcha_nogd'; } - - + function acp_page($id, &$module) { global $user; - + trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action)); } } +?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 42ca25ae54..a96f5ef9c6 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -22,6 +22,9 @@ if (!class_exists('phpbb_default_captcha')) include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } +/** +* @package VC +*/ class phpbb_recaptcha extends phpbb_default_captcha { var $recaptcha_server = 'http://api.recaptcha.net'; @@ -29,18 +32,16 @@ class phpbb_recaptcha extends phpbb_default_captcha var $challenge; var $response; - function init($type) { global $config, $db, $user; - + $user->add_lang('recaptcha'); parent::init($type); $this->challenge = request_var('recaptcha_challenge_field', ''); $this->response = request_var('recaptcha_response_field', ''); } - - + function get_instance() { return new phpbb_recaptcha(); @@ -48,25 +49,25 @@ class phpbb_recaptcha extends phpbb_default_captcha function is_available() { - global $config, $user; + global $config, $user; $user->add_lang('recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } - + function get_name() { return 'CAPTCHA_RECAPTCHA'; } - + function get_class_name() { return 'phpbb_recaptcha'; } - + function acp_page($id, &$module) { global $config, $db, $template, $user; - + $captcha_vars = array( 'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', 'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY', @@ -103,6 +104,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); $template->assign_var($template_var, $var); } + $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), @@ -110,47 +112,44 @@ class phpbb_recaptcha extends phpbb_default_captcha } } - - + // not needed function execute_demo() { } - - + // not needed function execute() { } - - + function get_template() { global $config, $user, $template; - + $template->set_filenames(array( 'captcha' => 'captcha_recaptcha.html') ); - + $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', 'RECAPTCHA_ERRORGET' => '', 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), )); - + return $template->assign_display('captcha'); } - + function get_demo_template($id) { return $this->get_template(); } - + function get_hidden_fields() { $hidden_fields = array(); - + // this is required for postig.php - otherwise we would forget about the captcha being already solved if ($this->solved) { @@ -159,17 +158,17 @@ class phpbb_recaptcha extends phpbb_default_captcha $hidden_fields['confirm_id'] = $this->confirm_id; return $hidden_fields; } - + function uninstall() { - self::garbage_collect(0); + $this->garbage_collect(0); } - + function install() { return; } - + function validate() { if (!parent::validate()) @@ -181,7 +180,6 @@ class phpbb_recaptcha extends phpbb_default_captcha return $this->recaptcha_check_answer(); } } - // Code from here on is based on recaptchalib.php /* @@ -218,14 +216,14 @@ class phpbb_recaptcha extends phpbb_default_captcha */ /** - * Submits an HTTP POST to a reCAPTCHA server - * @param string $host - * @param string $path - * @param array $data - * @param int port - * @return array response - */ - function _recaptcha_http_post($host, $path, $data, $port = 80) + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ + function _recaptcha_http_post($host, $path, $data, $port = 80) { $req = $this->_recaptcha_qsencode ($data); @@ -238,52 +236,56 @@ class phpbb_recaptcha extends phpbb_default_captcha $http_request .= $req; $response = ''; - if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { - die ('Could not open socket'); + if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) + { + trigger_error('Could not open socket', E_USER_ERROR); } fwrite($fs, $http_request); - while ( !feof($fs) ) - $response .= fgets($fs, 1160); // One TCP-IP packet + while (!feof($fs)) + { + // One TCP-IP packet + $response .= fgets($fs, 1160); + } fclose($fs); $response = explode("\r\n\r\n", $response, 2); return $response; } - /** - * Calls an HTTP POST function to verify if the user's guess was correct - * @param array $extra_params an array of extra variables to post to the server - * @return ReCaptchaResponse - */ - function recaptcha_check_answer ($extra_params = array()) + * Calls an HTTP POST function to verify if the user's guess was correct + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ + function recaptcha_check_answer($extra_params = array()) { global $config, $user; + //discard spam submissions - if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) + if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0) { - return $user->lang['RECAPTCHA_INCORRECT']; + return $user->lang['RECAPTCHA_INCORRECT']; } - $response = $this->_recaptcha_http_post ($this->recaptcha_verify_server, "/verify", - array ( - 'privatekey' => $config['recaptcha_privkey'], - 'remoteip' => $user->ip, - 'challenge' => $this->challenge, - 'response' => $this->response - ) + $extra_params - ); - - $answers = explode ("\n", $response[1]); - - if (trim ($answers[0]) === 'true') + $response = $this->_recaptcha_http_post($this->recaptcha_verify_server, '/verify', + array( + 'privatekey' => $config['recaptcha_privkey'], + 'remoteip' => $user->ip, + 'challenge' => $this->challenge, + 'response' => $this->response + ) + $extra_params + ); + + $answers = explode("\n", $response[1]); + + if (trim($answers[0]) === 'true') { $this->solved = true; return false; } - else + else { if ($answers[1] === 'incorrect-captcha-sol') { @@ -291,22 +293,24 @@ class phpbb_recaptcha extends phpbb_default_captcha } } } - - /** - * Encodes the given data into a query string format - * @param $data - array of string elements to be encoded - * @return string - encoded request - */ - function _recaptcha_qsencode ($data) + + /** + * Encodes the given data into a query string format + * @param $data - array of string elements to be encoded + * @return string - encoded request + */ + function _recaptcha_qsencode($data) { $req = ''; - foreach ( $data as $key => $value ) + foreach ($data as $key => $value) { - $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; } + // Cut the last '&' - $req=substr($req,0,strlen($req)-1); + $req = substr($req, 0, strlen($req) - 1); return $req; } } +?> \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 78905beff6..f958a204b6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -670,17 +670,17 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) } /** - * Test if a file/directory is writable - * - * This function calls the native is_writable() when not running under - * Windows and it is not disabled. - * - * @param string $file Path to perform write test on - * @return bool True when the path is writable, otherwise false. - */ +* Test if a file/directory is writable +* +* This function calls the native is_writable() when not running under +* Windows and it is not disabled. +* +* @param string $file Path to perform write test on +* @return bool True when the path is writable, otherwise false. +*/ function phpbb_is_writable($file) { - if (substr(PHP_OS, 0, 3) === 'WIN' || !function_exists('is_writable')) + if (strtolower(substr(PHP_OS, 0, 3)) === 'win' || !function_exists('is_writable')) { if (file_exists($file)) { @@ -714,7 +714,6 @@ function phpbb_is_writable($file) else { // file does not exist test if we can write to the directory - $dir = dirname($file); if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir)) @@ -722,6 +721,7 @@ function phpbb_is_writable($file) return true; } } + return false; } else @@ -2585,7 +2585,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); } - + $err = ''; // Make sure user->setup() has been called @@ -2700,14 +2700,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha->init(CONFIRM_LOGIN); $captcha->reset(); - $template->assign_vars(array( 'S_CONFIRM_CODE' => true, 'CONFIRM' => $captcha->get_template(''), )); $err = $user->lang[$result['error_msg']]; - break; case LOGIN_ERROR_PASSWORD_CONVERT: diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index ee9867b1f1..0345f039a3 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2077,8 +2077,8 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $sub_file)) { $avatar_list[$file][$avatar_row_count][$avatar_col_count] = array( - 'file' => rawurlencode ($file) . '/' . rawurlencode ($sub_file), - 'filename' => rawurlencode ($sub_file), + 'file' => rawurlencode($file) . '/' . rawurlencode($sub_file), + 'filename' => rawurlencode($sub_file), 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))), ); $avatar_col_count++; diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index e039fce6e1..8c6606d680 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -949,7 +949,7 @@ class session WHERE last_login < ' . (time() - (86400 * (int) $config['max_autologin_time'])); $db->sql_query($sql); } - + // only called from CRON; should be a safe workaround until the infrastructure gets going if (!class_exists('captcha_factory')) { @@ -961,7 +961,6 @@ class session return; } - /** * Sets a cookie * diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 958369a03e..06606f602f 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -42,7 +42,8 @@ class ucp_register $submit = (isset($_POST['submit'])) ? true : false; $change_lang = request_var('change_lang', ''); $user_lang = request_var('lang', $user->lang_name); - $confirm_refresh = (isset($_POST['confirm_refresh']) && $config['confirm_refresh']) ? ((!empty($_POST['confirm_refresh'])) ? 1 : 0) : false; + $confirm_refresh= (isset($_POST['confirm_refresh']) && $config['confirm_refresh']) ? ((!empty($_POST['confirm_refresh'])) ? 1 : 0) : false; + if ($agreed) { add_form_key('ucp_register'); @@ -52,14 +53,13 @@ class ucp_register add_form_key('ucp_register_terms'); } - if ($config['enable_confirm']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REG); } - + if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); @@ -94,7 +94,7 @@ class ucp_register { $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; - + $s_hidden_fields = array(); // If we change the language, we want to pass on some more possible parameter. @@ -108,7 +108,7 @@ class ucp_register 'lang' => $user->lang_name, 'tz' => request_var('tz', (float) $config['board_timezone']), )); - + if ($config['enable_confirm']) { $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); @@ -198,10 +198,12 @@ class ucp_register 'tz' => array('num', false, -14, 14), 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), )); + if (!check_form_key('ucp_register')) { $error[] = $user->lang['FORM_INVALID']; } + // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); @@ -216,11 +218,13 @@ class ucp_register { $captcha->reset(); } + if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) { $error[] = $user->lang['TOO_MANY_REGISTERS']; } } + // DNSBL check if ($config['check_dnsbl']) { @@ -424,7 +428,6 @@ class ucp_register $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm']) { if ($change_lang || $confirm_refresh) @@ -434,13 +437,12 @@ class ucp_register else { $str = ''; - } + $template->assign_vars(array( 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), 'S_CAPTCHA' => $captcha->get_template(), )); - } // @@ -455,7 +457,7 @@ class ucp_register $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; break; } - + $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'USERNAME' => $data['username'], @@ -474,8 +476,7 @@ class ucp_register 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - ) - ); + )); // $user->profile_fields = array(); -- cgit v1.2.1 From 0c19784ab9e5dae7828b3ebca619ec9fd1c301a7 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 7 Jun 2009 18:09:51 +0000 Subject: for the time being pushed to 3.2.x git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9560 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/Zend/Exception.php | 30 -------------- phpBB/includes/Zend/loader.php | 58 --------------------------- phpBB/includes/ezcomponents/loader.php | 73 ---------------------------------- 3 files changed, 161 deletions(-) delete mode 100644 phpBB/includes/Zend/Exception.php delete mode 100644 phpBB/includes/Zend/loader.php delete mode 100644 phpBB/includes/ezcomponents/loader.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/Zend/Exception.php b/phpBB/includes/Zend/Exception.php deleted file mode 100644 index 599d8a033e..0000000000 --- a/phpBB/includes/Zend/Exception.php +++ /dev/null @@ -1,30 +0,0 @@ -= 5.2.4 and spl_autoload_register() required', E_USER_ERROR); -} - -/** -* Autoload function for Zend framework classes -*/ -function phpbb_zend_autoload($class_name) -{ - global $phpbb_root_path; - - if (strpos($class_name, '_') !== false) - { - $path = str_replace('_', '/', $class_name) . '.php'; - require("{$phpbb_root_path}includes/" . $path); - return true; - } -} - -/** -* @ignore -*/ -// make sure Zend is in the include path -ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . $phpbb_root_path . 'includes' ); - -// check whether a regular autoload function already exists, so we can load it into the spl stack afterwards -$register_autoload = false; -if (function_exists('__autoload')) -{ - $register_autoload = true; -} - -spl_autoload_register('phpbb_zend_autoload'); - -// load the old autoload function into the spl stack if necessary -if ($register_autoload) -{ - spl_autoload_register('__autoload'); -} \ No newline at end of file diff --git a/phpBB/includes/ezcomponents/loader.php b/phpBB/includes/ezcomponents/loader.php deleted file mode 100644 index 62aaa7667d..0000000000 --- a/phpBB/includes/ezcomponents/loader.php +++ /dev/null @@ -1,73 +0,0 @@ -loaded = array(); - if (version_compare(PHP_VERSION, '5.2.1', '<')) - { - trigger_error('PHP >= 5.2.1 required', E_USER_ERROR); - } - } - - /** - * Loads all classes of a particular component. - * The base component is always loaded first. - * - * @param $component string Lower case component name - */ - function load_component($component) - { - global $phpbb_root_path; - - // don't allow loading the same component twice - if (isset($this->loaded[$component]) && $this->loaded[$component]) - { - return; - } - - // make sure base is always loaded first - if ($component != 'base' && !isset($this->loaded['base'])) - { - $this->load_component('base'); - } - - $ezc_path = $phpbb_root_path . 'includes/ezcomponents/'; - - // retrieve the autoload list - $classes = include($ezc_path . ucfirst($component) . '/' . $component . '_autoload.php'); - - // include all files related to this component - foreach ($classes as $class => $path) - { - include($ezc_path . $path); - } - } -} \ No newline at end of file -- cgit v1.2.1 From 0c57363fbc8769ef3e0774a9a03878553540bf9a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 8 Jun 2009 10:05:44 +0000 Subject: Fix bug #46065 - Correctly show private message history Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9561 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 05653f7e3b..96400ad70d 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1827,7 +1827,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '') ); - unset($rowset[$id]); + unset($rowset[$i]); $prev_id = $id; } -- cgit v1.2.1 From 2af8393d0f5fa08b95df989ab879ce1b7d4cab21 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 8 Jun 2009 22:33:30 +0000 Subject: Fix bug #45705 - Show error in the ACP when template folder is not readable. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9565 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_attachments.php | 2 +- phpBB/includes/acp/acp_styles.php | 5 +++++ phpBB/includes/functions_admin.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index ef20b48cec..de4092036e 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -694,7 +694,7 @@ class acp_attachments $imglist = filelist($phpbb_root_path . $img_path); - if (sizeof($imglist)) + if (!empty($imglist[''])) { $imglist = array_values($imglist); $imglist = $imglist[0]; diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 184c40f218..48802c79df 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -827,6 +827,11 @@ parse_css_file = {PARSE_CSS_FILE} unset($file_info); } + if (empty($filelist[''])) + { + trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); + } + // Now create the categories $filelist_cats[''] = array(); foreach ($filelist as $pathfile => $file_ary) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 79282c0358..a1f34792e0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -359,7 +359,7 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl */ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') { - $matches = array(); + $matches = array($dir => array()); // Remove initial / if present $rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir; -- cgit v1.2.1 From 41a2f0fb03a433ad98d0c96acdd7215f1b94da60 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 10 Jun 2009 12:28:41 +0000 Subject: language collision git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9568 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index 36cbaf7d79..4198dcdf5b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -52,7 +52,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha function get_name() { - return 'CAPTCHA_GD_WAVE'; + return 'CAPTCHA_GD_3D'; } function get_class_name() -- cgit v1.2.1 From 92b6e5400ea1024f3463866be70244eb1fe79a82 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 11 Jun 2009 13:12:04 +0000 Subject: Fix bug #45345 - Also remove data from friend/foe table when deleting user (patch by nickvergessen). Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9569 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0345f039a3..48fb532d00 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -501,6 +501,12 @@ function user_delete($mode, $user_id, $post_username = false) $cache->destroy('sql', MODERATOR_CACHE_TABLE); + // Delete the user_id from the zebra table + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $user_id . ' + OR zebra_id = ' . $user_id; + $db->sql_query($sql); + // Delete the user_id from the banlist $sql = 'DELETE FROM ' . BANLIST_TABLE . ' WHERE ban_userid = ' . $user_id; -- cgit v1.2.1 From 76cffeff0a043c3bd7d610c376e81c00899265dd Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 11 Jun 2009 16:53:45 +0000 Subject: Dynamic template includes :) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9570 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 43 ++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 42a5eb3248..d9d9abfe46 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -128,9 +128,9 @@ class template_compile $php_blocks = $matches[1]; $code = preg_replace('#.*?#s', '', $code); - preg_match_all('##', $code, $matches); + preg_match_all('##', $code, $matches); $include_blocks = $matches[1]; - $code = preg_replace('##', '', $code); + $code = preg_replace('##', '', $code); preg_match_all('##', $code, $matches); $includephp_blocks = $matches[1]; @@ -193,8 +193,39 @@ class template_compile case 'INCLUDE': $temp = array_shift($include_blocks); + + // Dynamic includes + // Cheap match rather than a full blown regexp, we already know + // the format of the input so just use string manipulation. + if ($temp[0] == '{') + { + $file = false; + + if ($temp[1] == '$') + { + $var = substr($temp, 2, -1); + //$file = $this->template->_tpldata['DEFINE']['.'][$var]; + $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; + } + else + { + $var = substr($temp, 1, -1); + //$file = $this->template->_rootref[$var]; + $temp = "\$this->_rootref['$var']"; + } + } + else + { + $file = $temp; + } + $compile_blocks[] = 'compile_tag_include($temp) . ' ?>'; - $this->template->_tpl_include($temp, false); + + // No point in checking variable includes + if ($file) + { + $this->template->_tpl_include($file, false); + } break; case 'INCLUDEPHP': @@ -594,6 +625,12 @@ class template_compile */ function compile_tag_include($tag_args) { + // Process dynamic includes + if ($tag_args[0] == '$') + { + return "if (isset($tag_args)) { \$this->_tpl_include($tag_args); }"; + } + return "\$this->_tpl_include('$tag_args');"; } -- cgit v1.2.1 From e71bae0e7ad7817e06fb786c3420a1a2158df8cc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Jun 2009 13:56:40 +0000 Subject: Fix dynamic config update routine error if firebird is used (Bug #46315) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9574 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f958a204b6..188c8ee5e3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -174,7 +174,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false) switch ($db->sql_layer) { case 'firebird': - $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)'; + $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))'; break; case 'postgres': -- cgit v1.2.1 From 863d7a7614a09dac545d3c3201e67c3beddb3960 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Jun 2009 14:41:03 +0000 Subject: First ATOM Feed commit/integration - Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9575 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 105 +++++++++++++++++++++++++++++++++- phpBB/includes/acp/info/acp_board.php | 1 + phpBB/includes/functions.php | 13 +++++ 3 files changed, 116 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index bce35ee68f..1b812a9c8f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -64,6 +64,8 @@ class acp_board 'legend2' => 'WARNINGS', 'warnings_expire_days' => array('lang' => 'WARNINGS_EXPIRE', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -93,6 +95,8 @@ class acp_board 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -143,7 +147,9 @@ class acp_board 'forward_pm' => array('lang' => 'ALLOW_FORWARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'auth_img_pm' => array('lang' => 'ALLOW_IMG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'auth_flash_pm' => array('lang' => 'ALLOW_FLASH_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false) + 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -182,6 +188,8 @@ class acp_board 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true), 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -205,6 +213,8 @@ class acp_board 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true), 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -235,6 +245,28 @@ class acp_board 'coppa_enable' => array('lang' => 'ENABLE_COPPA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'coppa_mail' => array('lang' => 'COPPA_MAIL', 'validate' => 'string', 'type' => 'textarea:5:40', 'explain' => true), 'coppa_fax' => array('lang' => 'COPPA_FAX', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => false), + + 'legend4' => 'ACP_SUBMIT_CHANGES', + ) + ); + break; + + case 'feed': + $display_vars = array( + 'title' => 'ACP_FEED_MANAGEMENT', + 'vars' => array( + 'legend1' => 'ACP_FEED_GENERAL', + 'feed_enable' => array('lang' => 'ACP_FEED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), + 'feed_item_statistics' => array('lang' => 'ACP_FEED_ITEM_STATISTICS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), + 'feed_limit' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => true), + 'feed_overall_forums' => array('lang' => 'ACP_FEED_OVERALL_FORUMS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), + 'feed_overall_forums_limit' => array('lang' => 'ACP_FEED_OVERALL_FORUMS_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => false), + 'feed_overall_topics' => array('lang' => 'ACP_FEED_OVERALL_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), + 'feed_overall_topics_limit' => array('lang' => 'ACP_FEED_OVERALL_TOPIC_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => false), + 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), + 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), + 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_news_forums', 'explain' => true ), + 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_exclude_forums', 'explain' => true), ) ); break; @@ -279,6 +311,8 @@ class acp_board 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + + 'legend4' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -312,6 +346,8 @@ class acp_board 'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true), 'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true), + + 'legend4' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -360,7 +396,9 @@ class acp_board 'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0', 'type' => 'text:4:5', 'explain' => true), 'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true), 'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true), - 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true) + 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true), + + 'legend3' => 'ACP_SUBMIT_CHANGES', ) ); break; @@ -395,7 +433,7 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + if ($null === false || strpos($config_name, 'legend') !== false) { continue; } @@ -405,6 +443,26 @@ class acp_board continue; } + // If not set, then this is a valid entry and needs to be emptied (select_multiple, checkbox) + if (!isset($cfg_array[$config_name])) + { + $cfg_array[$config_name] = ''; + } + + + // Erm, we spotted an array + if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) + { + // Get config *array* + $cfg_ = utf8_normalize_nfc(request_var('config', array('' => array('')), true)); + + // Check if the variable is set and an array + if (isset($cfg_[$config_name]) && is_array($cfg_[$config_name])) + { + $cfg_array[$config_name] = trim(serialize($cfg_[$config_name])); + } + } + $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($config_name == 'email_function_name') @@ -830,6 +888,47 @@ class acp_board return " "; } + + /** + * Select multiple forums + */ + function select_news_forums($value, $key) + { + global $user, $config; + + // Determine ids to be selected + $select_ids = (sizeof($value)) ? $value : false; + + $forum_list = make_forum_select($select_ids, false, true, true, true, false, true); + + // Build forum options + $s_forum_options = ''; + foreach ($forum_list as $f_id => $f_row) + { + $s_forum_options .= ''; + } + + return $s_forum_options; + } + + function select_exclude_forums($value, $key) + { + global $user, $config; + + // Determine ids to be selected + $select_ids = (sizeof($value)) ? $value : false; + + $forum_list = make_forum_select($select_ids, false, true, false, false, false, true); + + // Build forum options + $s_forum_options = ''; + foreach ($forum_list as $f_id => $f_row) + { + $s_forum_options .= ''; + } + + return $s_forum_options; + } } ?> \ No newline at end of file diff --git a/phpBB/includes/acp/info/acp_board.php b/phpBB/includes/acp/info/acp_board.php index 72d86676a6..58b650650c 100644 --- a/phpBB/includes/acp/info/acp_board.php +++ b/phpBB/includes/acp/info/acp_board.php @@ -26,6 +26,7 @@ class acp_board_info 'message' => array('title' => 'ACP_MESSAGE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_MESSAGES')), 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'signature' => array('title' => 'ACP_SIGNATURE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + 'feed' => array('title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'registration' => array('title' => 'ACP_REGISTER_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'auth' => array('title' => 'ACP_AUTH_SETTINGS', 'auth' => 'acl_a_server', 'cat' => array('ACP_CLIENT_COMMUNICATION')), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 188c8ee5e3..94f2adc5bd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3775,6 +3775,9 @@ function page_header($page_title = '', $display_online_list = true) $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } + $forum_id = request_var('f', 0); + $topic_id = request_var('t', 0); + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -3822,6 +3825,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', + 'U_FEED' => generate_board_url() . "/feed.$phpEx", 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, @@ -3843,6 +3847,15 @@ function page_header($page_title = '', $display_online_list = true) 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, + 'S_FORUM_ID' => $forum_id, + 'S_TOPIC_ID' => $topic_id, + + 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, + 'S_ENABLE_FEEDS_NEWS' => ($config['feed_news_id'] != '') ? true : false, + 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, + 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, + 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_id && strpos($user->page['page_name'], 'viewforum') !== false) ? true : false, + 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && $topic_id && strpos($user->page['page_name'], 'viewtopic') !== false) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', -- cgit v1.2.1 From 8c246032cc03ceceb8fcf24fe3802a1f8165de2f Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 12 Jun 2009 15:24:30 +0000 Subject: fix preview in ACP git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9576 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../includes/captcha/plugins/captcha_abstract.php | 13 +++++++- .../captcha/plugins/phpbb_captcha_gd_plugin.php | 39 ++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 0666a3ca67..9e52762bc2 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -30,6 +30,7 @@ class phpbb_default_captcha var $seed; var $type; var $solved = false; + var $captcha_vars = false; function init($type) { @@ -106,10 +107,20 @@ class phpbb_default_captcha $template->set_filenames(array( 'captcha_demo' => 'captcha_default_acp_demo.html') ); + + $variables = ''; + + if (is_array($this->captcha_vars)) + { + foreach ($this->captcha_vars as $captcha_var => $template_var) + { + $variables .= '&' . rawurlencode($captcha_var) . '=' . request_var($captcha_var, (int) $config[$captcha_var]); + } + } // acp_captcha has a delivery function; let's use it $template->assign_vars(array( - 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx . '?captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()), + 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx . '?captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()) . $variables, 'CONFIRM_ID' => $this->confirm_id, )); diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index ac78b3d1c4..cd821f959e 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -29,6 +29,18 @@ if (!class_exists('phpbb_default_captcha')) */ class phpbb_captcha_gd extends phpbb_default_captcha { + + var $captcha_vars = array( + 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', + 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', + 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', + 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', + 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', + 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', + 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', + + ); + function phpbb_captcha_gd() { global $phpbb_root_path, $phpEx; @@ -65,16 +77,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); - $captcha_vars = array( - 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', - 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', - 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', - 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', - 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', - 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', - 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', - ); $config_vars = array( 'enable_confirm' => 'REG_ENABLE', @@ -92,7 +95,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha if ($submit && check_form_key($form_key)) { - $captcha_vars = array_keys($captcha_vars); + $captcha_vars = array_keys($this->captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = request_var($captcha_var, 0); @@ -109,7 +112,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha } else { - foreach ($captcha_vars as $captcha_var => $template_var) + foreach ($this->captcha_vars as $captcha_var => $template_var) { $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); @@ -121,6 +124,20 @@ class phpbb_captcha_gd extends phpbb_default_captcha )); } } + + function execute_demo() + { + global $config; + + $config_old = $config; + foreach ($this->captcha_vars as $captcha_var => $template_var) + { + $config[$captcha_var] = request_var($captcha_var, (int) $config[$captcha_var]); + } + parent::execute_demo(); + $config = $config_old; + } + } ?> \ No newline at end of file -- cgit v1.2.1 From 12de4efca49f8dea35d783db587696e37ef2355b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 13 Jun 2009 12:40:15 +0000 Subject: Fix bug #46255 - Allow friends/foes to be added and removed at the same time. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9577 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_zebra.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index fb5df9394b..c853c47026 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -52,6 +52,21 @@ class ucp_zebra { if (confirm_box(true)) { + // Remove users + if (!empty($data['usernames'])) + { + // Force integer values + $data['usernames'] = array_map('intval', $data['usernames']); + + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $user->data['user_id'] . ' + AND ' . $db->sql_in_set('zebra_id', $data['usernames']); + $db->sql_query($sql); + + $updated = true; + } + + // Add users if ($data['add']) { $data['add'] = array_map('trim', array_map('utf8_clean_string', explode("\n", $data['add']))); @@ -183,18 +198,6 @@ class ucp_zebra } } } - else if (sizeof($data['usernames'])) - { - // Force integer values - $data['usernames'] = array_map('intval', $data['usernames']); - - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND ' . $db->sql_in_set('zebra_id', $data['usernames']); - $db->sql_query($sql); - - $updated = true; - } if ($updated) { -- cgit v1.2.1 From 290893c3a7b97d3cc0e150705906c59b7e6d4185 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 12:58:17 +0000 Subject: #44745 - fix empty action in ucp groups git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9578 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_groups.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 4e40f0a2a3..49ebc48684 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -41,7 +41,7 @@ class ucp_groups switch ($mode) { case 'membership': - + $this->page_title = 'UCP_USERGROUPS_MEMBER'; if ($submit || isset($_POST['change_default'])) @@ -414,7 +414,7 @@ class ucp_groups $this->page_title = 'UCP_USERGROUPS_MANAGE'; $action = (isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''); $group_id = request_var('g', 0); - + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); add_form_key('ucp_groups'); @@ -438,10 +438,10 @@ class ucp_groups { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING); } - + $group_name = $group_row['group_name']; $group_type = $group_row['group_type']; - + $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : ''; $template->assign_vars(array( @@ -450,7 +450,7 @@ class ucp_groups 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', 'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), 'GROUP_TYPE' => $group_row['group_type'], - + 'AVATAR' => $avatar_img, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', @@ -604,7 +604,7 @@ class ucp_groups // Only set the rank, colour, etc. if it's changed or if we're adding a new // group. This prevents existing group members being updated if no changes // were made. - + $group_attributes = array(); $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients'); foreach ($test_variables as $test) @@ -679,7 +679,7 @@ class ucp_groups { avatar_gallery($category, $avatar_select, 4); } - + $avatars_enabled = ($can_upload || ($config['allow_avatar_local'] || $config['allow_avatar_remote'])) ? true : false; $template->assign_vars(array( @@ -697,7 +697,7 @@ class ucp_groups 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, - + 'GROUP_DESC' => $group_desc_data['text'], 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], 'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'], @@ -839,6 +839,7 @@ class ucp_groups 'PAGINATION' => generate_pagination($this->u_action . "&action=$action&g=$group_id", $total_members, $config['topics_per_page'], $start), 'U_ACTION' => $this->u_action . "&g=$group_id", + 'S_UCP_ACTION' => $this->u_action . "&g=$group_id", 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=ucp&field=usernames'), )); @@ -896,7 +897,7 @@ class ucp_groups if (!sizeof($mark_ary)) { $start = 0; - + do { $sql = 'SELECT user_id @@ -1027,7 +1028,7 @@ class ucp_groups $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; $default = request_var('default', 0); - + if (confirm_box(true)) { // Add user/s to group -- cgit v1.2.1 From 75ae7aee971c91e8548aabc93319dfa0789d6164 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 13 Jun 2009 13:14:27 +0000 Subject: Fix some issues with XCache, can't totally resolve the purge() method as XCache does not expose its settings to userland PHP. #46435 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9579 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_memory.php | 2 +- phpBB/includes/acm/acm_xcache.php | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index fd9b9ff342..1ed4fb0d55 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -39,7 +39,7 @@ class acm_memory global $phpbb_root_path, $dbname, $table_prefix; $this->cache_dir = $phpbb_root_path . 'cache/'; - $this->key_prefix = md5($dbname, $table_prefix) . '_'; + $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; if (!isset($this->extension) || !extension_loaded($this->extension)) { diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index ad527b8220..d0a614660c 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -25,10 +25,25 @@ if (!class_exists('acm_memory')) /** * ACM for XCache * @package acm +* +* To use this module you need ini_get() enabled and the following INI settings configured as follows: +* - xcache.var_size > 0 +* - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set) +* */ class acm extends acm_memory { - var $extension = 'xcache'; + var $extension = 'XCache'; + + function acm() + { + parent::acm_memory(); + + if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0) + { + trigger_error('Increase xcache.var_size setting above 0 or enable ini_get() to use this ACM module.', E_USER_ERROR); + } + } /** * Purge cache data @@ -37,14 +52,17 @@ class acm extends acm_memory */ function purge() { + // Run before for XCache, if admin functions are disabled it will terminate execution + parent::purge(); + + // If the admin authentication is enabled but not set up, this will cause a nasty error. + // Not much we can do about it though. $n = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $n; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } - - parent::purge(); } /** -- cgit v1.2.1 From 11dc41063313d62b100c16bceb289b12c7c3bf2b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sat, 13 Jun 2009 14:09:51 +0000 Subject: Oh right. PHP4 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9581 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_captcha.php | 10 +++++----- phpBB/includes/auth/auth_db.php | 2 +- phpBB/includes/captcha/captcha_factory.php | 5 +++-- phpBB/includes/captcha/captcha_gd.php | 1 + phpBB/includes/captcha/plugins/captcha_abstract.php | 2 +- phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php | 5 +++-- phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php | 5 +++-- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 5 +++-- phpBB/includes/ucp/ucp_register.php | 2 +- 9 files changed, 21 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 7c7a5acc9f..74e0521e12 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -43,7 +43,7 @@ class acp_captcha // Delegate if ($configure) { - $config_captcha = phpbb_captcha_factory::get_instance($selected); + $config_captcha =& phpbb_captcha_factory::get_instance($selected); $config_captcha->acp_page($id, $this); add_log('admin', 'LOG_CONFIG_VISUAL'); } @@ -78,11 +78,11 @@ class acp_captcha // sanity check if (isset($captchas['available'][$selected])) { - $old_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $old_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $old_captcha->uninstall(); set_config('captcha_plugin', $selected); - $new_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $new_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $new_captcha->install(); add_log('admin', 'LOG_CONFIG_VISUAL'); @@ -113,7 +113,7 @@ class acp_captcha $captcha_select .= ''; } - $demo_captcha = phpbb_captcha_factory::get_instance($selected); + $demo_captcha =& phpbb_captcha_factory::get_instance($selected); foreach ($config_vars as $config_var => $template_var) { @@ -135,7 +135,7 @@ class acp_captcha { global $db, $user, $config; - $captcha = phpbb_captcha_factory::get_instance($selected); + $captcha =& phpbb_captcha_factory::get_instance($selected); $captcha->init(CONFIRM_REG); $captcha->execute_demo(); diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index f798264ada..5dc141ff77 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -80,7 +80,7 @@ function login_db(&$username, &$password) } else { - $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); $vc_response = $captcha->validate(); diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index b5fa69990d..73406a954f 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -26,7 +26,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - function get_instance($name) + function &get_instance($name) { global $phpbb_root_path, $phpEx; @@ -35,7 +35,8 @@ class phpbb_captcha_factory { include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx); } - return call_user_func(array($name, 'get_instance')); + $instance =& call_user_func(array($name, 'get_instance')); + return $instance; } /** diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php index 9734a63c1b..91915ce80c 100644 --- a/phpBB/includes/captcha/captcha_gd.php +++ b/phpBB/includes/captcha/captcha_gd.php @@ -34,6 +34,7 @@ class captcha function execute($code, $seed) { global $config; + srand($seed); //mt_srand($seed); diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 9e52762bc2..6ca6bc628e 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -131,7 +131,7 @@ class phpbb_default_captcha { $hidden_fields = array(); - // this is required for postig.php - otherwise we would forget about the captcha being already solved + // this is required for posting.php - otherwise we would forget about the captcha being already solved if ($this->solved) { $hidden_fields['confirm_code'] = $this->confirm_code; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index cd821f959e..06178ece50 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -51,9 +51,10 @@ class phpbb_captcha_gd extends phpbb_default_captcha } } - function get_instance() + function &get_instance() { - return new phpbb_captcha_gd(); + $instance =& new phpbb_captcha_gd(); + return $instance; } function is_available() diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php index 517b55f09e..1fc859532a 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -40,9 +40,10 @@ class phpbb_captcha_nogd extends phpbb_default_captcha } } - function get_instance() + function &get_instance() { - return new phpbb_captcha_nogd(); + $instance =& new phpbb_captcha_nogd(); + return $instance; } function is_available() diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index a96f5ef9c6..2a20b4b78d 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -42,9 +42,10 @@ class phpbb_recaptcha extends phpbb_default_captcha $this->response = request_var('recaptcha_response_field', ''); } - function get_instance() + function &get_instance() { - return new phpbb_recaptcha(); + $instance =& new phpbb_recaptcha(); + return $instance; } function is_available() diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 06606f602f..fa8119949f 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -56,7 +56,7 @@ class ucp_register if ($config['enable_confirm']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REG); } -- cgit v1.2.1 From 2d30e880899d7a15c0cac5c1f03c951fb0ceb5be Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 14:23:04 +0000 Subject: use same method to update custom profile fields in UCP and ACP (and then i am able to debug what is wrong with the oracle code) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9582 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 49 +---------------------- phpBB/includes/functions_profile_fields.php | 61 ++++++++++++++++++++++++++++- phpBB/includes/ucp/ucp_profile.php | 20 +--------- 3 files changed, 62 insertions(+), 68 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index e5f83faec3..11bfe12354 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1136,54 +1136,7 @@ class acp_users $db->sql_query($sql); // Update Custom Fields - if (sizeof($cp_data)) - { - switch ($db->sql_layer) - { - case 'oracle': - case 'firebird': - case 'postgres': - $right_delim = $left_delim = '"'; - break; - - case 'sqlite': - case 'mssql': - case 'mssql_odbc': - $right_delim = ']'; - $left_delim = '['; - break; - - case 'mysql': - case 'mysql4': - case 'mysqli': - $right_delim = $left_delim = '`'; - break; - } - - foreach ($cp_data as $key => $value) - { - // Firebird is case sensitive with delimiter - $cp_data[$left_delim . (($db->sql_layer == 'firebird') ? strtoupper($key) : $key) . $right_delim] = $value; - unset($cp_data[$key]); - } - - $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $cp_data) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if (!$db->sql_affectedrows()) - { - $cp_data['user_id'] = (int) $user_id; - - $db->sql_return_on_error(true); - - $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); - $db->sql_query($sql); - - $db->sql_return_on_error(false); - } - } + $cp->update_profile_field_data($user_id, $cp_data); trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 26a1feb126..d9b6b25477 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -259,7 +259,7 @@ class custom_profile } /** - * Submit profile field + * Submit profile field for validation * @access public */ function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error) @@ -349,6 +349,65 @@ class custom_profile $db->sql_freeresult($result); } + /** + * Update profile field data directly + */ + function update_profile_field_data($user_id, &$cp_data) + { + global $db; + + if (!sizeof($cp_data)) + { + return; + } + + switch ($db->sql_layer) + { + case 'oracle': + case 'firebird': + case 'postgres': + $right_delim = $left_delim = '"'; + break; + + case 'sqlite': + case 'mssql': + case 'mssql_odbc': + $right_delim = ']'; + $left_delim = '['; + break; + + case 'mysql': + case 'mysql4': + case 'mysqli': + $right_delim = $left_delim = '`'; + break; + } + + foreach ($cp_data as $key => $value) + { + // Firebird is case sensitive with delimiter + $cp_data[$left_delim . (($db->sql_layer == 'firebird') ? strtoupper($key) : $key) . $right_delim] = $value; + unset($cp_data[$key]); + } + + $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $cp_data) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + if (!$db->sql_affectedrows()) + { + $cp_data['user_id'] = (int) $user_id; + + $db->sql_return_on_error(true); + + $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); + $db->sql_query($sql); + + $db->sql_return_on_error(false); + } + } + /** * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 30752d8c8a..572235696e 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -380,25 +380,7 @@ class ucp_profile $db->sql_query($sql); // Update Custom Fields - if (sizeof($cp_data)) - { - $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $cp_data) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - if (!$db->sql_affectedrows()) - { - $cp_data['user_id'] = (int) $user->data['user_id']; - - $db->sql_return_on_error(true); - - $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); - $db->sql_query($sql); - - $db->sql_return_on_error(false); - } - } + $cp->update_profile_field_data($user->data['user_id'], $cp_data); meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); -- cgit v1.2.1 From d843dbd046fa427d00d30ef06558043e46c6fc98 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 14:48:45 +0000 Subject: Fix sql_column_exists for oracle (oracle uses uppercase table names) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9583 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/db_tools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index bc6b027b1f..8c8653e1da 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -801,7 +801,7 @@ class phpbb_db_tools case 'oracle': $sql = "SELECT column_name FROM user_tab_columns - WHERE table_name = '{$table}'"; + WHERE LOWER(table_name) = '" . strtolower($table) . "'"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { -- cgit v1.2.1 From d8e78c766b0f14f5d53e1916c341cbaccb012b4f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 15:00:33 +0000 Subject: like firebird, oracle uses uppercase column names if delimiter used (Fixes Bug #46015) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9585 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_profile_fields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index d9b6b25477..bb54e0de5b 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -386,7 +386,7 @@ class custom_profile foreach ($cp_data as $key => $value) { // Firebird is case sensitive with delimiter - $cp_data[$left_delim . (($db->sql_layer == 'firebird') ? strtoupper($key) : $key) . $right_delim] = $value; + $cp_data[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value; unset($cp_data[$key]); } -- cgit v1.2.1 From e69fe56634225d771d4d47c2151d9828b1be2b5d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 16:04:54 +0000 Subject: - fix sql_column_exists for firebird (had same problem as oracle) - fix sql_column_change for firebird (interbase6 only supports TYPE and SET DEFAULT, but not the same syntax ass ADD COLUMN) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9586 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/db_tools.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 8c8653e1da..7ea70f341d 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -819,7 +819,7 @@ class phpbb_db_tools case 'firebird': $sql = "SELECT RDB\$FIELD_NAME as FNAME FROM RDB\$RELATION_FIELDS - WHERE RDB\$RELATION_NAME = '{$table}'"; + WHERE RDB\$RELATION_NAME = '" . strtoupper($table) . "'"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -972,10 +972,12 @@ class phpbb_db_tools { case 'firebird': $sql .= " {$column_type} "; + $return_array['column_type_sql_type'] = " {$column_type} "; if (!is_null($column_data[1])) { $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; + $return_array['column_type_sql_default'] = ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; } $sql .= 'NOT NULL'; @@ -1648,7 +1650,15 @@ class phpbb_db_tools { case 'firebird': // Change type... - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; + if (!empty($column_data['column_type_sql_default'])) + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" SET DEFAULT ' . ' ' . $column_data['column_type_sql_default']; + } + else + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; + } break; case 'mssql': -- cgit v1.2.1 From 4758d49b9b661703d2cd5cffaa9c6c443a624e1d Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 14 Jun 2009 10:53:08 +0000 Subject: view_log() breaks if the serialized data is corrupt. #46545 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9589 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a1f34792e0..a8e49a12bc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2419,7 +2419,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id if (!empty($row['log_data'])) { - $log_data_ary = unserialize($row['log_data']); + $log_data_ary = @unserialize($row['log_data']); + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; if (isset($user->lang[$row['log_operation']])) { @@ -2442,7 +2443,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); } } - else + else if (!empty($log_data_ary)) { $log[$i]['action'] .= '
' . implode('', $log_data_ary); } -- cgit v1.2.1 From b60f96c4ec09a41f0ecd19f16caca7f88808cc23 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 14 Jun 2009 15:24:03 +0000 Subject: See if this plays out: do not require people to re-enter the CAPTCHA git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9591 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 3 ++- phpBB/includes/ucp/ucp_register.php | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 6ca6bc628e..1446df9874 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -183,7 +183,8 @@ class phpbb_default_captcha function validate() { global $config, $db, $user; - + + $error = ''; $this->confirm_code = request_var('confirm_code', ''); if (!$this->confirm_id) { diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index fa8119949f..4671f21d5b 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -52,7 +52,8 @@ class ucp_register { add_form_key('ucp_register_terms'); } - + + $captcha_solved = false; if ($config['enable_confirm']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); @@ -216,7 +217,8 @@ class ucp_register } else { - $captcha->reset(); + $captcha_solved = true; + // $captcha->reset(); } if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) @@ -423,12 +425,17 @@ class ucp_register { $s_hidden_fields['coppa'] = $coppa; } - $s_hidden_fields = build_hidden_fields($s_hidden_fields); + + if ($config['enable_confirm']) + { + $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); + } + $s_hidden_fields = build_hidden_fields($s_hidden_fields); $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm']) + if ($config['enable_confirm'] && !$captcha_solved) { if ($change_lang || $confirm_refresh) { -- cgit v1.2.1 From f8f4b1373fb40bb069fe169426f921b649d1f46b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 14 Jun 2009 22:38:00 +0000 Subject: Addition to r9577: Remove unnecessary integer casting. request_var() already does that. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9593 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_zebra.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index c853c47026..50fcbed90e 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -55,9 +55,6 @@ class ucp_zebra // Remove users if (!empty($data['usernames'])) { - // Force integer values - $data['usernames'] = array_map('intval', $data['usernames']); - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('zebra_id', $data['usernames']); -- cgit v1.2.1 From 8c79920a55e2b803cc050ad662b7da73a08f6998 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 15 Jun 2009 11:19:19 +0000 Subject: Fix bug #45585 - Show error if hostname lookup doesn't return a valid IP address when banning. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9594 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 48fb532d00..ab0122866c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -910,7 +910,8 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } } } - else + + if (empty($banlist_ary)) { trigger_error('NO_IPS_DEFINED'); } -- cgit v1.2.1 From a49eef594bf059f9ac1fa480049838af6cf0f260 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 15 Jun 2009 11:21:27 +0000 Subject: Fix bug #46455 - Make sure can_load_dll() is available. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9595 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_gd_plugin.php | 22 ++++++++++++++++------ .../plugins/phpbb_captcha_gd_wave_plugin.php | 14 +++++++++++++- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index 06178ece50..108e8f686e 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -38,9 +38,8 @@ class phpbb_captcha_gd extends phpbb_default_captcha 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', - ); - + function phpbb_captcha_gd() { global $phpbb_root_path, $phpEx; @@ -59,7 +58,19 @@ class phpbb_captcha_gd extends phpbb_default_captcha function is_available() { - return (@extension_loaded('gd') || can_load_dll('gd')); + global $phpbb_root_path, $phpEx; + + if (@extension_loaded('gd')) + { + return true; + } + + if (!function_exists('can_load_dll')) + { + include($phpbb_root_path . 'includes/functions_install.' . $phpEx); + } + + return can_load_dll('gd'); } function get_name() @@ -79,7 +90,6 @@ class phpbb_captcha_gd extends phpbb_default_captcha $user->add_lang('acp/board'); - $config_vars = array( 'enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', @@ -125,7 +135,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha )); } } - + function execute_demo() { global $config; @@ -138,7 +148,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha parent::execute_demo(); $config = $config_old; } - + } ?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index 4198dcdf5b..ce678b6d29 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -47,7 +47,19 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha function is_available() { - return (@extension_loaded('gd') || can_load_dll('gd')); + global $phpbb_root_path, $phpEx; + + if (@extension_loaded('gd')) + { + return true; + } + + if (!function_exists('can_load_dll')) + { + include($phpbb_root_path . 'includes/functions_install.' . $phpEx); + } + + return can_load_dll('gd'); } function get_name() -- cgit v1.2.1 From d8b0f2f31074b83fffa613e93cf156fd913f74be Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Jun 2009 14:06:56 +0000 Subject: Fix bug #40205 - Wrong message shown to user, when adding bots to friends/foes Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9597 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_zebra.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 50fcbed90e..5ed4db7520 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -136,6 +136,10 @@ class ucp_zebra { $user_id_ary[] = $row['user_id']; } + else if ($row['user_id'] != ANONYMOUS) + { + $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_BOTS']; + } else { $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS']; -- cgit v1.2.1 From ce144ab0baaafa10bf3e37812e2f5875680de499 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 16 Jun 2009 14:14:07 +0000 Subject: Fix Oracle database backup (Bug #46715) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9598 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 856b867c9a..1182e224cf 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -1854,7 +1854,8 @@ class oracle_extractor extends base_extractor // Build the SQL statement to recreate the data. for ($i = 0; $i < $i_num_fields; $i++) { - $str_val = $row[$ary_name[$i]]; + // Oracle uses uppercase - we use lowercase + $str_val = $row[strtolower($ary_name[$i])]; if (preg_match('#char|text|bool|raw#i', $ary_type[$i])) { @@ -1885,7 +1886,7 @@ class oracle_extractor extends base_extractor } $schema_vals[$i] = $str_quote . $str_val . $str_quote; - $schema_fields[$i] = '"' . $ary_name[$i] . "'"; + $schema_fields[$i] = '"' . $ary_name[$i] . '"'; } // Take the ordered fields and their associated data and build it -- cgit v1.2.1 From bfc8906a5ed4b99d0c592972b3267fe52d5da257 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 16 Jun 2009 14:36:12 +0000 Subject: Fix bug #40245 - Attachments table is not being updated when deleting user and retaining his posts Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9599 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index ab0122866c..144b323959 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -421,6 +421,11 @@ function user_delete($mode, $user_id, $post_username = false) WHERE topic_last_poster_id = $user_id"; $db->sql_query($sql); + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' + SET poster_id = ' . ANONYMOUS . " + WHERE poster_id = $user_id"; + $db->sql_query($sql); + // Since we change every post by this author, we need to count this amount towards the anonymous user // Update the post count for the anonymous user -- cgit v1.2.1 From ef0eed4d9ef83d7dfbcdd1c78f812ef5e135f279 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Jun 2009 16:13:53 +0000 Subject: Fix bug #46145 - Template cache error for files of template-subfolders Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9600 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_styles.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 48802c79df..4c33aa1edb 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1029,12 +1029,12 @@ parse_css_file = {PARSE_CSS_FILE} foreach ($file_ary as $file) { - $file = str_replace('/', '.', $file); + $file = str_replace('/', '.', $file); // perform some dirty guessing to get the path right. // We assume that three dots in a row were '../' - $tpl_file = str_replace('.', '/', $file); - $tpl_file = str_replace('///', '../', $tpl_file); + $tpl_file = str_replace('.', '/', $file); + $tpl_file = str_replace('///', '../', $tpl_file); $filename = "{$cache_prefix}_$file.html.$phpEx"; @@ -1066,6 +1066,11 @@ parse_css_file = {PARSE_CSS_FILE} } } + // Correct the filename if it is stored in database and the file is in a subfolder. + if ($template_row['template_storedb']) + { + $file = str_replace('.', '/', $file); + } $template->assign_block_vars('file', array( 'U_VIEWSOURCE' => $this->u_action . "&action=cache&id=$template_id&source=$file", @@ -1073,7 +1078,7 @@ parse_css_file = {PARSE_CSS_FILE} 'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/$filename")), 'FILENAME' => $file, 'FILENAME_PATH' => $file_tpl, - 'FILESIZE' => sprintf('%.1f ' . $user->lang['KIB'], filesize("{$phpbb_root_path}cache/$filename") / 1024), + 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")), 'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html'])) ); } @@ -1271,7 +1276,6 @@ parse_css_file = {PARSE_CSS_FILE} ); } - /** * Edit imagesets * @@ -2409,7 +2413,6 @@ parse_css_file = {PARSE_CSS_FILE} } } - if ($mode == 'template') { $super = array(); @@ -3209,7 +3212,6 @@ parse_css_file = {PARSE_CSS_FILE} $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ($row) { // If it exist, we just use the style on installation @@ -3260,7 +3262,6 @@ parse_css_file = {PARSE_CSS_FILE} $inherit_bf = false; } - if (sizeof($error)) { return false; @@ -3530,7 +3531,6 @@ parse_css_file = {PARSE_CSS_FILE} break; } - $sql = "SELECT {$mode}_inherits_id FROM $sql_from WHERE {$mode}_id = " . (int) $id; -- cgit v1.2.1 From 3b181245b206e383ba603bb23105a91b494181ed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 09:10:48 +0000 Subject: Change bug #21825 - Banning/unbanning users now generates an entry in their user notes Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9602 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 144b323959..962733aa6a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1072,9 +1072,16 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas // Update log $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'LOG_BAN_'; - // Add to moderator and admin log + // Add to moderator log, admin log and user notes add_log('admin', $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); add_log('mod', 0, 0, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); + if ($mode == 'user') + { + foreach ($banlist_ary as $user_id) + { + add_log('user', $user_id, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); + } + } $cache->destroy('sql', BANLIST_TABLE); @@ -1113,7 +1120,7 @@ function user_unban($mode, $ban) switch ($mode) { case 'user': - $sql = 'SELECT u.username AS unban_info + $sql = 'SELECT u.username AS unban_info, u.user_id FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b WHERE ' . $db->sql_in_set('b.ban_id', $unban_sql) . ' AND u.user_id = b.ban_userid'; @@ -1134,9 +1141,11 @@ function user_unban($mode, $ban) $result = $db->sql_query($sql); $l_unban_list = ''; + $user_ids_ary = array(); while ($row = $db->sql_fetchrow($result)) { $l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info']; + $user_ids_ary[] = $row['user_id']; } $db->sql_freeresult($result); @@ -1144,9 +1153,16 @@ function user_unban($mode, $ban) WHERE ' . $db->sql_in_set('ban_id', $unban_sql); $db->sql_query($sql); - // Add to moderator and admin log + // Add to moderator log, admin log and user notes add_log('admin', 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); add_log('mod', 0, 0, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); + if ($mode == 'user') + { + foreach ($user_ids_ary as $user_id) + { + add_log('user', $user_id, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); + } + } } $cache->destroy('sql', BANLIST_TABLE); -- cgit v1.2.1 From 7b0d5c0164491fbce9b93e22bd28ab759c592420 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 10:40:32 +0000 Subject: Fix bug #41555 - Fix function to recalculate Binary Tree Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9605 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 104 ++++++++++--------------------------- 1 file changed, 28 insertions(+), 76 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a8e49a12bc..d74bad53e9 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -18,94 +18,46 @@ if (!defined('IN_PHPBB')) /** * Recalculate Binary Tree -function recalc_btree($sql_id, $sql_table, $module_class = '') +* +* @param int $new_id first left_id (should start with 1) +* @param string $pkey primary key-column (containing the id for the parent_id of the children) +* @param string $table constant or fullname of the table +* @param int $parent_id parent_id of the current tree-path (default = 0) +* @param array $where contains strings to compare closer on the where statement (additional) +* +* @author EXreaction +*/ +function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) { global $db; - if (!$sql_id || !$sql_table) - { - return; - } - - $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : ''; - - // Reset to minimum possible left and right id - $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id - FROM $sql_table - $sql_where"; + $sql = 'SELECT * + FROM ' . $table . ' + WHERE parent_id = ' . (int) $parent_id . + ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . ' + ORDER BY left_id ASC'; $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1); - - if ($substract > 0) - { - $sql = "UPDATE $sql_table - SET left_id = left_id - $substract, right_id = right_id - $substract - $sql_where"; - $db->sql_query($sql); - } - - $sql = "SELECT $sql_id, parent_id, left_id, right_id - FROM $sql_table - $sql_where - ORDER BY left_id ASC, parent_id ASC, $sql_id ASC"; - $f_result = $db->sql_query($sql); - - while ($item_data = $db->sql_fetchrow($f_result)) + while ($row = $db->sql_fetchrow($result)) { - if ($item_data['parent_id']) + // First we update the left_id for this module + if ($row['left_id'] != $new_id) { - $sql = "SELECT left_id, right_id - FROM $sql_table - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - $sql_id = {$item_data['parent_id']}"; - $result = $db->sql_query($sql); - - if (!$row = $db->sql_fetchrow($result)) - { - $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id]; - $db->sql_query($sql); - } - $db->sql_freeresult($result); + $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); + } + $new_id++; - $sql = "UPDATE $sql_table - SET left_id = left_id + 2, right_id = right_id + 2 - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - left_id > {$row['right_id']}"; - $db->sql_query($sql); + // Then we go through any children and update their left/right id's + recalc_btree($new_id, $pkey, $table, $row[$pkey], $where); - $sql = "UPDATE $sql_table - SET right_id = right_id + 2 - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - {$row['left_id']} BETWEEN left_id AND right_id"; - $db->sql_query($sql); - - $item_data['left_id'] = $row['right_id']; - $item_data['right_id'] = $row['right_id'] + 1; - } - else + // Then we come back and update the right_id for this module + if ($row['right_id'] != $new_id) { - $sql = "SELECT MAX(right_id) AS right_id - FROM $sql_table - $sql_where"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $item_data['left_id'] = $row['right_id'] + 1; - $item_data['right_id'] = $row['right_id'] + 2; + $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); } - - $sql = "UPDATE $sql_table - SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']} - WHERE $sql_id = " . $item_data[$sql_id]; - $db->sql_query($sql); + $new_id++; } - $db->sql_freeresult($f_result); + $db->sql_freeresult($result); } -*/ /** * Simple version of jumpbox, just lists authed forums -- cgit v1.2.1 From afddcaecf2886cd8f2442a419623bb1447d81aba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 12:15:54 +0000 Subject: fix r9605 Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9606 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d74bad53e9..52a7017e09 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -17,17 +17,17 @@ if (!defined('IN_PHPBB')) } /** -* Recalculate Binary Tree +* Recalculate Nested Sets * * @param int $new_id first left_id (should start with 1) * @param string $pkey primary key-column (containing the id for the parent_id of the children) * @param string $table constant or fullname of the table -* @param int $parent_id parent_id of the current tree-path (default = 0) +* @param int $parent_id parent_id of the current set (default = 0) * @param array $where contains strings to compare closer on the where statement (additional) * * @author EXreaction */ -function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) +function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) { global $db; @@ -47,7 +47,7 @@ function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) $new_id++; // Then we go through any children and update their left/right id's - recalc_btree($new_id, $pkey, $table, $row[$pkey], $where); + recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where); // Then we come back and update the right_id for this module if ($row['right_id'] != $new_id) -- cgit v1.2.1 From 0e5cc91d6bdcef2e50fd8f04b4d5fe2249015f24 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 12:17:19 +0000 Subject: Fix bug #22665 - Display and highlight already used rank images while assigning new rank Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9607 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_ranks.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index 41ed5b0fba..a1a10545ef 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -168,25 +168,22 @@ class acp_ranks { $img = $path . $img; - if (!in_array($img, $existing_imgs) || $action == 'edit') + if ($ranks && $img == $ranks['rank_image']) { - if ($ranks && $img == $ranks['rank_image']) - { - $selected = ' selected="selected"'; - $edit_img = $img; - } - else - { - $selected = ''; - } - - if (strlen($img) > 255) - { - continue; - } - - $filename_list .= ''; + $selected = ' selected="selected"'; + $edit_img = $img; } + else + { + $selected = ''; + } + + if (strlen($img) > 255) + { + continue; + } + + $filename_list .= ''; } } -- cgit v1.2.1 From c6c6841cfbc0b5e342fb2dc5cbdea1834c4b47e9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 17 Jun 2009 13:29:26 +0000 Subject: Use dynamic includes, fix some style bugs, make the old default captcha family backwards compatible to 3.0.5 styles git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9609 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/captcha_gd.php | 5 ++--- .../includes/captcha/plugins/captcha_abstract.php | 26 ++++++++++------------ .../captcha/plugins/phpbb_captcha_gd_plugin.php | 2 +- .../captcha/plugins/phpbb_recaptcha_plugin.php | 6 +---- phpBB/includes/functions.php | 2 +- phpBB/includes/ucp/ucp_register.php | 5 ++--- 6 files changed, 19 insertions(+), 27 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php index 91915ce80c..96e39af85b 100644 --- a/phpBB/includes/captcha/captcha_gd.php +++ b/phpBB/includes/captcha/captcha_gd.php @@ -35,8 +35,7 @@ class captcha { global $config; - srand($seed); - //mt_srand($seed); + mt_srand($seed); // Create image $img = imagecreatetruecolor($this->width, $this->height); @@ -109,7 +108,7 @@ class captcha if ($config['captcha_gd_3d_noise']) { - $xoffset = rand(0,9); + $xoffset = mt_rand(0,9); $noise_bitmaps = $this->captcha_noise_bg_bitmaps(); for ($i = 0; $i < $code_len; ++$i) { diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 1446df9874..1682293c02 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -85,29 +85,27 @@ class phpbb_default_captcha function get_template() { global $config, $user, $template, $phpEx, $phpbb_root_path; - - $template->set_filenames(array( - 'captcha' => 'captcha_default.html') - ); - + + $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); + $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; + $template->assign_vars(array( - 'CONFIRM_IMAGE' => append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type), + 'CONFIRM_IMAGE_LINK' => $link, + 'CONFIRM_IMAGE' => '', + 'CONFIRM_IMG' => '', 'CONFIRM_ID' => $this->confirm_id, - 'S_REFRESH' => (bool) $config['confirm_refresh'], - + 'S_CONFIRM_CODE' => true, + 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, + 'L_CONFIRM_EXPLAIN' => $explain, )); - return $template->assign_display('captcha'); + return 'captcha_default.html'; } function get_demo_template($id) { global $config, $user, $template, $phpbb_admin_path, $phpEx; - $template->set_filenames(array( - 'captcha_demo' => 'captcha_default_acp_demo.html') - ); - $variables = ''; if (is_array($this->captcha_vars)) @@ -124,7 +122,7 @@ class phpbb_default_captcha 'CONFIRM_ID' => $this->confirm_id, )); - return $template->assign_display('captcha_demo'); + return 'captcha_default_acp_demo.html'; } function get_hidden_fields() diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index 108e8f686e..ab71da10d7 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -34,7 +34,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', - 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', +// 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 2a20b4b78d..bd8fbce0fa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -128,10 +128,6 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $user, $template; - $template->set_filenames(array( - 'captcha' => 'captcha_recaptcha.html') - ); - $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', @@ -139,7 +135,7 @@ class phpbb_recaptcha extends phpbb_default_captcha 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), )); - return $template->assign_display('captcha'); + return 'captcha_recaptcha.html'; } function get_demo_template($id) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 94f2adc5bd..e55a76fbb0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2702,7 +2702,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $template->assign_vars(array( 'S_CONFIRM_CODE' => true, - 'CONFIRM' => $captcha->get_template(''), + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); $err = $user->lang[$result['error_msg']]; diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 4671f21d5b..4815329643 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -42,7 +42,6 @@ class ucp_register $submit = (isset($_POST['submit'])) ? true : false; $change_lang = request_var('change_lang', ''); $user_lang = request_var('lang', $user->lang_name); - $confirm_refresh= (isset($_POST['confirm_refresh']) && $config['confirm_refresh']) ? ((!empty($_POST['confirm_refresh'])) ? 1 : 0) : false; if ($agreed) { @@ -437,7 +436,7 @@ class ucp_register // Visual Confirmation - Show images if ($config['enable_confirm'] && !$captcha_solved) { - if ($change_lang || $confirm_refresh) + if ($change_lang) { $str = '&change_lang=' . $change_lang; } @@ -448,7 +447,7 @@ class ucp_register $template->assign_vars(array( 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), - 'S_CAPTCHA' => $captcha->get_template(), + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); } -- cgit v1.2.1 From 737812dc448967179a2d286243bdb9ac8c41371f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 15:38:08 +0000 Subject: fix r9602 Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9611 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 962733aa6a..f8827154c9 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1145,7 +1145,10 @@ function user_unban($mode, $ban) while ($row = $db->sql_fetchrow($result)) { $l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info']; - $user_ids_ary[] = $row['user_id']; + if ($mode == 'user') + { + $user_ids_ary[] = $row['user_id']; + } } $db->sql_freeresult($result); -- cgit v1.2.1 From ca1be2bf25eab8b601e763faf8d3de9eada68e60 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 18 Jun 2009 10:44:38 +0000 Subject: Fix bug #39875 - Empty error message in UCP folder management when creating folder without name Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9612 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_options.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php index 2d2ff23cab..e80c0672cf 100644 --- a/phpBB/includes/ucp/ucp_pm_options.php +++ b/phpBB/includes/ucp/ucp_pm_options.php @@ -109,6 +109,10 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit $db->sql_query($sql); $msg = $user->lang['FOLDER_ADDED']; } + else + { + $msg = $user->lang['FOLDER_NAME_EMPTY']; + } } else { -- cgit v1.2.1 From e3af3015231c9c8baf58f55081b2068d2dad89b0 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 18 Jun 2009 12:56:59 +0000 Subject: Finally stop this annoyance, if PDO is shared module it must be loaded for the SQLite extension to work git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9618 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_install.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 611b0a7bc3..42b9b4e318 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -21,6 +21,12 @@ if (!defined('IN_PHPBB')) */ function can_load_dll($dll) { + // SQLite2 is a tricky thing, from 5.0.0 it requires PDO; if PDO is not loaded we must state that SQLite is unavailable + // as the installer doesn't understand that the extension has a prerequisite. + if ($dll == 'sqlite' && version_compare(PHP_VERSION, '5.0.0', '>=') && !extension_loaded('pdo')) + { + return false; + } return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && function_exists('dl') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false; } -- cgit v1.2.1 From de81a5499ea941613401bd7e846db224d6d23054 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 18 Jun 2009 13:08:02 +0000 Subject: 'I think the phrase rhymes with Clucking Bell!' Fix spaces in r9618 stupid [code] block :@ git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9620 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_install.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 42b9b4e318..7fa299548d 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -23,10 +23,10 @@ function can_load_dll($dll) { // SQLite2 is a tricky thing, from 5.0.0 it requires PDO; if PDO is not loaded we must state that SQLite is unavailable // as the installer doesn't understand that the extension has a prerequisite. - if ($dll == 'sqlite' && version_compare(PHP_VERSION, '5.0.0', '>=') && !extension_loaded('pdo')) - { - return false; - } + if ($dll == 'sqlite' && version_compare(PHP_VERSION, '5.0.0', '>=') && !extension_loaded('pdo')) + { + return false; + } return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && function_exists('dl') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false; } -- cgit v1.2.1 From ac1fd3c740bf396e27e882877b94ae246caedac6 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Thu, 18 Jun 2009 23:21:19 +0000 Subject: Fix bug #16555 - Word censoring doesn't support unicode strings Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9624 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/cache.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php index fc9a01ae4e..392f1377da 100644 --- a/phpBB/includes/cache.php +++ b/phpBB/includes/cache.php @@ -84,7 +84,15 @@ class cache extends acm $censors = array(); while ($row = $db->sql_fetchrow($result)) { - $censors['match'][] = '#(?=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) + { + $censors['match'][] = '#(?sql_freeresult($result); -- cgit v1.2.1 From d7d96223e7bae7cd60b13c6e7896d95838c3633c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 19 Jun 2009 09:51:50 +0000 Subject: - Display coloured usernames in ACP groups management screens - Changed behaviour of group_create() function to support specifying additional group columns - New groups option to excempt group leaders from group permissions git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9625 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_groups.php | 38 ++++++++++++----- phpBB/includes/acp/acp_permissions.php | 1 + phpBB/includes/auth.php | 12 ++++-- phpBB/includes/functions_admin.php | 7 +++- phpBB/includes/functions_user.php | 76 +++++++++++++++++++--------------- phpBB/includes/ucp/ucp_groups.php | 19 +++++++-- 6 files changed, 101 insertions(+), 52 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 2ee5ded01d..3df61ff4e2 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -309,6 +309,7 @@ class acp_groups 'message_limit' => request_var('group_message_limit', 0), 'max_recipients' => request_var('group_max_recipients', 0), 'founder_manage' => 0, + 'skip_auth' => request_var('group_skip_auth', 0), ); if ($user->data['user_type'] == USER_FOUNDER) @@ -400,11 +401,26 @@ class acp_groups // were made. $group_attributes = array(); - $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients', 'founder_manage'); - foreach ($test_variables as $test) + $test_variables = array( + 'rank' => 'int', + 'colour' => 'string', + 'avatar' => 'string', + 'avatar_type' => 'int', + 'avatar_width' => 'int', + 'avatar_height' => 'int', + 'receive_pm' => 'int', + 'legend' => 'int', + 'message_limit' => 'int', + 'max_recipients'=> 'int', + 'founder_manage'=> 'int', + 'skip_auth' => 'int', + ); + + foreach ($test_variables as $test => $type) { if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) { + settype($submit_ary[$test], $type); $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; } } @@ -562,7 +578,7 @@ class acp_groups 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', - + 'GROUP_SKIP_AUTH' => (!empty($group_row['group_skip_auth'])) ? ' checked="checked"' : '', 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], 'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'], @@ -591,8 +607,7 @@ class acp_groups 'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=settings&name=group_colour'), 'U_ACTION' => "{$this->u_action}&action=$action&g=$group_id", 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)), - ) - ); + )); return; break; @@ -607,7 +622,7 @@ class acp_groups $this->page_title = 'GROUP_MEMBERS'; // Grab the leaders - always, on every page... - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending + $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND u.user_id = ug.user_id @@ -621,11 +636,12 @@ class acp_groups 'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"), 'USERNAME' => $row['username'], + 'USERNAME_COLOUR' => $row['user_colour'], 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', 'USER_POSTS' => $row['user_posts'], - 'USER_ID' => $row['user_id']) - ); + 'USER_ID' => $row['user_id'], + )); } $db->sql_freeresult($result); @@ -662,7 +678,7 @@ class acp_groups )); // Grab the members - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending + $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND u.user_id = ug.user_id @@ -687,6 +703,7 @@ class acp_groups 'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"), 'USERNAME' => $row['username'], + 'USERNAME_COLOUR' => $row['user_colour'], 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', 'USER_POSTS' => $row['user_posts'], @@ -763,8 +780,7 @@ class acp_groups 'GROUP_NAME' => $group_name, 'TOTAL_MEMBERS' => $row['total_members'], - ) - ); + )); } } } diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 164970b5d5..1dab6febdd 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -963,6 +963,7 @@ class acp_permissions LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id) WHERE ug.user_id = ' . $user_id . ' AND ug.user_pending = 0 + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) ORDER BY g.group_type DESC, g.group_id DESC'; $result = $db->sql_query($sql); diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 1196a9a0f0..2a269c3c80 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -608,22 +608,26 @@ class auth // Now grab group settings - non-role specific... $sql_ary[] = 'SELECT ug.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . ' - FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug' . $sql_opts_from . ' + FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g' . $sql_opts_from . ' WHERE a.auth_role_id = 0 ' . (($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . ' AND a.group_id = ug.group_id + AND g.group_id = ug.group_id AND ug.user_pending = 0 + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " $sql_forum $sql_opts"; // Now grab group settings - role specific... $sql_ary[] = 'SELECT ug.user_id, a.forum_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . ' - FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . ' + FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . ' WHERE a.auth_role_id = r.role_id ' . (($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . ' AND a.group_id = ug.group_id + AND g.group_id = ug.group_id AND ug.user_pending = 0 + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) ' . (($sql_user) ? 'AND ug.' . $sql_user : '') . " $sql_forum $sql_opts"; @@ -825,9 +829,11 @@ class auth // Now grab group-specific permission settings $sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting - FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug + FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g WHERE a.group_id = ug.group_id + AND g.group_id = ug.group_id AND ug.user_pending = 0 + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ug.user_id = ' . $user_id; $result = $db->sql_query($sql); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 52a7017e09..f9a072d1a8 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2137,12 +2137,13 @@ function cache_moderators() // Remove users who have group memberships with DENY moderator permissions $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => 'a.forum_id, ug.user_id', + 'SELECT' => 'a.forum_id, ug.user_id, g.group_id', 'FROM' => array( ACL_OPTIONS_TABLE => 'o', USER_GROUP_TABLE => 'ug', - ACL_GROUPS_TABLE => 'a' + ACL_GROUPS_TABLE => 'a', + GROUPS_TABLE => 'g', ), 'LEFT_JOIN' => array( @@ -2156,6 +2157,8 @@ function cache_moderators() AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) OR r.auth_setting = ' . ACL_NEVER . ') AND a.group_id = ug.group_id + AND g.ground_id = ug.group_id + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ug.user_pending = 0 AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char), diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index f8827154c9..5e8108eb64 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2396,24 +2396,9 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow global $phpbb_root_path, $config, $db, $user, $file_upload; $error = array(); - $attribute_ary = array( - 'group_colour' => 'string', - 'group_rank' => 'int', - 'group_avatar' => 'string', - 'group_avatar_type' => 'int', - 'group_avatar_width' => 'int', - 'group_avatar_height' => 'int', - - 'group_receive_pm' => 'int', - 'group_legend' => 'int', - 'group_message_limit' => 'int', - 'group_max_recipients' => 'int', - - 'group_founder_manage' => 'int', - ); - // Those are group-only attributes - $group_only_ary = array('group_receive_pm', 'group_legend', 'group_message_limit', 'group_max_recipients', 'group_founder_manage'); + // Attributes which also affect the users table + $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height'); // Check data. Limit group name length. if (!utf8_strlen($name) || utf8_strlen($name) > 60) @@ -2451,14 +2436,8 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (sizeof($group_attributes)) { - foreach ($attribute_ary as $attribute => $_type) - { - if (isset($group_attributes[$attribute])) - { - settype($group_attributes[$attribute], $_type); - $sql_ary[$attribute] = $group_attributes[$attribute]; - } - } + // Merge them with $sql_ary to properly update the group + $sql_ary = array_merge($sql_ary, $group_attributes); } // Setting the log message before we set the group id (if group gets added) @@ -2483,6 +2462,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow { remove_default_avatar($group_id, $user_ary); } + if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) { remove_default_rank($group_id, $user_ary); @@ -2498,6 +2478,32 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow SET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "' WHERE group_id = $group_id"; $db->sql_query($sql); + + // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group + if (isset($group_attributes['group_skip_auth'])) + { + // Get users within this group... + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND user_pending = 0'; + $result = $db->sql_query($sql); + + $user_id_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $user_id_ary[] = $row['user_id']; + } + $db->sql_freeresult($result); + + if (!empty($user_id_ary)) + { + global $auth; + + // Clear permissions cache of relevant users + $auth->acl_clear_prefetch($user_id_ary); + } + } } else { @@ -2508,6 +2514,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (!$group_id) { $group_id = $db->sql_nextid(); + if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD) { group_correct_avatar($group_id, $sql_ary['group_avatar']); @@ -2518,18 +2525,21 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $sql_ary = array(); if (sizeof($group_attributes)) { - foreach ($attribute_ary as $attribute => $_type) + // Go through the user attributes array, check if a group attribute matches it and then set it. ;) + foreach ($user_attribute_ary as $attribute) { - if (isset($group_attributes[$attribute]) && !in_array($attribute, $group_only_ary)) + if (!isset($group_attributes[$attribute])) { - // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... - if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) - { - continue; - } + continue; + } - $sql_ary[$attribute] = $group_attributes[$attribute]; + // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... + if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) + { + continue; } + + $sql_ary[$attribute] = $group_attributes[$attribute]; } } diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 49ebc48684..3f27f093ec 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -606,11 +606,24 @@ class ucp_groups // were made. $group_attributes = array(); - $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients'); - foreach ($test_variables as $test) + $test_variables = array( + 'rank' => 'int', + 'colour' => 'string', + 'avatar' => 'string', + 'avatar_type' => 'int', + 'avatar_width' => 'int', + 'avatar_height' => 'int', + 'receive_pm' => 'int', + 'legend' => 'int', + 'message_limit' => 'int', + 'max_recipients'=> 'int', + ); + + foreach ($test_variables as $test => $type) { - if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test])) + if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) { + settype($submit_ary[$test], $type); $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; } } -- cgit v1.2.1 From 5d9cf2aa41c61dd35114223006c5e16c104c5a2b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 19 Jun 2009 12:31:28 +0000 Subject: Make captchas stricter by oly having one entry per session; fix a bug in ucp_register that caused three captcha instances to be generated. Non-MySQL databases and garbage collecting needs extensive testing. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9626 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../includes/captcha/plugins/captcha_abstract.php | 53 ++++++++++++---------- phpBB/includes/ucp/ucp_register.php | 14 +++--- 2 files changed, 36 insertions(+), 31 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 1682293c02..6962100945 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -28,6 +28,7 @@ class phpbb_default_captcha var $confirm_code; var $code; var $seed; + var $attempts = 0; var $type; var $solved = false; var $captcha_vars = false; @@ -43,7 +44,7 @@ class phpbb_default_captcha $this->type = (int) $type; - if (!strlen($this->confirm_id)) + if (!strlen($this->confirm_id) || !$this->load_code()) { // we have no confirm ID, better get ready to display something $this->generate_code(); @@ -183,7 +184,6 @@ class phpbb_default_captcha global $config, $db, $user; $error = ''; - $this->confirm_code = request_var('confirm_code', ''); if (!$this->confirm_id) { $error = $user->lang['CONFIRM_CODE_WRONG']; @@ -204,7 +204,7 @@ class phpbb_default_captcha if (strlen($error)) { // okay, incorrect answer. Let's ask a new question. - $this->generate_code(); + $this->new_attempt(); return $error; } else @@ -259,6 +259,29 @@ class phpbb_default_captcha $db->sql_query($sql); } + /** + * New Question, if desired. + */ + function new_attempt() + { + global $db, $user; + + $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); + $this->seed = hexdec(substr(unique_id(), 4, 10)); + $this->solved = false; + // compute $seed % 0x7fffffff + $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); + + $sql = 'UPDATE ' . CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'code' => (string) $this->code, + 'seed' => (int) $this->seed)) . ' + , attempts = attempts + 1 + WHERE + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND + session_id = \'' . $db->sql_escape($user->session_id) . '\''; + $db->sql_query($sql); + } + /** * Look up everything we need for painting&checking. */ @@ -266,7 +289,7 @@ class phpbb_default_captcha { global $db, $user; - $sql = 'SELECT code, seed + $sql = 'SELECT code, seed, attempts FROM ' . CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' @@ -279,6 +302,7 @@ class phpbb_default_captcha { $this->code = $row['code']; $this->seed = $row['seed']; + $this->attempts = $row['attempts']; return true; } @@ -287,15 +311,6 @@ class phpbb_default_captcha function check_code() { - global $db; - - if (empty($this->code)) - { - if (!$this->load_code()) - { - return false; - } - } return (strcasecmp($this->code, $this->confirm_code) === 0); } @@ -312,17 +327,7 @@ class phpbb_default_captcha function get_attempt_count() { - global $db, $user; - - $sql = 'SELECT COUNT(session_id) AS attempts - FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . $this->type; - $result = $db->sql_query($sql); - $attempts = (int) $db->sql_fetchfield('attempts'); - $db->sql_freeresult($result); - - return $attempts; + return $this->attempts; } function reset() diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 4815329643..e1a924ae58 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -52,13 +52,6 @@ class ucp_register add_form_key('ucp_register_terms'); } - $captcha_solved = false; - if ($config['enable_confirm']) - { - include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_REG); - } if ($change_lang || $user_lang != $config['default_lang']) { @@ -150,6 +143,13 @@ class ucp_register return; } + $captcha_solved = false; + if ($config['enable_confirm']) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_REG); + } // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 $timezone = date('Z') / 3600; -- cgit v1.2.1 From be81ae9e46a5f79742b8f1bbf04ee86927eeff77 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 19 Jun 2009 12:38:08 +0000 Subject: should fix garbage collection git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9627 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 8c6606d680..b04a73be41 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -955,7 +955,7 @@ class session { include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); } - captcha_factory::garbage_collect($config['captcha_plugin']); + phpbb_captcha_factory::garbage_collect($config['captcha_plugin']); } return; -- cgit v1.2.1 From 7cebffe72fcdbbbad70ccc926192d63a92e426ce Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Fri, 19 Jun 2009 14:58:21 +0000 Subject: Fixed bug #14304 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9629 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_styles.php | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 4c33aa1edb..16b1852cd6 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -210,23 +210,36 @@ parse_css_file = {PARSE_CSS_FILE} trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); } - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' - WHERE style_id = ' . $style_id; - $db->sql_query($sql); - - // Set style to default for any member using deactivated style - if ($action == 'deactivate') + if (($action == 'deactivate' && confirm_box(true)) || $action == 'activate') { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . $config['default_style'] . " - WHERE user_style = $style_id"; + $sql = 'UPDATE ' . STYLES_TABLE . ' + SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' + WHERE style_id = ' . $style_id; $db->sql_query($sql); - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_style = 0 - WHERE forum_style = ' . $style_id; - $db->sql_query($sql); + // Set style to default for any member using deactivated style + if ($action == 'deactivate') + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . $config['default_style'] . " + WHERE user_style = $style_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_style = 0 + WHERE forum_style = ' . $style_id; + $db->sql_query($sql); + } + } + elseif ( $action == 'deactivate' ) + { + $s_hidden_fields = array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'style_id' => $style_id, + ); + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); } break; } -- cgit v1.2.1 From d85a5ad036b2088fe742de29d9464678d2e19e23 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 19 Jun 2009 22:03:19 +0000 Subject: Fix bug #46785 - Hide avatars if type disabled and give global option to turn on/off Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9632 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/includes/acp/acp_users.php | 13 ++++++++++++- phpBB/includes/functions_display.php | 20 ++++++++++++++++++-- phpBB/includes/ucp/ucp_profile.php | 17 ++++++++++++++--- 4 files changed, 45 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 1b812a9c8f..9349dab5f6 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -112,6 +112,7 @@ class acp_board 'avatar_max_width' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), + 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 11bfe12354..cb3ffe5720 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1429,8 +1429,19 @@ class acp_users $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } + if (!$config['allow_avatar'] && $user_row['user_avatar_type']) + { + $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; + } + else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || + (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || + (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) + { + $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; + } + // Generate users avatar - $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : ''; + $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : ''; $display_gallery = (isset($_POST['display_gallery'])) ? true : false; $avatar_select = basename(request_var('avatar_select', '')); diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index fdcc118269..8fa9a5677f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1200,14 +1200,15 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * @param string $avatar_width Width of users avatar * @param string $avatar_height Height of users avatar * @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * * @return string Avatar image */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR') +function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) { global $user, $config, $phpbb_root_path, $phpEx; - if (empty($avatar) || !$avatar_type) + if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) { return ''; } @@ -1217,12 +1218,27 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ switch ($avatar_type) { case AVATAR_UPLOAD: + if (!$config['allow_avatar_upload'] && !$ignore_config) + { + return ''; + } $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; break; case AVATAR_GALLERY: + if (!$config['allow_avatar_local'] && !$ignore_config) + { + return ''; + } $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; + + case AVATAR_REMOTE: + if (!$config['allow_avatar_remote'] && !$ignore_config) + { + return ''; + } + break; } $avatar_img .= $avatar; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 572235696e..e2a9699acc 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -578,9 +578,20 @@ class ucp_profile $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } + if (!$config['allow_avatar'] && $user->data['user_avatar_type']) + { + $error[] = $user->lang['AVATAR_NOT_ALLOWED']; + } + else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || + (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || + (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) + { + $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED']; + } + $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', - 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']), + 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true), 'AVATAR_SIZE' => $config['avatar_filesize'], 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), @@ -590,11 +601,11 @@ class ucp_profile 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), )); - if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) + if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) { avatar_gallery($category, $avatar_select, 4); } - else + else if ($config['allow_avatar']) { $avatars_enabled = ($can_upload || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; -- cgit v1.2.1 From 7d605da65bda85c26d13c810bbfc051b3495b76d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 19 Jun 2009 22:07:27 +0000 Subject: Fix bug #45805 - INCLUDEPHP not depending on phpbb_root_path Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9633 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 2 +- phpBB/includes/template.php | 47 ++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 15 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index d9d9abfe46..a951579db5 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -640,7 +640,7 @@ class template_compile */ function compile_tag_include_php($tag_args) { - return "include('" . $tag_args . "');"; + return "\$this->_php_include('$tag_args');"; } /** diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 0098c484bd..0263783849 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -55,7 +55,7 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; - + if ($user->theme['template_inherits_id']) { $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; @@ -105,13 +105,13 @@ class template $this->filename[$handle] = $filename; $this->files[$handle] = $this->root . '/' . $filename; - + if ($this->inherit_root) { $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; } } - + return true; } @@ -209,7 +209,7 @@ class template return true; } - + /** * Load a compiled template if possible, if not, recompile it * @access private @@ -220,7 +220,7 @@ class template $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx; $this->files_template[$handle] = $user->theme['template_id']; - + $recompile = false; if (!file_exists($filename) || @filesize($filename) === 0) { @@ -236,7 +236,7 @@ class template } $recompile = (@filemtime($filename) < filemtime($this->files[$handle])) ? true : false; } - + // Recompile page if the original template is newer, otherwise load the compiled version if (!$recompile) { @@ -249,14 +249,14 @@ class template { include($phpbb_root_path . 'includes/functions_template.' . $phpEx); } - + // Inheritance - we point to another template file for this one. Equality is also used for store_db if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) { $this->files[$handle] = $this->files_inherit[$handle]; $this->files_template[$handle] = $user->theme['template_inherits_id']; } - + $compile = new template_compile($this); // If we don't have a file assigned to this handle, die. @@ -282,7 +282,7 @@ class template $ids[] = $user->theme['template_inherits_id']; } $ids[] = $user->theme['template_id']; - + foreach ($ids as $id) { $sql = 'SELECT * @@ -290,7 +290,7 @@ class template WHERE template_id = ' . $id . " AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; - + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { @@ -298,7 +298,7 @@ class template } $db->sql_freeresult($result); } - + if (sizeof($rows)) { foreach ($rows as $row) @@ -326,7 +326,7 @@ class template { $this->files_template[$row['template_filename']] = $user->theme['template_id']; } - + if ($force_reload || $row['template_mtime'] < filemtime($file)) { if ($row['template_filename'] == $this->filename[$handle]) @@ -468,7 +468,7 @@ class template { unset($this->_tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']); } - + // Add a new iteration to this block with the variable assignments we were given. $this->_tpldata[$blockname][] = $vararray; } @@ -511,7 +511,7 @@ class template // Nested blocks are not supported return false; } - + // Change key to zero (change first position) if false and to last position if true if ($key === false || $key === true) { @@ -614,6 +614,25 @@ class template eval(' ?>' . $this->compiled_code[$handle] . '_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; + return; + } + include($file); + } } ?> \ No newline at end of file -- cgit v1.2.1 From 0d626d77bfaebb7e7e281e963b486911470f0992 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 20 Jun 2009 16:51:01 +0000 Subject: Fix bug #46865 - Add unapproved topic icon for moderators on forum list Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9635 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 8fa9a5677f..d3244e7111 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -154,6 +154,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } + // Count the difference of real to public topics, so we can display an information to moderators + $row['forum_topics_unapproved'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] - $row['forum_topics'] : 0; $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; // Display active topics from this forum? @@ -212,6 +214,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; } + $forum_rows[$parent_id]['forum_topics_unapproved'] += $row['forum_topics_unapproved']; $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; // Do not list redirects in LINK Forums as Posts. @@ -451,6 +454,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_FORUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, + 'U_UNAPPROVED_TOPICS' => ($row['forum_topics_unapproved'] > 0) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url) @@ -473,8 +477,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums') : '', 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST')) - ); + 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), + 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), + )); if ($return_moderators) { -- cgit v1.2.1 From 433de350c0fa2e1e09c23e6f5f29f118222d2df8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 20 Jun 2009 18:45:16 +0000 Subject: - [Feature] New "Newly Registered Users" group for assigning permissions to newly registered users. They will be removed from this group once they reach a defineable amount of posts. - [Feature] Ability to define if the "Newly Registered Users" group will be assigned as the default group to newly registered users. As a coincidence also Bug #46535 got fixed. Additionally the error message displayed with trigger_error() if accessing the private message tab in the ucp is now displayed inline in addition to a slightly different message for newly registered users to let them know that access permissions may be lifted over time. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9636 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 4 +-- phpBB/includes/auth/auth_apache.php | 1 + phpBB/includes/auth/auth_ldap.php | 1 + phpBB/includes/functions.php | 1 + phpBB/includes/functions_convert.php | 3 +- phpBB/includes/functions_posting.php | 4 +-- phpBB/includes/functions_user.php | 36 +++++++++++++++++-- phpBB/includes/session.php | 61 ++++++++++++++++++++++++++++++++ phpBB/includes/ucp/ucp_pm.php | 8 ++++- phpBB/includes/ucp/ucp_pm_viewfolder.php | 3 +- phpBB/includes/ucp/ucp_register.php | 5 +++ 11 files changed, 117 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 9349dab5f6..7866b1b81f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -171,8 +171,6 @@ class acp_board 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'POSTING', - 'enable_queue_trigger' => array('lang' => 'ENABLE_QUEUE_TRIGGER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'queue_trigger_posts' => array('lang' => 'QUEUE_TRIGGER_POSTS', 'validate' => 'int:0:250', 'type' => 'text:4:4', 'explain' => true), 'bump_type' => false, 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), @@ -229,6 +227,8 @@ class acp_board 'max_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,), 'require_activation' => array('lang' => 'ACC_ACTIVATION', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true), + 'new_member_post_limit' => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']), + 'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:1', 'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true), 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), 'allow_name_chars' => array('lang' => 'USERNAME_CHARS', 'validate' => 'string', 'type' => 'select', 'method' => 'select_username_chars', 'explain' => true), diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php index 930f5a0632..391e7abb0e 100644 --- a/phpBB/includes/auth/auth_apache.php +++ b/phpBB/includes/auth/auth_apache.php @@ -217,6 +217,7 @@ function user_row_apache($username, $password) 'group_id' => (int) $row['group_id'], 'user_type' => USER_NORMAL, 'user_ip' => $user->ip, + 'user_new' => ($config['new_member_post_limit']) ? 1 : 0, ); } diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index d49662fb2d..11c62ad0bc 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -227,6 +227,7 @@ function login_ldap(&$username, &$password) 'group_id' => (int) $row['group_id'], 'user_type' => USER_NORMAL, 'user_ip' => $user->ip, + 'user_new' => ($config['new_member_post_limit']) ? 1 : 0, ); unset($ldap_result); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e55a76fbb0..7b4f991965 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3795,6 +3795,7 @@ function page_header($page_title = '', $display_online_list = true) 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], + 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 2213df7d0f..f6710ded30 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1698,7 +1698,8 @@ function add_default_groups() 'REGISTERED_COPPA' => array('', 0, 0), 'GLOBAL_MODERATORS' => array('00AA00', 1, 0), 'ADMINISTRATORS' => array('AA0000', 1, 1), - 'BOTS' => array('9E8DA7', 0, 0) + 'BOTS' => array('9E8DA7', 0, 0), + 'NEWLY_REGISTERED' => array('', 0, 0), ); $sql = 'SELECT * diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 07c8944992..e0dc128583 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1620,8 +1620,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval $post_approval = 1; - // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) + // Check the permissions for post approval. Moderators are not affected. + if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) { $post_approval = 0; } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 5e8108eb64..17534376de 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -188,6 +188,8 @@ function user_add($user_row, $cp_data = false) 'user_regdate' => time(), 'user_passchg' => time(), 'user_options' => 895, + // We do not set the new flag here - registration scripts need to specify it + 'user_new' => 0, 'user_inactive_reason' => 0, 'user_inactive_time' => 0, @@ -275,6 +277,31 @@ function user_add($user_row, $cp_data = false) // Now make it the users default group... group_set_user_default($user_row['group_id'], array($user_id), false); + // Add to newly registered users group if user_new is 1 + if ($config['new_member_post_limit'] && $sql_ary['user_new']) + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED' + AND group_type = " . GROUP_SPECIAL; + $result = $db->sql_query($sql); + $add_group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if ($add_group_id) + { + // Add user to "newly registered users" group and set to default group if admin specified so. + if ($config['new_member_group_default']) + { + group_user_add($add_group_id, $user_id, false, false, true); + } + else + { + group_user_add($add_group_id, $user_id); + } + } + } + // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent if ($user_row['user_type'] == USER_NORMAL) { @@ -2867,7 +2894,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, { if (isset($sql_where_ary[$gid]) && sizeof($sql_where_ary[$gid])) { - remove_default_rank($gid, $sql_where_ary[$gid]); + remove_default_rank($group_id, $sql_where_ary[$gid]); remove_default_avatar($group_id, $sql_where_ary[$gid]); group_set_user_default($gid, $sql_where_ary[$gid], $default_data_ary); } @@ -2889,7 +2916,10 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $log = 'LOG_GROUP_REMOVE'; - add_log('admin', $log, $group_name, implode(', ', $username_ary)); + if ($group_name) + { + add_log('admin', $log, $group_name, implode(', ', $username_ary)); + } group_update_listings($group_id); @@ -3283,7 +3313,7 @@ function get_group_name($group_id) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if (!$row) + if (!$row || ($row['group_type'] == GROUP_SPECIAL && empty($user->lang))) { return ''; } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index b04a73be41..6b87bcc866 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -396,6 +396,11 @@ class session WHERE session_id = '" . $db->sql_escape($this->session_id) . "'"; $db->sql_query($sql); } + + if ($this->data['user_id'] != ANONYMOUS && !empty($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts']) + { + $this->leave_newly_registered(); + } } $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; @@ -2234,6 +2239,62 @@ class user extends session return $var; } } + + /** + * Funtion to make the user leave the NEWLY_REGISTERED system group. + * @access public + */ + function leave_newly_registered() + { + global $db; + + if (!function_exists('group_user_del')) + { + global $phpbb_root_path, $phpEx; + + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED' + AND group_type = " . GROUP_SPECIAL; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if (!$group_id) + { + return false; + } + + // We need to call group_user_del here, because this function makes sure everything is correctly changed. + // A downside for a call within the session handler is that the language is not set up yet - so no log entry + group_user_del($group_id, $this->data['user_id']); + + // Set user_new to 0 to let this not be triggered again + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_new = 0 + WHERE user_id = ' . $this->data['user_id']; + $db->sql_query($sql); + + $this->data['user_permissions'] = ''; + $this->data['user_new'] = 0; + + // The new users group was the users default group? + if ($this->data['group_id'] == $group_id) + { + // Which group is now the users default one? + $sql = 'SELECT group_id + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $this->data['user_id']; + $result = $db->sql_query($sql); + $this->data['group_id'] = $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + } + + return true; + } } ?> \ No newline at end of file diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index b4ac0c11da..6ac02c7d0a 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -119,7 +119,13 @@ class ucp_pm if (!$auth->acl_get('u_sendpm')) { - trigger_error('NO_AUTH_SEND_MESSAGE'); + // trigger_error('NO_AUTH_SEND_MESSAGE'); + $template->assign_vars(array( + 'S_NO_AUTH_SEND_MESSAGE' => true, + )); + + $tpl_file = 'ucp_pm_viewfolder'; + break; } include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx); diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index cb96b77754..b2ceb30f9e 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -504,8 +504,9 @@ function get_pm_from($folder_id, $folder, $user_id) 'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)), 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), + 'L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['NO_AUTH_SEND_MESSAGE'] : $user->lang['NO_MESSAGES'], - 'L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'], + 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index e1a924ae58..e0dc0222f5 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -310,6 +310,11 @@ class ucp_register 'user_inactive_time' => $user_inactive_time, ); + if ($config['new_member_post_limit']) + { + $user_row['user_new'] = 1; + } + // Register user... $user_id = user_add($user_row, $cp_data); -- cgit v1.2.1 From c3da86afc6be7183cdf320fe6ff0f6f5ffe46c28 Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Sat, 20 Jun 2009 19:23:02 +0000 Subject: Fixed bug #45735 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9637 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 71970b4b50..3eee702b1d 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -1254,7 +1254,7 @@ $lang = array_merge($lang, array( $keys = func_get_args(); $non_static = array_shift($keys); - $value = array_shift($keys); + $value = utf8_normalize_nfc(array_shift($keys)); if (!$non_static) { -- cgit v1.2.1 From 5ea9f6e3fc82ba39bbfde03b61a868d3c7b94f45 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 20 Jun 2009 22:38:39 +0000 Subject: Fix bug #31975 - Enhance obtain_users_online_string to be able to return user-lists for other session-items Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9638 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 59 ++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7b4f991965..c5216f7f6f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3439,16 +3439,17 @@ function msg_handler($errno, $msg_text, $errfile, $errline) /** * Queries the session table to get information about online guests -* @param int $forum_id Limits the search to the forum with this id +* @param int $item_id Limits the search to the item with this id +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return int The number of active distinct guest sessions */ -function obtain_guest_count($forum_id = 0) +function obtain_guest_count($item_id = 0, $item = 'forum') { global $db, $config; - if ($forum_id) + if ($item_id) { - $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; + $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } else { @@ -3486,17 +3487,18 @@ function obtain_guest_count($forum_id = 0) /** * Queries the session table to get information about online users -* @param int $forum_id Limits the search to the forum with this id +* @param int $item_id Limits the search to the item with this id +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return array An array containing the ids of online, hidden and visible users, as well as statistical info */ -function obtain_users_online($forum_id = 0) +function obtain_users_online($item_id = 0, $item = 'forum') { global $db, $config, $user; $reading_sql = ''; - if ($forum_id !== 0) + if ($item !== 0) { - $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; + $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } $online_users = array( @@ -3510,7 +3512,7 @@ function obtain_users_online($forum_id = 0) if ($config['load_online_guests']) { - $online_users['guests_online'] = obtain_guest_count($forum_id); + $online_users['guests_online'] = obtain_guest_count($item_id, $item); } // a little discrete magic to cache this for 30 seconds @@ -3549,14 +3551,17 @@ function obtain_users_online($forum_id = 0) /** * Uses the result of obtain_users_online to generate a localized, readable representation. * @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics -* @param int $forum_id Indicate that the data is limited to one forum and not global. +* @param int $item_id Indicate that the data is limited to one item and not global +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return array An array containing the string for output to the template */ -function obtain_users_online_string($online_users, $forum_id = 0) +function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum') { global $config, $db, $user, $auth; $user_online_link = $online_userlist = ''; + // Need caps version of $item for language-strings + $item_caps = strtoupper($item); if (sizeof($online_users['online_users'])) { @@ -3591,18 +3596,18 @@ function obtain_users_online_string($online_users, $forum_id = 0) $online_userlist = $user->lang['NO_ONLINE_USERS']; } - if ($forum_id === 0) + if ($item_id === 0) { $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; } else if ($config['load_online_guests']) { - $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS']; + $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_' . $item_caps . '_GUEST'] : $user->lang['BROWSING_' . $item_caps . '_GUESTS']; $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); } else { - $online_userlist = sprintf($user->lang['BROWSING_FORUM'], $online_userlist); + $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); } // Build online listing $vars_online = array( @@ -3700,10 +3705,28 @@ function page_header($page_title = '', $display_online_list = true) if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { - $f = request_var('f', 0); - $f = max($f, 0); - $online_users = obtain_users_online($f); - $user_online_strings = obtain_users_online_string($online_users, $f); + /** + * Load online data: + * For obtaining another session column use the following code, whereby the column is session_{$item}_id. + * Put the code directly after $item = 'forum'; + * + * + * $my_item_id = request_var('my_item_id', 0); + * + * if ($my_item_id > 0) + * { + * // would revolve to the column session_myitem_id in the SESSIONS_TABLE + * $item = 'myitem'; + * $item_id = $my_item_id; + * } + * + */ + + $item_id = max(request_var('f', 0), 0); + $item = 'forum'; + + $online_users = obtain_users_online($item_id, $item); + $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; -- cgit v1.2.1 From 050567483f8646a58b91e4abeb2bf61f735b0526 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 21 Jun 2009 09:36:13 +0000 Subject: Ability to fetch moderators with get_moderators() even if load_moderators setting is off. (Bug #35955) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9640 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index d3244e7111..57f416bee4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -663,14 +663,7 @@ function get_moderators(&$forum_moderators, $forum_id = false) { global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth; - // Have we disabled the display of moderators? If so, then return - // from whence we came ... - if (!$config['load_moderators']) - { - return; - } - - $forum_sql = ''; + $forum_id_ary = array(); if ($forum_id !== false) { @@ -679,13 +672,8 @@ function get_moderators(&$forum_moderators, $forum_id = false) $forum_id = array($forum_id); } - // If we don't have a forum then we can't have a moderator - if (!sizeof($forum_id)) - { - return; - } - - $forum_sql = 'AND m.' . $db->sql_in_set('forum_id', $forum_id); + // Exchange key/value pair to be able to faster check for the forum id existence + $forum_id_ary = array_flip($forum_id); } $sql_array = array( @@ -706,17 +694,25 @@ function get_moderators(&$forum_moderators, $forum_id = false) ), ), - 'WHERE' => "m.display_on_index = 1 $forum_sql", + 'WHERE' => 'm.display_on_index = 1', ); + // We query every forum here because for caching we should not have any parameter. $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) { + $f_id = (int) $row['forum_id']; + + if (!isset($forum_id_ary[$f_id])) + { + continue; + } + if (!empty($row['user_id'])) { - $forum_moderators[$row['forum_id']][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); + $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); } else { @@ -724,11 +720,11 @@ function get_moderators(&$forum_moderators, $forum_id = false) if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) { - $forum_moderators[$row['forum_id']][] = '' . $group_name . ''; + $forum_moderators[$f_id][] = '' . $group_name . ''; } else { - $forum_moderators[$row['forum_id']][] = '' . $group_name . ''; + $forum_moderators[$f_id][] = '' . $group_name . ''; } } } -- cgit v1.2.1 From f056e205add6b956b2e63a28a1d0b4062671c490 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 21 Jun 2009 10:40:52 +0000 Subject: rename user_id in confirm_box to confirm_uid. We are able to do this because confirm_box is completely transparent to the outside. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9641 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c5216f7f6f..dd82f9e53d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2496,7 +2496,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($check && $confirm) { - $user_id = request_var('user_id', 0); + $user_id = request_var('confirm_uid', 0); $session_id = request_var('sess', ''); $confirm_key = request_var('confirm_key', ''); @@ -2518,10 +2518,10 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo } $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user->data['user_id'], - 'sess' => $user->session_id, - 'sid' => $user->session_id) - ); + 'confirm_uid' => $user->data['user_id'], + 'sess' => $user->session_id, + 'sid' => $user->session_id, + )); // generate activation key $confirm_key = gen_rand_string(10); -- cgit v1.2.1 From afc0ef93c51f659247f4942a3691405d95947383 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 21 Jun 2009 11:13:20 +0000 Subject: add check to newly registered function to not execute this more than once git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9644 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6b87bcc866..4dc6933236 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2248,6 +2248,11 @@ class user extends session { global $db; + if (empty($this->data['user_new'])) + { + return false; + } + if (!function_exists('group_user_del')) { global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From c2c79d8297369fa461976061e0b7b95dd8c8a721 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 21 Jun 2009 13:31:26 +0000 Subject: fix the captcha ACP, restore xhtml compliance for recaptcha (#46195) - note, that this will not work in IE git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9645 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd8fbce0fa..50a456179b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -107,7 +107,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), + 'CAPTCHA_PREVIEW' => $this->get_demo_template(), 'CAPTCHA_NAME' => $this->get_class_name(), )); -- cgit v1.2.1 From 794e122cfa01539e912786455da59e25d459a56f Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 21 Jun 2009 14:31:00 +0000 Subject: add quicktool to remove users from the newly registered special group. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9646 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 30 ++++++++++++++++ phpBB/includes/functions_user.php | 73 +++++++++++++++++++++++++++++++++++++++ phpBB/includes/session.php | 41 +++------------------- 3 files changed, 108 insertions(+), 36 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cb3ffe5720..fd64025565 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -650,6 +650,28 @@ class acp_users trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; + + case 'leave_nr': + + if (confirm_box(true)) + { + remove_newly_registered($user_id, $user_row); + + add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']); + trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'u' => $user_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'update' => true)) + ); + } + + break; } // Handle registration info updates @@ -821,6 +843,10 @@ class acp_users if ($user_id == $user->data['user_id']) { $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); + if ($user_row['user_new']) + { + $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; + } } else { @@ -842,6 +868,10 @@ class acp_users { $quick_tool_ary['reactivate'] = 'FORCE'; } + if ($user_row['user_new']) + { + $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; + } } $s_action_options = ''; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 17534376de..bb54a14262 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3456,4 +3456,77 @@ function group_update_listings($group_id) } } + + +/** +* Funtion to make a user leave the NEWLY_REGISTERED system group. +* @access public +* @param $user_id The id of the user to remove from the group +*/ +function remove_newly_registered($user_id, $user_data = false) +{ + global $db; + + if ($user_data === false) + { + $sql = 'SELECT * + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + $user_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$user_row) + { + return false; + } + else + { + $user_data = $user_row; + } + } + + if (empty($user_data['user_new'])) + { + return false; + } + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED' + AND group_type = " . GROUP_SPECIAL; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if (!$group_id) + { + return false; + } + + // We need to call group_user_del here, because this function makes sure everything is correctly changed. + // A downside for a call within the session handler is that the language is not set up yet - so no log entry + group_user_del($group_id, $user_id); + + // Set user_new to 0 to let this not be triggered again + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_new = 0 + WHERE user_id = ' . $user_id; + $db->sql_query($sql); + + // The new users group was the users default group? + if ($user_data['group_id'] == $group_id) + { + // Which group is now the users default one? + $sql = 'SELECT group_id + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + $user_data['group_id'] = $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + } + + return $user_data['group_id']; +} + ?> \ No newline at end of file diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 4dc6933236..f74a7c5acc 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2253,51 +2253,20 @@ class user extends session return false; } - if (!function_exists('group_user_del')) + if (!function_exists('remove_newly_registered')) { global $phpbb_root_path, $phpEx; include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) + if ($group = remove_newly_registered($this->data['user_id'], $this->data)) { - return false; + $this->data['group_id'] = $group; + } - - // We need to call group_user_del here, because this function makes sure everything is correctly changed. - // A downside for a call within the session handler is that the language is not set up yet - so no log entry - group_user_del($group_id, $this->data['user_id']); - - // Set user_new to 0 to let this not be triggered again - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new = 0 - WHERE user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['user_permissions'] = ''; $this->data['user_new'] = 0; - - // The new users group was the users default group? - if ($this->data['group_id'] == $group_id) - { - // Which group is now the users default one? - $sql = 'SELECT group_id - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $this->data['user_id']; - $result = $db->sql_query($sql); - $this->data['group_id'] = $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - } - + return true; } } -- cgit v1.2.1 From eb72e526b804844839555314914049eec75f1398 Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Sun, 21 Jun 2009 16:00:42 +0000 Subject: Fixed bug #43125 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9648 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dd82f9e53d..14e1dde92f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2261,17 +2261,12 @@ function reapply_sid($url) } // Remove previously added sid - if (strpos($url, '?sid=') !== false) + if (strpos($url, 'sid=') !== false) { - $url = preg_replace('/(\?)sid=[a-z0-9]+(&|&)?/', '\1', $url); - } - else if (strpos($url, '&sid=') !== false) - { - $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); - } - else if (strpos($url, '&sid=') !== false) - { - $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); + // All kind of links + $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); + // if the sid was the first param, make the old second as first ones + $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); } return append_sid($url); -- cgit v1.2.1 From ffa5a33702d8ec5adec6bfc1c71bcf6e5708c4ff Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 22 Jun 2009 09:29:22 +0000 Subject: erm, yes... ground should be group git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9651 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index f9a072d1a8..b634410afc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2157,7 +2157,7 @@ function cache_moderators() AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) OR r.auth_setting = ' . ACL_NEVER . ') AND a.group_id = ug.group_id - AND g.ground_id = ug.group_id + AND g.group_id = ug.group_id AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ug.user_pending = 0 -- cgit v1.2.1 From 588dd7337fd87719b21cf2ec85671713e925acb9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Jun 2009 09:43:01 +0000 Subject: Fix bug #13673 - Add confirm-box when deleting permissions Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9652 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_permissions.php | 60 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 1dab6febdd..077a3d7c83 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -217,43 +217,61 @@ class acp_permissions trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } - // Handle actions if (strpos($mode, 'setting_') === 0 && $action) { switch ($action) { case 'delete': - - if (!check_form_key($form_name)) + if (confirm_box(true)) { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - // All users/groups selected? - $all_users = (isset($_POST['all_users'])) ? true : false; - $all_groups = (isset($_POST['all_groups'])) ? true : false; + // All users/groups selected? + $all_users = (isset($_POST['all_users'])) ? true : false; + $all_groups = (isset($_POST['all_groups'])) ? true : false; - if ($all_users || $all_groups) - { - $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); + if ($all_users || $all_groups) + { + $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); + + if ($all_users && sizeof($items['user_ids'])) + { + $user_id = $items['user_ids']; + } + else if ($all_groups && sizeof($items['group_ids'])) + { + $group_id = $items['group_ids']; + } + } - if ($all_users && sizeof($items['user_ids'])) + if (sizeof($user_id) || sizeof($group_id)) { - $user_id = $items['user_ids']; + $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); } - else if ($all_groups && sizeof($items['group_ids'])) + else { - $group_id = $items['group_ids']; + trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); } } - - if (sizeof($user_id) || sizeof($group_id)) - { - $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); - } else { - trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); + $s_hidden_fields = array( + 'i' => $id, + 'mode' => $mode, + 'action' => array($action => 1), + 'user_id' => $user_id, + 'group_id' => $group_id, + 'forum_id' => $forum_id, + 'type' => $permission_type, + ); + if (isset($_POST['all_users'])) + { + $s_hidden_fields['all_users'] = 1; + } + if (isset($_POST['all_groups'])) + { + $s_hidden_fields['all_groups'] = 1; + } + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); } break; -- cgit v1.2.1 From bfcf6a1de5181a0b26b247f8cb9e181b8c83ff90 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 22 Jun 2009 14:36:04 +0000 Subject: Fix bug #46765 - View unread posts Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9653 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 14e1dde92f..12b9363ec4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3840,6 +3840,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), + 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), -- cgit v1.2.1 From b1584a8d5c709c4c909826e23286ca6aa438cf41 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 22 Jun 2009 16:16:04 +0000 Subject: Fix bug #46965 - File named install in php directory Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9654 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 2 +- phpBB/includes/session.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 365290e909..5d6bd40681 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -499,7 +499,7 @@ class acp_main } // Warn if install is still present - if (file_exists($phpbb_root_path . 'install')) + if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) { $template->assign_var('S_REMOVE_INSTALL', true); } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index f74a7c5acc..509e11e524 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1756,7 +1756,7 @@ class user extends session // Disable board if the install/ directory is still present // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally - if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install')) + if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) { // Adjust the message slightly according to the permissions if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) -- cgit v1.2.1 From c32f49679f635175d43de7264ee09782c56c628e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 23 Jun 2009 10:48:53 +0000 Subject: - add options for quick reply (forum-based and board-wide) - add option for minimum post chars (which is a required setting for quick reply, therefore we introduce it here) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9656 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 3 +++ phpBB/includes/acp/acp_forums.php | 5 +++++ phpBB/includes/constants.php | 1 + phpBB/includes/message_parser.php | 18 +++++++++++++----- 4 files changed, 22 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 7866b1b81f..41849b909a 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -87,6 +87,7 @@ class acp_board 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'ACP_LOAD_SETTINGS', 'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), @@ -169,6 +170,7 @@ class acp_board 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'POSTING', 'bump_type' => false, @@ -181,6 +183,7 @@ class acp_board 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true), 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'text:4:4', 'explain' => false), 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), + 'min_post_chars' => array('lang' => 'MIN_CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true), 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true), 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'), diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index bf5242ace6..810caa62d5 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -139,6 +139,7 @@ class acp_forums 'enable_icons' => request_var('enable_icons', false), 'enable_prune' => request_var('enable_prune', false), 'enable_post_review' => request_var('enable_post_review', true), + 'enable_quick_reply' => request_var('enable_quick_reply', false), 'prune_days' => request_var('prune_days', 7), 'prune_viewed' => request_var('prune_viewed', 7), 'prune_freq' => request_var('prune_freq', 1), @@ -423,6 +424,7 @@ class acp_forums $forum_data['forum_flags'] += (request_var('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0; $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; $forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; + $forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; } // Show form to create/modify a forum @@ -682,6 +684,7 @@ class acp_forums 'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false, 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false, 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, + 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, 'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false, )); @@ -941,6 +944,7 @@ class acp_forums $forum_data['forum_flags'] += ($forum_data['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0; $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; $forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; + $forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; // Unset data that are not database fields $forum_data_sql = $forum_data; @@ -951,6 +955,7 @@ class acp_forums unset($forum_data_sql['prune_sticky']); unset($forum_data_sql['show_active']); unset($forum_data_sql['enable_post_review']); + unset($forum_data_sql['enable_quick_reply']); unset($forum_data_sql['forum_password_confirm']); // What are we going to do tonight Brain? The same thing we do everynight, diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 4cb21bc637..2e2c239d89 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -91,6 +91,7 @@ define('FORUM_FLAG_PRUNE_ANNOUNCE', 4); define('FORUM_FLAG_PRUNE_STICKY', 8); define('FORUM_FLAG_ACTIVE_TOPICS', 16); define('FORUM_FLAG_POST_REVIEW', 32); +define('FORUM_FLAG_QUICK_REPLY', 64); // Optional text flags define('OPTION_FLAG_BBCODE', 1); diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ab6fc3f4f3..4cdc8b933e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1089,14 +1089,22 @@ class parse_message extends bbcode_firstpass $replace = array("\\1:"); $this->message = preg_replace($match, $replace, trim($this->message)); - // Message length check. 0 disables this check completely. - if ($config['max_' . $mode . '_chars'] > 0) + // Store message length... + $message_length = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); + + // Maximum message length check. 0 disables this check completely. + if ((int) $config['max_' . $mode . '_chars'] > 0 && $message_length > (int) $config['max_' . $mode . '_chars']) { - $msg_len = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); + $this->warn_msg[] = sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $message_length, (int) $config['max_' . $mode . '_chars']); + return (!$update_this_message) ? $return_message : $this->warn_msg; + } - if ((!$msg_len && $mode !== 'sig') || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars']) + // Minimum message length check for post only + if ($mode !== 'sig') + { + if (!$message_length || $message_length < (int) $config['min_post_chars']) { - $this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, $config['max_' . $mode . '_chars']); + $this->warn_msg[] = (!$message_length) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_FEW_CHARS_LIMIT'], $message_length, (int) $config['min_post_chars']); return (!$update_this_message) ? $return_message : $this->warn_msg; } } -- cgit v1.2.1 From 6c9ddcf1df1d4255867ef1d34eb4498ba908338c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 23 Jun 2009 12:10:50 +0000 Subject: fix previews git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9659 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 50a456179b..bd8fbce0fa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -107,7 +107,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $this->get_demo_template(), + 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), )); -- cgit v1.2.1 From 4279658e1ffeab6cf4c5989ba5a88685a6927c4b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 23 Jun 2009 13:22:05 +0000 Subject: meh git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9660 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_captcha.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 74e0521e12..2fc8fe7486 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -121,8 +121,8 @@ class acp_captcha } $template->assign_vars(array( - 'CAPTCHA_PREVIEW' => $demo_captcha->get_demo_template($id), - 'CAPTCHA_SELECT' => $captcha_select, + 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), + 'CAPTCHA_SELECT' => $captcha_select, )); } } -- cgit v1.2.1 From 19e2dcd5db7f2a910409b82ce315265608ae8266 Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Wed, 24 Jun 2009 02:56:05 +0000 Subject: Fixed Bug #47145 - [Fix] Correctly check banned users when force password change Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9665 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 509e11e524..c1bc4b3f31 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1833,7 +1833,7 @@ class user extends session // Does the user need to change their password? If so, redirect to the // ucp profile reg_details page ... of course do not redirect if we're already in the ucp - if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && $this->data['is_registered'] && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) + if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) { if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") { -- cgit v1.2.1 From 8d106c79c54a4b870c65112fc50dbb2dd755936a Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Wed, 24 Jun 2009 03:11:20 +0000 Subject: Fixed Bug #15085 - [Feature] Add language selection on the registration terms page Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9666 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_register.php | 49 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index e0dc0222f5..b2bcc794f7 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -52,7 +52,6 @@ class ucp_register add_form_key('ucp_register_terms'); } - if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); @@ -67,7 +66,7 @@ class ucp_register $agreed = (empty($_GET['change_lang'])) ? 0 : $agreed; } - $user->lang_name = $lang = $use_lang; + $user->lang_name = $user_lang = $use_lang; $user->lang = array(); $user->add_lang(array('common', 'ucp')); } @@ -78,17 +77,26 @@ class ucp_register } } + $captcha_solved = false; + if ($config['enable_confirm']) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_REG); + } + $cp = new custom_profile(); $error = $cp_data = $cp_error = array(); - if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) { $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; - $s_hidden_fields = array(); + $s_hidden_fields = array( + 'change_lang' => $change_lang, + ); // If we change the language, we want to pass on some more possible parameter. if ($change_lang) @@ -108,6 +116,17 @@ class ucp_register } } + // Checking amount of available languages + $lang_row = array(); + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $lang_row[] = $row; + } + $db->sql_freeresult($result); + if ($coppa === false && $config['coppa_enable']) { $now = getdate(); @@ -115,6 +134,7 @@ class ucp_register unset($now); $template->assign_vars(array( + 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), @@ -129,6 +149,7 @@ class ucp_register else { $template->assign_vars(array( + 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 'S_SHOW_COPPA' => false, @@ -138,19 +159,12 @@ class ucp_register ) ); } + unset($lang_row); $this->tpl_name = 'ucp_agreement'; return; } - $captcha_solved = false; - if ($config['enable_confirm']) - { - include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_REG); - } - // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 $timezone = date('Z') / 3600; $is_dst = date('I'); @@ -430,7 +444,6 @@ class ucp_register $s_hidden_fields['coppa'] = $coppa; } - if ($config['enable_confirm']) { $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); @@ -441,15 +454,6 @@ class ucp_register // Visual Confirmation - Show images if ($config['enable_confirm'] && !$captcha_solved) { - if ($change_lang) - { - $str = '&change_lang=' . $change_lang; - } - else - { - $str = ''; - } - $template->assign_vars(array( 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), 'CAPTCHA_TEMPLATE' => $captcha->get_template(), @@ -484,6 +488,7 @@ class ucp_register 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_TZ_OPTIONS' => tz_select($data['tz']), 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, + 'S_REGISTRATION' => true, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), -- cgit v1.2.1 From f9bbf10a80c7a22a1ff59e30eef1cf9873e46516 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Jun 2009 10:08:18 +0000 Subject: - Fix XHTML for r9666 - Utilize $captcha->solved property - Only validate captcha once to retain captcha mode over switching from/to agreement page git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9668 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 +++- phpBB/includes/ucp/ucp_register.php | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 12b9363ec4..30bdc9abce 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2265,7 +2265,7 @@ function reapply_sid($url) { // All kind of links $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); - // if the sid was the first param, make the old second as first ones + // if the sid was the first param, make the old second as first ones $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); } @@ -3844,6 +3844,8 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), + 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), + 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.$phpEx", diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index b2bcc794f7..aa3e00685e 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -51,7 +51,7 @@ class ucp_register { add_form_key('ucp_register_terms'); } - + if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); @@ -77,12 +77,18 @@ class ucp_register } } - $captcha_solved = false; + $vc_response = false; if ($config['enable_confirm']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REG); + + // If confirm id is submitted we check the status of the captcha here + if (request_var('confirm_code', '')) + { + $vc_response = $captcha->validate(); + } } $cp = new custom_profile(); @@ -117,10 +123,11 @@ class ucp_register } // Checking amount of available languages - $lang_row = array(); - $sql = 'SELECT lang_id + $sql = 'SELECT lang_id FROM ' . LANG_TABLE; $result = $db->sql_query($sql); + + $lang_row = array(); while ($row = $db->sql_fetchrow($result)) { $lang_row[] = $row; @@ -223,16 +230,10 @@ class ucp_register if ($config['enable_confirm']) { - $vc_response = $captcha->validate(); - if ($vc_response) + if (!$captcha->solved) { $error[] = $vc_response; } - else - { - $captcha_solved = true; - // $captcha->reset(); - } if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) { @@ -443,7 +444,7 @@ class ucp_register { $s_hidden_fields['coppa'] = $coppa; } - + if ($config['enable_confirm']) { $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); @@ -452,7 +453,7 @@ class ucp_register $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm'] && !$captcha_solved) + if ($config['enable_confirm'] && !$captcha->solved) { $template->assign_vars(array( 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), -- cgit v1.2.1 From 08a88fcf33693d4349d3fb478ce4704d70ba3111 Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Wed, 24 Jun 2009 13:31:04 +0000 Subject: [Feature] Add confirmation for deactivating language packs Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9669 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_language.php | 43 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 3eee702b1d..8ca45a27f6 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -766,28 +766,41 @@ class acp_language trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING); } - $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); + if (confirm_box(true)) + { + $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lang = '" . $db->sql_escape($config['default_lang']) . "' - WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; - $db->sql_query($sql); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lang = '" . $db->sql_escape($config['default_lang']) . "' + WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; + $db->sql_query($sql); - // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we? - $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; - $db->sql_query($sql); + // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we? + $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; + $db->sql_query($sql); - $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; - $db->sql_query($sql); + $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; + $db->sql_query($sql); - $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; - $result = $db->sql_query($sql); + $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; + $result = $db->sql_query($sql); - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); - add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); + add_log('admin', 'LOG_LANGUAGE_PACK_DELETED', $row['lang_english_name']); - trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action)); + trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action)); + } + else + { + $s_hidden_fields = array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'id' => $lang_id, + ); + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); + } break; case 'install': -- cgit v1.2.1 From 9c795870f9c8d5569365d9df9cc7207988dcb609 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Jun 2009 21:13:53 +0000 Subject: Fix bug #37285 - [Change] Add quote-button for own pm's in pm-history Authorised by: ToonArmy git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9671 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 96400ad70d..271cce9f42 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1781,7 +1781,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $decoded_message = false; - if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) + if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) { $decoded_message = $message; decode_message($decoded_message, $row['bbcode_uid']); @@ -1824,7 +1824,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode 'MSG_ID' => $row['msg_id'], 'U_VIEW_MESSAGE' => "$url&f=$folder_id&p=" . $row['msg_id'], - 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', + 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '') ); unset($rowset[$i]); -- cgit v1.2.1 From b4c17b3732659991e979b989327fe375a9218df0 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 25 Jun 2009 08:26:51 +0000 Subject: We have to use the documented API git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9672 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 18 ++++++++++++++---- phpBB/includes/ucp/ucp_register.php | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 6962100945..e23cfd0de0 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -30,7 +30,7 @@ class phpbb_default_captcha var $seed; var $attempts = 0; var $type; - var $solved = false; + var $solved = 0; var $captcha_vars = false; function init($type) @@ -223,7 +223,7 @@ class phpbb_default_captcha $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->confirm_id = md5(unique_id($user->ip)); $this->seed = hexdec(substr(unique_id(), 4, 10)); - $this->solved = false; + $this->solved = 0; // compute $seed % 0x7fffffff $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); @@ -246,7 +246,7 @@ class phpbb_default_captcha $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); - $this->solved = false; + $this->solved = 0; // compute $seed % 0x7fffffff $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); @@ -268,7 +268,7 @@ class phpbb_default_captcha $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); - $this->solved = false; + $this->solved = 0; // compute $seed % 0x7fffffff $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); @@ -342,6 +342,16 @@ class phpbb_default_captcha // we leave the class usable by generating a new question $this->generate_code(); } + + function is_solved() + { + if ($this->solved === 0) + { + $this->validate(); + } + return (bool) $this->solved; + } + } ?> \ No newline at end of file diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index aa3e00685e..8192f5489b 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -230,7 +230,7 @@ class ucp_register if ($config['enable_confirm']) { - if (!$captcha->solved) + if (!$captcha->is_solved()) { $error[] = $vc_response; } @@ -453,7 +453,7 @@ class ucp_register $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm'] && !$captcha->solved) + if ($config['enable_confirm'] && !$captcha->is_solved()) { $template->assign_vars(array( 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), -- cgit v1.2.1 From 7ca31ace1a023c910470208abec219b1c03923ac Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Jun 2009 10:39:36 +0000 Subject: fix r9652 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9673 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_permissions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 077a3d7c83..8e03a7fa52 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -254,6 +254,16 @@ class acp_permissions } else { + if (isset($_POST['cancel'])) + { + $u_redirect = $this->u_action . '&type=' . $permission_type; + foreach ($forum_id as $fid) + { + $u_redirect .= '&forum_id[]=' . $fid; + } + redirect($u_redirect); + } + $s_hidden_fields = array( 'i' => $id, 'mode' => $mode, -- cgit v1.2.1 From 1c0df0dc91dcfb603cfb653e7daaf03257ac5495 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 25 Jun 2009 17:57:57 +0000 Subject: revert r9653 because it does not work as advertised (a load of bugs and not really what we wanted... back to the drawing board ;)) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9674 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 30bdc9abce..25bef4557a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3840,7 +3840,6 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), - 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), -- cgit v1.2.1 From d39d8481cfd6a9cd1e418aaff14833a149770e71 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 26 Jun 2009 10:07:59 +0000 Subject: Change bug #39505 - Pm history only shows pms of the receipts you currently reply to Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9677 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 271cce9f42..8851b53680 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1691,12 +1691,29 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode { global $db, $user, $config, $template, $phpbb_root_path, $phpEx, $auth, $bbcode; + // Select all receipts and the author from the pm we currently view, to only display their pm-history + $sql = 'SELECT author_id, user_id + FROM ' . PRIVMSGS_TO_TABLE . " + WHERE msg_id = $msg_id + AND folder_id <> " . PRIVMSGS_HOLD_BOX; + $result = $db->sql_query($sql); + + $recipients = array(); + while ($row = $db->sql_fetchrow($result)) + { + $recipients[] = $row['user_id']; + $recipients[] = $row['author_id']; + } + $db->sql_freeresult($result); + $recipients = array_unique($recipients); + // Get History Messages (could be newer) $sql = 'SELECT t.*, p.*, u.* FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u WHERE t.msg_id = p.msg_id AND p.author_id = u.user_id - AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ") + AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') + AND ' . $db->sql_in_set('t.author_id', $recipients) . " AND t.user_id = $user_id"; if (!$message_row['root_level']) -- cgit v1.2.1 From 5d6dca16a7b7e9c043570139c90b97c83a01bb5e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 26 Jun 2009 10:47:19 +0000 Subject: Fix bug #47345 - Check if template file is empty before trying to read from it. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9682 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_styles.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 16b1852cd6..ab9ddc0b6f 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -2556,9 +2556,22 @@ parse_css_file = {PARSE_CSS_FILE} { trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR); } - $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$template_path$pathfile$file")); + + $filesize = filesize("{$phpbb_root_path}styles/$template_path$pathfile$file"); + + if ($filesize) + { + $template_data = fread($fp, $filesize); + } + fclose($fp); + if (!$filesize) + { + // File is empty + continue; + } + if (preg_match_all('##is', $template_data, $matches)) { foreach ($matches[1] as $match) -- cgit v1.2.1 From 89ddc4543f987f4edda07e7a09552a2e93dc238a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 26 Jun 2009 11:38:29 +0000 Subject: Fix bug #38395 - Loading draft removes recipients when replying to PM Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9685 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 4 ++-- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e0dc128583..18bb432769 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -818,7 +818,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a /** * Load Drafts */ -function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) +function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $msg_id = 0) { global $user, $db, $template, $auth; global $phpbb_root_path, $phpEx; @@ -911,7 +911,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) { // Either display as PM draft if forum_id and topic_id are empty or if access to the forums has been denied afterwards... $link_pm = true; - $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}"); + $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" . (($pm_action) ? "&action=$pm_action" : '') . (($msg_id) ? "&p=$msg_id" : '')); } $template->assign_block_vars('draftrow', array( diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 008d8d6c88..85e43dfc8c 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -631,7 +631,7 @@ function compose_pm($id, $mode, $action) // Load Drafts if ($load && $drafts) { - load_drafts(0, 0, $id); + load_drafts(0, 0, $id, $action, $msg_id); } if ($submit || $preview || $refresh) -- cgit v1.2.1 From d61574a61e4b46f8c7ad0e75f0e2261ab8405670 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 26 Jun 2009 20:18:05 +0000 Subject: Okay it should work again. Thanks Raimon. In the future, please test if your changes are really a good idea. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9694 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_register.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 8192f5489b..ef6b076ebc 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -77,19 +77,6 @@ class ucp_register } } - $vc_response = false; - if ($config['enable_confirm']) - { - include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_REG); - - // If confirm id is submitted we check the status of the captcha here - if (request_var('confirm_code', '')) - { - $vc_response = $captcha->validate(); - } - } $cp = new custom_profile(); @@ -171,6 +158,15 @@ class ucp_register $this->tpl_name = 'ucp_agreement'; return; } + + + // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. + if ($config['enable_confirm']) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_REG); + } // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 $timezone = date('Z') / 3600; @@ -230,7 +226,8 @@ class ucp_register if ($config['enable_confirm']) { - if (!$captcha->is_solved()) + $vc_response = $captcha->validate(); + if (!$captcha->is_solved() && $vc_response) { $error[] = $vc_response; } -- cgit v1.2.1 From 076067f85649e53c77aceddf68b469ef59a294ca Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 26 Jun 2009 20:58:36 +0000 Subject: Okay, okay, I see the issue. I'll revisit this tomorrow. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9695 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 11 +++++------ phpBB/includes/ucp/ucp_register.php | 4 ---- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index e23cfd0de0..c6de2ff887 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -38,13 +38,12 @@ class phpbb_default_captcha global $config, $db, $user; // read input - $this->confirm_id = request_var('confirm_id', ''); $this->confirm_code = request_var('confirm_code', ''); $refresh = request_var('refresh_vc', false) && $config['confirm_refresh']; $this->type = (int) $type; - if (!strlen($this->confirm_id) || !$this->load_code()) + if (!$this->load_code()) { // we have no confirm ID, better get ready to display something $this->generate_code(); @@ -205,6 +204,7 @@ class phpbb_default_captcha { // okay, incorrect answer. Let's ask a new question. $this->new_attempt(); + $this->solved = false; return $error; } else @@ -277,7 +277,6 @@ class phpbb_default_captcha 'seed' => (int) $this->seed)) . ' , attempts = attempts + 1 WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } @@ -289,10 +288,9 @@ class phpbb_default_captcha { global $db, $user; - $sql = 'SELECT code, seed, attempts + $sql = 'SELECT code, confirm_id, seed, attempts FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . $this->type; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); @@ -300,6 +298,7 @@ class phpbb_default_captcha if ($row) { + $this->confirm_id = $row['confirm_id']; $this->code = $row['code']; $this->seed = $row['seed']; $this->attempts = $row['attempts']; diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index ef6b076ebc..a802a35b87 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -103,10 +103,6 @@ class ucp_register 'tz' => request_var('tz', (float) $config['board_timezone']), )); - if ($config['enable_confirm']) - { - $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); - } } // Checking amount of available languages -- cgit v1.2.1 From adaeec1ec9f7cd55522a5c4d0bf0538dbc0c6f99 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sat, 27 Jun 2009 08:36:40 +0000 Subject: Fixed Bug #45115 - Signature parsing flags are not stored in DB Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9696 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 15 ++++++++++++--- phpBB/includes/functions_user.php | 2 +- phpBB/includes/session.php | 4 ++-- phpBB/includes/ucp/ucp_profile.php | 15 ++++++++++++--- 4 files changed, 27 insertions(+), 9 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index fd64025565..c663103e17 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1545,9 +1545,9 @@ class acp_users include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); - $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false; - $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; + $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $this->optionget($user_row, 'sig_bbcode') : false; + $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $this->optionget($user_row, 'sig_smilies') : false; + $enable_urls = ($config['allow_sig_links']) ? (bool) $this->optionget($user_row, 'sig_links') : false; $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); $preview = (isset($_POST['preview'])) ? true : false; @@ -1556,6 +1556,10 @@ class acp_users { include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); + $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; + $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; + $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; + $message_parser = new parse_message($signature); // Allowing Quote BBCode @@ -1573,8 +1577,13 @@ class acp_users if (!sizeof($error) && $submit) { + $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); + $this->optionset($user_row, 'sig_smilies', $enable_smilies); + $this->optionset($user_row, 'sig_links', $enable_urls); + $sql_ary = array( 'user_sig' => (string) $message_parser->message, + 'user_options' => $user_row['user_options'], 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield ); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index bb54a14262..4ea094e451 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -187,7 +187,7 @@ function user_add($user_row, $cp_data = false) 'user_ip' => '', 'user_regdate' => time(), 'user_passchg' => time(), - 'user_options' => 895, + 'user_options' => 230271, // We do not set the new flag here - registration scripts need to specify it 'user_new' => 0, diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index c1bc4b3f31..9ae5a7c793 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1431,8 +1431,8 @@ class user extends session var $img_lang; var $img_array = array(); - // Able to add new option (id 7) - var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10); + // Able to add new options (up to id 31) + var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); var $keyvalues = array(); /** diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index e2a9699acc..d93567c543 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -456,9 +456,9 @@ class ucp_profile include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false; - $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; + $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false; + $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false; + $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false; $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true)); @@ -468,6 +468,10 @@ class ucp_profile { include($phpbb_root_path . 'includes/message_parser.' . $phpEx); + $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; + $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; + $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; + if (!sizeof($error)) { $message_parser = new parse_message($signature); @@ -487,8 +491,13 @@ class ucp_profile if (!sizeof($error) && $submit) { + $user->optionset('sig_bbcode', $enable_bbcode); + $user->optionset('sig_smilies', $enable_smilies); + $user->optionset('sig_links', $enable_urls); + $sql_ary = array( 'user_sig' => (string) $message_parser->message, + 'user_options' => $user->data['user_options'], 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield ); -- cgit v1.2.1 From 6273718dc5a7812b980ca45b20d123e5e0908026 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 27 Jun 2009 20:56:49 +0000 Subject: acp module for submitting statistical information to phpBB git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9698 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_ranks.php | 2 +- phpBB/includes/acp/acp_send_statistics.php | 93 +++++++++++++ phpBB/includes/acp/info/acp_send_statistics.php | 37 +++++ phpBB/includes/questionnaire/questionnaire.php | 152 +++++++++++++++++++++ .../includes/questionnaire/questionnaire_phpbb.php | 122 +++++++++++++++++ 5 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/acp/acp_send_statistics.php create mode 100644 phpBB/includes/acp/info/acp_send_statistics.php create mode 100644 phpBB/includes/questionnaire/questionnaire.php create mode 100644 phpBB/includes/questionnaire/questionnaire_phpbb.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index a1a10545ef..fcfef2a61e 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -39,7 +39,7 @@ class acp_ranks $this->tpl_name = 'acp_ranks'; $this->page_title = 'ACP_MANAGE_RANKS'; - $form_name = 'acp_prune'; + $form_name = 'acp_ranks'; add_form_key($form_name); switch ($action) diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php new file mode 100644 index 0000000000..4bfacfdb50 --- /dev/null +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -0,0 +1,93 @@ +tpl_name = 'acp_send_statistics'; + $this->page_title = 'ACP_SEND_STATISTICS'; + + $c = new Questionnaire_Data_Collector(); + $c->addDataProvider(new Questionnaire_PHP_Data_Provider()); + $c->addDataProvider(new Questionnaire_System_Data_Provider()); + $c->addDataProvider(new questionnaire_phpbb_data_provider($config)); + + $template->assign_vars(array( + 'U_COLLECT_STATS' => $collect_url, + 'RAW_DATA' => $c->getDataForForm(), + )); + + $raw = $c->getDataRaw(); + + foreach ($raw as $provider => $data) + { + $template->assign_block_vars('providers', array( + 'NAME' => htmlentities($provider), + )); + + foreach ($data as $key => $value) + { + if (is_array($value)) + { + $value = utf8_wordwrap(serialize($value), 75, "\n", true); + } + + $template->assign_block_vars('providers.values', array( + 'KEY' => htmlentities($key), + 'VALUE' => htmlentities($value), + )); + } + } + } + + /** + * Output the data as an HTML Definition List. + * + * @param mixed + * @param string + * @param string + * @return void + */ + function data_printer($value, $key) + { + echo '
', htmlentities($key), '
', $ident, "\t", '
'; + if (is_array($value)) + { + $value = htmlentities(serialize($value)); + echo '
'; + echo '
'; + } else { + echo htmlentities($value); + } + echo '
'; + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/acp/info/acp_send_statistics.php b/phpBB/includes/acp/info/acp_send_statistics.php new file mode 100644 index 0000000000..33e66ecd26 --- /dev/null +++ b/phpBB/includes/acp/info/acp_send_statistics.php @@ -0,0 +1,37 @@ + 'acp_send_statistics', + 'title' => 'ACP_SEND_STATISTICS', + 'version' => '1.0.0', + 'modes' => array( + 'questionnaire' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php new file mode 100644 index 0000000000..7eeb4e4113 --- /dev/null +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -0,0 +1,152 @@ + PHP_VERSION, + 'sapi' => PHP_SAPI, + 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', + 'safe_mode' => (int)ini_get('safe_mode'), + 'open_basedir' => (int)ini_get('open_basedir'), + 'memory_limit' => ini_get('memory_limit'), + 'allow_url_fopen' => (int)ini_get('allow_url_fopen'), + 'allow_url_include' => (int)ini_get('allow_url_include'), + 'file_uploads' => (int)ini_get('file_uploads'), + 'upload_max_filesize' => ini_get('upload_max_filesize'), + 'post_max_size' => ini_get('post_max_size'), + 'disable_functions' => ini_get('disable_functions'), + 'disable_classes' => ini_get('disable_classes'), + 'enable_dl' => (int)ini_get('enable_dl'), + 'magic_quotes_gpc' => (int)ini_get('magic_quotes_gpc'), + 'register_globals' => (int)ini_get('register_globals'), + 'filter.default' => ini_get('filter.default'), + 'zend.ze1_compatibility_mode' => (int)ini_get('zend.ze1_compatibility_mode'), + 'unicode.semantics' => (int)ini_get('unicode.semantics'), + 'zend_thread_safty' => (int)function_exists('zend_thread_id'), + 'extensions' => get_loaded_extensions() + ); + } +} + + +class Questionnaire_System_Data_Provider +{ + function getIdentifier() + { + return 'System'; + } + + /** + * Get data about the general system information, like OS or IP (shortened). + * + * @return array + */ + function getData() + { + // Start discovering the IPV4 server address, if available + $serverAddress = '0.0.0.0'; + if (isset($_SERVER['SERVER_ADDR'])) { + $serverAddress = $_SERVER['SERVER_ADDR']; + } + // Running on IIS? + if (isset($_SERVER['LOCAL_ADDR'])) { + $serverAddress = $_SERVER['LOCAL_ADDR']; + } + $aIPAddress = explode('.', $serverAddress); + + return array( + 'os' => PHP_OS, + 'httpd' => $_SERVER['SERVER_SOFTWARE'], + // we don't want the real IP address (for privacy policy reasons) but only + // a network address to see whether your installation is running on a private or public network. + // IANA reserved addresses for private networks (RFC 1918) are: + // - 10.0.0.0/8 + // - 172.16.0.0/12 + // - 192.168.0.0/16 + 'ip' => $aIPAddress[0].'.'.$aIPAddress[1].'.XXX.YYY' + ); + } +} + +/** + * This class collects data which is used to create some usage statistics. + * + * The collected data is - after authorization of the administrator - submitted + * to a central server. For privacy reasons we try to collect only data which aren't private + * or don't give any information which might help to identify the user. + * + * @author Johannes Schlueter + * @copyright (c) 2007-2008 Johannes Schlueter + */ + +class Questionnaire_Data_Collector +{ + var $providers; + var $data = null; + + /** + * Constructor. + * + * @param array + * @param string + */ + function __construct() + { + $this->providers = array(); + } + + function addDataProvider(&$provider) + { + $this->providers[] = &$provider; + } + + /** + * Get data as an array. + * + * @return array All Data + */ + function getDataRaw() + { + if (!$this->data) { + $this->collect(); + } + + return $this->data; + } + + function getDataForForm() + { + return base64_encode(serialize($this->getDataRaw())); + } + + /** + * Collect info into the data property. + * + * @return void + */ + function collect() + { + foreach (array_keys($this->providers) as $key) { + $provider = &$this->providers[$key]; + $this->data[$provider->getIdentifier()] = $provider->getData(); + } + } +} diff --git a/phpBB/includes/questionnaire/questionnaire_phpbb.php b/phpBB/includes/questionnaire/questionnaire_phpbb.php new file mode 100644 index 0000000000..7c2ce4c292 --- /dev/null +++ b/phpBB/includes/questionnaire/questionnaire_phpbb.php @@ -0,0 +1,122 @@ +unique_id = unique_id(); + set_config('questionnaire_unique_id', $this->unique_id); + } + else + { + $this->unique_id = $config['questionnaire_unique_id']; + } + + $this->config = $config; + } + + /** + * Returns a string identifier for this data provider + * + * @return string "phpBB" + */ + function getIdentifier() + { + return 'phpBB'; + } + + + /** + * Get data about this phpBB installation. + * + * @return array Relevant anonymous config options + */ + function getData() + { + + // Exclude certain config vars + $exclude_config_vars = array( + 'avatar_gallery_path' => true, + 'avatar_path' => true, + 'avatar_salt' => true, + 'board_contact' => true, + 'board_disable_msg' => true, + 'board_email' => true, + 'board_email_sig' => true, + 'cookie_name' => true, + 'icons_path' => true, + 'icons_path' => true, + 'jab_host' => true, + 'jab_password' => true, + 'jab_port' => true, + 'jab_username' => true, + 'ldap_base_dn' => true, + 'ldap_email' => true, + 'ldap_password' => true, + 'ldap_port' => true, + 'ldap_server' => true, + 'ldap_uid' => true, + 'ldap_user' => true, + 'ldap_user_filter' => true, + 'ranks_path' => true, + 'script_path' => true, + 'server_name' => true, + 'server_port' => true, + 'server_protocol' => true, + 'site_desc' => true, + 'sitename' => true, + 'smilies_path' => true, + 'smtp_host' => true, + 'smtp_password' => true, + 'smtp_port' => true, + 'smtp_username' => true, + 'upload_icons_path' => true, + 'upload_path' => true, + 'newest_user_colour' => true, + 'newest_user_id' => true, + 'newest_username' => true, + 'rand_seed' => true, + ); + + $result = array(); + foreach ($this->config as $name => $value) + { + if (!isset($exclude_config_vars[$name])) + { + $result['config.' . $name] = $value; + } + } + + return $result; + } +} \ No newline at end of file -- cgit v1.2.1 From b07b30f55d872b8e7450fe954964ebf534ac2092 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 27 Jun 2009 21:08:42 +0000 Subject: did not have auto props on this machine - removed an unused function from the new acp file git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9699 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_send_statistics.php | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index 4bfacfdb50..1549157041 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -2,7 +2,7 @@ /** * * @package acp -* @version $Id: acp_ranks.php 8479 2008-03-29 00:22:48Z naderman $ +* @version $Id$ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -66,28 +66,6 @@ class acp_send_statistics } } } - - /** - * Output the data as an HTML Definition List. - * - * @param mixed - * @param string - * @param string - * @return void - */ - function data_printer($value, $key) - { - echo '
', htmlentities($key), '
', $ident, "\t", '
'; - if (is_array($value)) - { - $value = htmlentities(serialize($value)); - echo '
'; - echo '
'; - } else { - echo htmlentities($value); - } - echo '
'; - } } ?> \ No newline at end of file -- cgit v1.2.1 From 494054838963df6cab6f25302f12d78156202698 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 27 Jun 2009 21:10:14 +0000 Subject: - forgot to remove __construct methods when making this PHP4 compatible git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9700 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/questionnaire/questionnaire.php | 2 +- phpBB/includes/questionnaire/questionnaire_phpbb.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 7eeb4e4113..811b26cf20 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -108,7 +108,7 @@ class Questionnaire_Data_Collector * @param array * @param string */ - function __construct() + function Questionnaire_Data_Collector() { $this->providers = array(); } diff --git a/phpBB/includes/questionnaire/questionnaire_phpbb.php b/phpBB/includes/questionnaire/questionnaire_phpbb.php index 7c2ce4c292..47bd931e68 100644 --- a/phpBB/includes/questionnaire/questionnaire_phpbb.php +++ b/phpBB/includes/questionnaire/questionnaire_phpbb.php @@ -27,9 +27,8 @@ class questionnaire_phpbb_data_provider * Constructor. * * @param array $config - * @param string $oldversion */ - function __construct($config) + function questionnaire_phpbb_data_provider($config) { // generate a unique id if necessary if (!isset($config['questionnaire_unique_id'])) -- cgit v1.2.1 From e146efbd165c71b00003f6ae3ea3f4de2da3d64b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 29 Jun 2009 12:52:45 +0000 Subject: Add some data for akismet et al git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9702 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 4 ++-- phpBB/includes/ucp/ucp_register.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index c6de2ff887..86ecdaf97e 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -178,7 +178,7 @@ class phpbb_default_captcha return; } - function validate() + function validate($data = false) { global $config, $db, $user; @@ -344,7 +344,7 @@ class phpbb_default_captcha function is_solved() { - if ($this->solved === 0) + if (request_var('confirm_code', false) && $this->solved === 0) { $this->validate(); } diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index a802a35b87..da62061a72 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -222,8 +222,8 @@ class ucp_register if ($config['enable_confirm']) { - $vc_response = $captcha->validate(); - if (!$captcha->is_solved() && $vc_response) + $vc_response = $captcha->validate($data); + if ($vc_response) { $error[] = $vc_response; } -- cgit v1.2.1 From 1c5e724e5ecbf3a9e36d3e34dd50f4cd3134f696 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 29 Jun 2009 14:36:05 +0000 Subject: undoing change from #9575, as it broke the board disabled message git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9704 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 41849b909a..008594a319 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -437,7 +437,7 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if ($null === false || strpos($config_name, 'legend') !== false) + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } -- cgit v1.2.1 From 5f89b6a6d085701a0f999feb15879a62148f6fac Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 30 Jun 2009 14:00:27 +0000 Subject: *blinks* there were supposed to be more files, where are they? Ah, here git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9707 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 86ecdaf97e..2a93b3f895 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -38,12 +38,13 @@ class phpbb_default_captcha global $config, $db, $user; // read input + $this->confirm_id = request_var('confirm_id', ''); $this->confirm_code = request_var('confirm_code', ''); $refresh = request_var('refresh_vc', false) && $config['confirm_refresh']; $this->type = (int) $type; - if (!$this->load_code()) + if (!strlen($this->confirm_id) || !$this->load_code()) { // we have no confirm ID, better get ready to display something $this->generate_code(); @@ -95,6 +96,7 @@ class phpbb_default_captcha 'CONFIRM_IMG' => '', 'CONFIRM_ID' => $this->confirm_id, 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, 'L_CONFIRM_EXPLAIN' => $explain, )); @@ -178,7 +180,7 @@ class phpbb_default_captcha return; } - function validate($data = false) + function validate() { global $config, $db, $user; @@ -204,7 +206,6 @@ class phpbb_default_captcha { // okay, incorrect answer. Let's ask a new question. $this->new_attempt(); - $this->solved = false; return $error; } else @@ -277,6 +278,7 @@ class phpbb_default_captcha 'seed' => (int) $this->seed)) . ' , attempts = attempts + 1 WHERE + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } @@ -288,9 +290,10 @@ class phpbb_default_captcha { global $db, $user; - $sql = 'SELECT code, confirm_id, seed, attempts + $sql = 'SELECT code, seed, attempts FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . $this->type; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); @@ -298,7 +301,6 @@ class phpbb_default_captcha if ($row) { - $this->confirm_id = $row['confirm_id']; $this->code = $row['code']; $this->seed = $row['seed']; $this->attempts = $row['attempts']; -- cgit v1.2.1 From 7d22229045484897246e70cf7208a13af34c7531 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 30 Jun 2009 14:23:16 +0000 Subject: a bit of text git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9709 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 2a93b3f895..fb64063a90 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -255,8 +255,8 @@ class phpbb_default_captcha 'code' => (string) $this->code, 'seed' => (int) $this->seed)) . ' WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND - session_id = \'' . $db->sql_escape($user->session_id) . '\''; + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } @@ -278,8 +278,8 @@ class phpbb_default_captcha 'seed' => (int) $this->seed)) . ' , attempts = attempts + 1 WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND - session_id = \'' . $db->sql_escape($user->session_id) . '\''; + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } @@ -293,7 +293,7 @@ class phpbb_default_captcha $sql = 'SELECT code, seed, attempts FROM ' . CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . $this->type; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); -- cgit v1.2.1 From 2854705096a5029295ab99fa9fcf063661fc2cbc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 2 Jul 2009 10:28:32 +0000 Subject: Fix bug #36565 - Search by authorname does not display posts of guests and deleted users Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9713 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/search/fulltext_mysql.php | 56 +++++++++++++++++------- phpBB/includes/search/fulltext_native.php | 71 ++++++++++++++++++++----------- 2 files changed, 87 insertions(+), 40 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index e1e7951367..456a11f24e 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -324,16 +324,17 @@ class fulltext_mysql extends search_backend * Performs a search on keywords depending on display specific params. You have to run split_keywords() first. * * @param string $type contains either posts or topics depending on what should be searched for - * @param string &$fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string &$terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string &$sort_key is the key of $sort_by_sql for the selected sorting - * @param string &$sort_dir is either a or d representing ASC and DESC - * @param string &$sort_days specifies the maximum amount of days a post may be old - * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched - * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts - * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array &$author_ary an array of author ids if the author should be ignored during the search the array is empty + * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) + * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) + * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query + * @param string $sort_key is the key of $sort_by_sql for the selected sorting + * @param string $sort_dir is either a or d representing ASC and DESC + * @param string $sort_days specifies the maximum amount of days a post may be old + * @param array $ex_fid_ary specifies an array of forum ids which should not be searched + * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched + * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty + * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered * @param int $start indicates the first index of the page * @param int $per_page number of ids each page is supposed to contain @@ -341,7 +342,7 @@ class fulltext_mysql extends search_backend * * @access public */ - function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) + function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { global $config, $db; @@ -440,14 +441,27 @@ class fulltext_mysql extends search_backend $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id'; $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - $sql_author = (sizeof($author_ary) == 1) ? ' = ' . $author_ary[0] : 'IN (' . implode(', ', $author_ary) . ')'; + if (sizeof($author_ary) && $author_name) + { + // first one matches post of registered users, second one guests and deleted users + $sql_author = ' AND (' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; + $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + } + else if (sizeof($author_ary)) + { + $sql_author = ' AND ' . $db->sql_in_set('p.poster_id', $author_ary); + } + else + { + $sql_author = ''; + } $sql_where_options = $sql_sort_join; $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; $sql_where_options .= $m_approve_fid_sql; - $sql_where_options .= (sizeof($author_ary)) ? ' AND p.poster_id ' . $sql_author : ''; + $sql_where_options .= $sql_author; $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_where_options .= $sql_match_where; @@ -500,7 +514,7 @@ class fulltext_mysql extends search_backend * @param int $per_page number of ids each page is supposed to contain * @return total number of results */ - function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) + function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { global $config, $db; @@ -522,7 +536,8 @@ class fulltext_mysql extends search_backend $topic_id, implode(',', $ex_fid_ary), implode(',', $m_approve_fid_ary), - implode(',', $author_ary) + implode(',', $author_ary), + $author_name, ))); // try reading the results from cache @@ -535,7 +550,16 @@ class fulltext_mysql extends search_backend $id_ary = array(); // Create some display specific sql strings - $sql_author = $db->sql_in_set('p.poster_id', $author_ary); + if ($author_name) + { + // first one matches post of registered users, second one guests and deleted users + $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; + $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + } + else + { + $sql_author = $db->sql_in_set('p.poster_id', $author_ary); + } $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 8df5ddfbae..513a16bc58 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -392,16 +392,17 @@ class fulltext_native extends search_backend * Performs a search on keywords depending on display specific params. You have to run split_keywords() first. * * @param string $type contains either posts or topics depending on what should be searched for - * @param string &$fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string &$terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string &$sort_key is the key of $sort_by_sql for the selected sorting - * @param string &$sort_dir is either a or d representing ASC and DESC - * @param string &$sort_days specifies the maximum amount of days a post may be old - * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched - * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts - * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array &$author_ary an array of author ids if the author should be ignored during the search the array is empty + * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) + * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) + * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query + * @param string $sort_key is the key of $sort_by_sql for the selected sorting + * @param string $sort_dir is either a or d representing ASC and DESC + * @param string $sort_days specifies the maximum amount of days a post may be old + * @param array $ex_fid_ary specifies an array of forum ids which should not be searched + * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched + * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty + * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered * @param int $start indicates the first index of the page * @param int $per_page number of ids each page is supposed to contain @@ -409,7 +410,7 @@ class fulltext_native extends search_backend * * @access public */ - function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) + function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { global $config, $db; @@ -432,7 +433,8 @@ class fulltext_native extends search_backend $topic_id, implode(',', $ex_fid_ary), implode(',', $m_approve_fid_ary), - implode(',', $author_ary) + implode(',', $author_ary), + $author_name, ))); // try reading the results from cache @@ -623,7 +625,17 @@ class fulltext_native extends search_backend if (sizeof($author_ary)) { - $sql_where[] = $db->sql_in_set('p.poster_id', $author_ary); + if ($author_name) + { + // first one matches post of registered users, second one guests and deleted users + $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; + $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + } + else + { + $sql_author = $db->sql_in_set('p.poster_id', $author_ary); + } + $sql_where[] = $sql_author; } if (sizeof($ex_fid_ary)) @@ -773,14 +785,15 @@ class fulltext_native extends search_backend * * @param string $type contains either posts or topics depending on what should be searched for * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array &$sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string &$sort_key is the key of $sort_by_sql for the selected sorting - * @param string &$sort_dir is either a or d representing ASC and DESC - * @param string &$sort_days specifies the maximum amount of days a post may be old - * @param array &$ex_fid_ary specifies an array of forum ids which should not be searched - * @param array &$m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts - * @param int &$topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array &$author_ary an array of author ids + * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query + * @param string $sort_key is the key of $sort_by_sql for the selected sorting + * @param string $sort_dir is either a or d representing ASC and DESC + * @param string $sort_days specifies the maximum amount of days a post may be old + * @param array $ex_fid_ary specifies an array of forum ids which should not be searched + * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched + * @param array $author_ary an array of author ids + * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered * @param int $start indicates the first index of the page * @param int $per_page number of ids each page is supposed to contain @@ -788,7 +801,7 @@ class fulltext_native extends search_backend * * @access public */ - function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page) + function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { global $config, $db; @@ -810,7 +823,8 @@ class fulltext_native extends search_backend $topic_id, implode(',', $ex_fid_ary), implode(',', $m_approve_fid_ary), - implode(',', $author_ary) + implode(',', $author_ary), + $author_name, ))); // try reading the results from cache @@ -823,7 +837,16 @@ class fulltext_native extends search_backend $id_ary = array(); // Create some display specific sql strings - $sql_author = $db->sql_in_set('p.poster_id', $author_ary); + if ($author_name) + { + // first one matches post of registered users, second one guests and deleted users + $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; + $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + } + else + { + $sql_author = $db->sql_in_set('p.poster_id', $author_ary); + } $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; -- cgit v1.2.1 From 3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 6 Jul 2009 13:10:05 +0000 Subject: Add a purge option for the session table to the acp. Seems that many boards get unusable due to styles not embedding the cron image and/or extremely long session timeout settings and/or DOS attacks. This new button can be a stopgap measure in those cases. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9714 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 5d6bd40681..42f6aa0b8e 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -97,6 +97,10 @@ class acp_main $confirm = true; $confirm_lang = 'PURGE_CACHE_CONFIRM'; break; + case 'purge_sessions': + $confirm = true; + $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; + break; default: $confirm = true; @@ -341,6 +345,44 @@ class acp_main add_log('admin', 'LOG_PURGE_CACHE'); break; + + case 'purge_sessions': + if ((int) $user->data['user_type'] !== USER_FOUNDER) + { + trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); + + // DELETE would probably take a lot longer if we're dealing with a runaway table + foreach ($tables as $table) + { + $sql = "TRUNCATE TABLE $table"; + $db->sql_query($sql); + } + + // let's restore the admin session + $reinsert_ary = array( + 'session_id' => (string) $user->session_id, + 'session_page' => (string) substr($user->page['page'], 0, 199), + 'session_forum_id' => $user->page['forum'], + 'session_user_id' => (int) $user->data['user_id'], + 'session_start' => (int) $user->data['session_start'], + 'session_last_visit' => (int) $user->data['session_last_visit'], + 'session_time' => (int) $user->time_now, + 'session_browser' => (string) trim(substr($user->browser, 0, 149)), + 'session_forwarded_for' => (string) $user->forwarded_for, + 'session_ip' => (string) $user->ip, + 'session_autologin' => (int) $user->data['session_autologin'], + 'session_admin' => 1, + 'session_viewonline' => (int) $user->data['session_viewonline'], + ); + + $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); + $db->sql_query($sql); + + add_log('admin', 'LOG_PURGE_SESSIONS'); + break; } } } -- cgit v1.2.1 From 1d655f2f3e61a673573e5ea3cc863e34a1bb8eaa Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 6 Jul 2009 13:42:15 +0000 Subject: Fix an endless loop; don't return the sql array by reference git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9716 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_profile_fields.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index bb54e0de5b..abdae926bd 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -383,15 +383,16 @@ class custom_profile break; } + // use new array for the UPDATE; changes in the key do not affect the original array + $cp_data_sql = array(); foreach ($cp_data as $key => $value) { // Firebird is case sensitive with delimiter - $cp_data[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value; - unset($cp_data[$key]); + $cp_data_sql[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value; } $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $cp_data) . " + SET ' . $db->sql_build_array('UPDATE', $cp_data_sql) . " WHERE user_id = $user_id"; $db->sql_query($sql); @@ -401,7 +402,7 @@ class custom_profile $db->sql_return_on_error(true); - $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); + $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data_sql); $db->sql_query($sql); $db->sql_return_on_error(false); -- cgit v1.2.1 From 62471fe5813329ebcee8de7d0e93c492ea1f8635 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 6 Jul 2009 13:42:43 +0000 Subject: Fix an endless loop; don't return the sql array by reference git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9717 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_profile_fields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index abdae926bd..bb1ec476c4 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -398,7 +398,7 @@ class custom_profile if (!$db->sql_affectedrows()) { - $cp_data['user_id'] = (int) $user_id; + $cp_data_sql['user_id'] = (int) $user_id; $db->sql_return_on_error(true); -- cgit v1.2.1 From fa84400d288374f9c702757cc619db815a65fefb Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 7 Jul 2009 09:22:01 +0000 Subject: restore firebird/sqlite support. TODO - the DBAL should handle this git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9718 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 42f6aa0b8e..e0d6a3f01c 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -354,11 +354,19 @@ class acp_main $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); - // DELETE would probably take a lot longer if we're dealing with a runaway table foreach ($tables as $table) { - $sql = "TRUNCATE TABLE $table"; - $db->sql_query($sql); + switch ($db->sql_layer) + { + case 'sqlite': + case 'firebird': + $db->sql_query("DELETE FROM $table"); + break; + + default: + $db->sql_query("TRUNCATE TABLE $table"); + break; + } } // let's restore the admin session -- cgit v1.2.1 From 59a5278c69250adf1b8459df45b7873613240a09 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 7 Jul 2009 09:29:00 +0000 Subject: merged questioinnaire and questionnaire_phpbb and adjusted all files to our coding guidelines... if we want to allow dropping in other providers we could add provider files to the questionnaire directory (and grab them), if not it is best to remove the questionnaire directory and put the file under includes/ git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9719 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_send_statistics.php | 22 +- phpBB/includes/questionnaire/questionnaire.php | 416 ++++++++++++++------- .../includes/questionnaire/questionnaire_phpbb.php | 121 ------ 3 files changed, 290 insertions(+), 269 deletions(-) delete mode 100644 phpBB/includes/questionnaire/questionnaire_phpbb.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index 1549157041..6c29b9fbb5 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -15,8 +15,8 @@ if (!defined('IN_PHPBB')) { exit; } -include($phpbb_root_path . 'includes/questionnaire/questionnaire_phpbb.' . $phpEx); +include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx); /** * @package acp @@ -34,22 +34,24 @@ class acp_send_statistics $this->tpl_name = 'acp_send_statistics'; $this->page_title = 'ACP_SEND_STATISTICS'; - $c = new Questionnaire_Data_Collector(); - $c->addDataProvider(new Questionnaire_PHP_Data_Provider()); - $c->addDataProvider(new Questionnaire_System_Data_Provider()); - $c->addDataProvider(new questionnaire_phpbb_data_provider($config)); + $collector = new phpbb_questionnaire_data_collector(); + + // Add data provider + $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); + $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); + $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); $template->assign_vars(array( 'U_COLLECT_STATS' => $collect_url, - 'RAW_DATA' => $c->getDataForForm(), + 'RAW_DATA' => $collector->get_data_for_form(), )); - $raw = $c->getDataRaw(); + $raw = $collector->get_data_raw(); foreach ($raw as $provider => $data) { $template->assign_block_vars('providers', array( - 'NAME' => htmlentities($provider), + 'NAME' => htmlspecialchars($provider), )); foreach ($data as $key => $value) @@ -60,8 +62,8 @@ class acp_send_statistics } $template->assign_block_vars('providers.values', array( - 'KEY' => htmlentities($key), - 'VALUE' => htmlentities($value), + 'KEY' => utf8_htmlspecialchars($key), + 'VALUE' => utf8_htmlspecialchars($value), )); } } diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 811b26cf20..42ac44d38a 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -1,152 +1,292 @@ +* @copyright (c) 2007-2008 Johannes Schlueter +*/ +class phpbb_questionnaire_data_collector { - function getIdentifier() - { - return 'PHP'; - } - - /** - * Get data about the PHP runtime setup. - * - * @return array - */ - function getData() - { - return array( - 'version' => PHP_VERSION, - 'sapi' => PHP_SAPI, - 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', - 'safe_mode' => (int)ini_get('safe_mode'), - 'open_basedir' => (int)ini_get('open_basedir'), - 'memory_limit' => ini_get('memory_limit'), - 'allow_url_fopen' => (int)ini_get('allow_url_fopen'), - 'allow_url_include' => (int)ini_get('allow_url_include'), - 'file_uploads' => (int)ini_get('file_uploads'), - 'upload_max_filesize' => ini_get('upload_max_filesize'), - 'post_max_size' => ini_get('post_max_size'), - 'disable_functions' => ini_get('disable_functions'), - 'disable_classes' => ini_get('disable_classes'), - 'enable_dl' => (int)ini_get('enable_dl'), - 'magic_quotes_gpc' => (int)ini_get('magic_quotes_gpc'), - 'register_globals' => (int)ini_get('register_globals'), - 'filter.default' => ini_get('filter.default'), - 'zend.ze1_compatibility_mode' => (int)ini_get('zend.ze1_compatibility_mode'), - 'unicode.semantics' => (int)ini_get('unicode.semantics'), - 'zend_thread_safty' => (int)function_exists('zend_thread_id'), - 'extensions' => get_loaded_extensions() - ); - } + var $providers; + var $data = null; + + /** + * Constructor. + * + * @param array + * @param string + */ + function phpbb_questionnaire_data_collector() + { + $this->providers = array(); + } + + function add_data_provider(&$provider) + { + $this->providers[] = &$provider; + } + + /** + * Get data as an array. + * + * @return array All Data + */ + function get_data_raw() + { + if (!$this->data) + { + $this->collect(); + } + + return $this->data; + } + + function get_data_for_form() + { + return base64_encode(serialize($this->get_data_raw())); + } + + /** + * Collect info into the data property. + * + * @return void + */ + function collect() + { + foreach (array_keys($this->providers) as $key) + { + $provider = &$this->providers[$key]; + $this->data[$provider->get_identifier()] = $provider->get_data(); + } + } } +/** interface: get_indentifier(), get_data() */ -class Questionnaire_System_Data_Provider +/** +* Questionnaire PHP data provider +* @package phpBB3 +*/ +class phpbb_questionnaire_php_data_provider { - function getIdentifier() - { - return 'System'; - } - - /** - * Get data about the general system information, like OS or IP (shortened). - * - * @return array - */ - function getData() - { - // Start discovering the IPV4 server address, if available - $serverAddress = '0.0.0.0'; - if (isset($_SERVER['SERVER_ADDR'])) { - $serverAddress = $_SERVER['SERVER_ADDR']; - } - // Running on IIS? - if (isset($_SERVER['LOCAL_ADDR'])) { - $serverAddress = $_SERVER['LOCAL_ADDR']; - } - $aIPAddress = explode('.', $serverAddress); - - return array( - 'os' => PHP_OS, - 'httpd' => $_SERVER['SERVER_SOFTWARE'], - // we don't want the real IP address (for privacy policy reasons) but only - // a network address to see whether your installation is running on a private or public network. - // IANA reserved addresses for private networks (RFC 1918) are: - // - 10.0.0.0/8 - // - 172.16.0.0/12 - // - 192.168.0.0/16 - 'ip' => $aIPAddress[0].'.'.$aIPAddress[1].'.XXX.YYY' - ); - } + function get_identifier() + { + return 'PHP'; + } + + /** + * Get data about the PHP runtime setup. + * + * @return array + */ + function get_data() + { + return array( + 'version' => PHP_VERSION, + 'sapi' => PHP_SAPI, + 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', + 'safe_mode' => (int) @ini_get('safe_mode'), + 'open_basedir' => (int) @ini_get('open_basedir'), + 'memory_limit' => @ini_get('memory_limit'), + 'allow_url_fopen' => (int) @ini_get('allow_url_fopen'), + 'allow_url_include' => (int) @ini_get('allow_url_include'), + 'file_uploads' => (int) @ini_get('file_uploads'), + 'upload_max_filesize' => @ini_get('upload_max_filesize'), + 'post_max_size' => @ini_get('post_max_size'), + 'disable_functions' => @ini_get('disable_functions'), + 'disable_classes' => @ini_get('disable_classes'), + 'enable_dl' => (int) @ini_get('enable_dl'), + 'magic_quotes_gpc' => (int) @ini_get('magic_quotes_gpc'), + 'register_globals' => (int) @ini_get('register_globals'), + 'filter.default' => @ini_get('filter.default'), + 'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'), + 'unicode.semantics' => (int) @ini_get('unicode.semantics'), + 'zend_thread_safty' => (int) function_exists('zend_thread_id'), + 'extensions' => get_loaded_extensions(), + ); + } } /** - * This class collects data which is used to create some usage statistics. - * - * The collected data is - after authorization of the administrator - submitted - * to a central server. For privacy reasons we try to collect only data which aren't private - * or don't give any information which might help to identify the user. - * - * @author Johannes Schlueter - * @copyright (c) 2007-2008 Johannes Schlueter - */ - -class Questionnaire_Data_Collector +* Questionnaire System data provider +* @package phpBB3 +*/ +class phpbb_questionnaire_system_data_provider { - var $providers; - var $data = null; - - /** - * Constructor. - * - * @param array - * @param string - */ - function Questionnaire_Data_Collector() - { - $this->providers = array(); - } - - function addDataProvider(&$provider) - { - $this->providers[] = &$provider; - } - - /** - * Get data as an array. - * - * @return array All Data - */ - function getDataRaw() - { - if (!$this->data) { - $this->collect(); - } - - return $this->data; - } - - function getDataForForm() - { - return base64_encode(serialize($this->getDataRaw())); - } - - /** - * Collect info into the data property. - * - * @return void - */ - function collect() - { - foreach (array_keys($this->providers) as $key) { - $provider = &$this->providers[$key]; - $this->data[$provider->getIdentifier()] = $provider->getData(); - } - } + function get_identifier() + { + return 'System'; + } + + /** + * Get data about the general system information, like OS or IP (shortened). + * + * @return array + */ + function get_data() + { + // Start discovering the IPV4 server address, if available + $server_address = '0.0.0.0'; + + if (!empty($_SERVER['SERVER_ADDR'])) + { + $server_address = $_SERVER['SERVER_ADDR']; + } + + // Running on IIS? + if (!empty($_SERVER['LOCAL_ADDR'])) + { + $server_address = $_SERVER['LOCAL_ADDR']; + } + + $ip_address_ary = explode('.', $server_address); + + // build ip + if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1])) + { + $ip_address_ary = explode('.', '0.0.0.0'); + } + + return array( + 'os' => PHP_OS, + 'httpd' => $_SERVER['SERVER_SOFTWARE'], + // we don't want the real IP address (for privacy policy reasons) but only + // a network address to see whether your installation is running on a private or public network. + // IANA reserved addresses for private networks (RFC 1918) are: + // - 10.0.0.0/8 + // - 172.16.0.0/12 + // - 192.168.0.0/16 + 'ip' => $ip_address_ary[0] . '.' . $ip_address_ary[1] . '.XXX.YYY', + ); + } +} + +/** +* Questionnaire phpBB data provider +* @package phpBB3 +*/ +class phpbb_questionnaire_phpbb_data_provider +{ + var $config; + var $unique_id; + + /** + * Constructor. + * + * @param array $config + */ + function phpbb_questionnaire_phpbb_data_provider($config) + { + // generate a unique id if necessary + if (empty($config['questionnaire_unique_id'])) + { + $this->unique_id = unique_id(); + set_config('questionnaire_unique_id', $this->unique_id); + } + else + { + $this->unique_id = $config['questionnaire_unique_id']; + } + + $this->config = $config; + } + + /** + * Returns a string identifier for this data provider + * + * @return string "phpBB" + */ + function get_identifier() + { + return 'phpBB'; + } + + /** + * Get data about this phpBB installation. + * + * @return array Relevant anonymous config options + */ + function get_data() + { + // Exclude certain config vars + $exclude_config_vars = array( + 'avatar_gallery_path' => true, + 'avatar_path' => true, + 'avatar_salt' => true, + 'board_contact' => true, + 'board_disable_msg' => true, + 'board_email' => true, + 'board_email_sig' => true, + 'cookie_name' => true, + 'icons_path' => true, + 'icons_path' => true, + 'jab_host' => true, + 'jab_password' => true, + 'jab_port' => true, + 'jab_username' => true, + 'ldap_base_dn' => true, + 'ldap_email' => true, + 'ldap_password' => true, + 'ldap_port' => true, + 'ldap_server' => true, + 'ldap_uid' => true, + 'ldap_user' => true, + 'ldap_user_filter' => true, + 'ranks_path' => true, + 'script_path' => true, + 'server_name' => true, + 'server_port' => true, + 'server_protocol' => true, + 'site_desc' => true, + 'sitename' => true, + 'smilies_path' => true, + 'smtp_host' => true, + 'smtp_password' => true, + 'smtp_port' => true, + 'smtp_username' => true, + 'upload_icons_path' => true, + 'upload_path' => true, + 'newest_user_colour' => true, + 'newest_user_id' => true, + 'newest_username' => true, + 'rand_seed' => true, + ); + + $result = array(); + foreach ($this->config as $name => $value) + { + // Mods may add columns for storing passwords - we do not want to grab them + if (isset($exclude_config_vars[$name]) || strpos($name, 'password') !== false) + { + continue; + } + + $result['config.' . $name] = $value; + } + + return $result; + } } + +?> \ No newline at end of file diff --git a/phpBB/includes/questionnaire/questionnaire_phpbb.php b/phpBB/includes/questionnaire/questionnaire_phpbb.php deleted file mode 100644 index 47bd931e68..0000000000 --- a/phpBB/includes/questionnaire/questionnaire_phpbb.php +++ /dev/null @@ -1,121 +0,0 @@ -unique_id = unique_id(); - set_config('questionnaire_unique_id', $this->unique_id); - } - else - { - $this->unique_id = $config['questionnaire_unique_id']; - } - - $this->config = $config; - } - - /** - * Returns a string identifier for this data provider - * - * @return string "phpBB" - */ - function getIdentifier() - { - return 'phpBB'; - } - - - /** - * Get data about this phpBB installation. - * - * @return array Relevant anonymous config options - */ - function getData() - { - - // Exclude certain config vars - $exclude_config_vars = array( - 'avatar_gallery_path' => true, - 'avatar_path' => true, - 'avatar_salt' => true, - 'board_contact' => true, - 'board_disable_msg' => true, - 'board_email' => true, - 'board_email_sig' => true, - 'cookie_name' => true, - 'icons_path' => true, - 'icons_path' => true, - 'jab_host' => true, - 'jab_password' => true, - 'jab_port' => true, - 'jab_username' => true, - 'ldap_base_dn' => true, - 'ldap_email' => true, - 'ldap_password' => true, - 'ldap_port' => true, - 'ldap_server' => true, - 'ldap_uid' => true, - 'ldap_user' => true, - 'ldap_user_filter' => true, - 'ranks_path' => true, - 'script_path' => true, - 'server_name' => true, - 'server_port' => true, - 'server_protocol' => true, - 'site_desc' => true, - 'sitename' => true, - 'smilies_path' => true, - 'smtp_host' => true, - 'smtp_password' => true, - 'smtp_port' => true, - 'smtp_username' => true, - 'upload_icons_path' => true, - 'upload_path' => true, - 'newest_user_colour' => true, - 'newest_user_id' => true, - 'newest_username' => true, - 'rand_seed' => true, - ); - - $result = array(); - foreach ($this->config as $name => $value) - { - if (!isset($exclude_config_vars[$name])) - { - $result['config.' . $name] = $value; - } - } - - return $result; - } -} \ No newline at end of file -- cgit v1.2.1 From 2e8d14004f9fc7083fcd7b377b86ea5cef7d55db Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 7 Jul 2009 10:52:59 +0000 Subject: Coding guidelines in r9629 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9720 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index ab9ddc0b6f..166ad11d3e 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -231,7 +231,7 @@ parse_css_file = {PARSE_CSS_FILE} $db->sql_query($sql); } } - elseif ( $action == 'deactivate' ) + else if ($action == 'deactivate') { $s_hidden_fields = array( 'i' => $id, -- cgit v1.2.1 From bd516916b8c627917e9be17cc81e37d56421eb66 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 7 Jul 2009 11:41:07 +0000 Subject: Color bbcode now supports three-digit hex notation. (Bug #39965 - Patch by leviatan21) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9722 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/bbcode.php | 2 +- phpBB/includes/message_parser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 562488db70..693523dcbb 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -265,7 +265,7 @@ class bbcode case 6: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( - '!\[color=(#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), + '!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), ) ); break; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 4cdc8b933e..7370c2057c 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -118,7 +118,7 @@ class bbcode_firstpass extends bbcode 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), + 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), -- cgit v1.2.1 From 4991cae3a1f5d3bcb435ae65bd63d4a705aa0653 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 7 Jul 2009 12:55:34 +0000 Subject: Fixed Bug #39625 - QUOTE-string not included when replying to pm's Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9725 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_compose.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 85e43dfc8c..edee64bd18 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -84,6 +84,10 @@ function compose_pm($id, $mode, $action) } redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm')); } + + // Since viewtopic.php language entries are used in several modes, + // we include the language file here + $user->add_lang('viewtopic'); // Output PM_TO box if message composing if ($action != 'edit') @@ -746,7 +750,6 @@ function compose_pm($id, $mode, $action) // Preview if (!sizeof($error) && $preview) { - $user->add_lang('viewtopic'); $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); $preview_signature = $user->data['user_sig']; -- cgit v1.2.1 From eb4eee77ac5b870966a00b4e23ff14f204e18c68 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 7 Jul 2009 12:59:30 +0000 Subject: Further word censor fix to work with UTF8 correctly Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9726 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php index 392f1377da..1effada666 100644 --- a/phpBB/includes/cache.php +++ b/phpBB/includes/cache.php @@ -86,7 +86,7 @@ class cache extends acm { if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) { - $censors['match'][] = '#(? Date: Tue, 7 Jul 2009 13:33:53 +0000 Subject: Fix bug #47815 - View end of ban in MCP and ACP when user is banned by duration - Patch by Pyramide Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9727 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_ban.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php index 77fb44dda9..542ed47f3b 100644 --- a/phpBB/includes/acp/acp_ban.php +++ b/phpBB/includes/acp/acp_ban.php @@ -181,7 +181,22 @@ class acp_ban $banned_options .= '' . $row[$field] . ''; $time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0; - $ban_length[$row['ban_id']] = (isset($ban_end_text[$time_length])) ? $ban_end_text[$time_length] : $user->lang['UNTIL'] . ' -> ' . $user->format_date($row['ban_end']); + + if ($time_length == 0) + { + // Banned permanently + $ban_length[$row['ban_id']] = $user->lang['PERMANENT']; + } + else if (isset($ban_end_text[$time_length])) + { + // Banned for a given duration + $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DURATION'], $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); + } + else + { + // Banned until given date + $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DATE'], $user->format_date($row['ban_end'], false, true)); + } $ban_reasons[$row['ban_id']] = $row['ban_reason']; $ban_give_reasons[$row['ban_id']] = $row['ban_give_reason']; -- cgit v1.2.1 From a6f088992b4d75df91df75f8d183a12f9fa12777 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 7 Jul 2009 15:18:11 +0000 Subject: Fix bug #47785 - Fetch requested cookie variables directly from cookie super global. This should fix a problem with phpBB installations on PHP 5.3 Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9728 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 25bef4557a..29f4186a5d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -71,12 +71,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) $_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name]; } - if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) + $super_global = ($cookie) ? '_COOKIE' : '_REQUEST'; + if (!isset($$super_global[$var_name]) || is_array($$super_global[$var_name]) != is_array($default)) { return (is_array($default)) ? array() : $default; } - $var = $_REQUEST[$var_name]; + $var = $$super_global[$var_name]; if (!is_array($default)) { $type = gettype($default); -- cgit v1.2.1 From 48e3b6deaab11bd4f04132aed514430aef8696f7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 7 Jul 2009 15:36:24 +0000 Subject: Fix r9728 - It does actually not work that way. ;-) Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9729 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 29f4186a5d..c6f6084918 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -72,12 +72,12 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) } $super_global = ($cookie) ? '_COOKIE' : '_REQUEST'; - if (!isset($$super_global[$var_name]) || is_array($$super_global[$var_name]) != is_array($default)) + if (!isset($GLOBALS[$super_global][$var_name]) || is_array($GLOBALS[$super_global][$var_name]) != is_array($default)) { return (is_array($default)) ? array() : $default; } - $var = $$super_global[$var_name]; + $var = $GLOBALS[$super_global][$var_name]; if (!is_array($default)) { $type = gettype($default); -- cgit v1.2.1 From f368e0ec09b38c885465478ff965400ffdc5c65e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 8 Jul 2009 10:22:36 +0000 Subject: Another feature: Detect when a post has been altered by someone else while editing. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9731 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 18bb432769..22fbfe3495 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -944,6 +944,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id WHERE p.topic_id = $topic_id " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' + ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' ORDER BY p.post_time '; $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; $result = $db->sql_query_limit($sql, $config['posts_per_page']); @@ -962,6 +963,12 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id return false; } + // Handle 'post_review_edit' like 'post_review' from now on + if ($mode == 'post_review_edit') + { + $mode = 'post_review'; + } + $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe', -- cgit v1.2.1 From 1c6e99848f9663792051c6bd84b6159b5ad57a4e Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Wed, 8 Jul 2009 12:50:45 +0000 Subject: Fixed Bug #40155 - Postcount of 0 not showing up in PMs Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9733 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 5fef30056f..185a7f523c 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -178,7 +178,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'RANK_IMG' => $user_info['rank_image'], 'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '', 'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']), - 'AUTHOR_POSTS' => (!empty($user_info['user_posts'])) ? $user_info['user_posts'] : '', + 'AUTHOR_POSTS' => (int) $user_info['user_posts'], 'AUTHOR_FROM' => (!empty($user_info['user_from'])) ? $user_info['user_from'] : '', 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : ((isset($user_info['online']) && $user_info['online']) ? $user->img('icon_user_online', $user->lang['ONLINE']) : $user->img('icon_user_offline', $user->lang['OFFLINE'])), -- cgit v1.2.1 From 51885a2734bea8f77e9be0f536942fb6bf305163 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Jul 2009 13:03:43 +0000 Subject: Fix bug #47575 - Disable word-censor option in UCP lacks the config-setting - Patch by 00mohgta7 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9734 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_prefs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 9b705fba6c..cc8565e69d 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -282,7 +282,7 @@ class ucp_prefs 'S_AVATARS' => $data['avatars'], 'S_DISABLE_CENSORS' => $data['wordcensor'], - 'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors')) ? true : false, + 'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors') && $config['allow_nocensors']) ? true : false, 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, -- cgit v1.2.1 From 55e15b4c8eea94f226a0169284bb51d7d9bcbcd4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 8 Jul 2009 13:52:18 +0000 Subject: Fix database updater and db tools to support multiple column changes/additions/removals with SQLite git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9735 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/db_tools.php | 246 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 229 insertions(+), 17 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 7ea70f341d..ddc633c6d1 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -347,6 +347,11 @@ class phpbb_db_tools // holds the DDL for a column $columns = $statements = array(); + if ($this->sql_table_exists($table_name)) + { + return $this->_sql_run_sql($statements); + } + // Begin transaction $statements[] = 'begin'; @@ -580,6 +585,14 @@ class phpbb_db_tools } $statements = array(); + $sqlite = false; + + // For SQLite we need to perform the schema changes in a much more different way + if ($this->db->sql_layer == 'sqlite' && $this->return_statements) + { + $sqlite_data = array(); + $sqlite = true; + } // Change columns? if (!empty($schema_changes['change_columns'])) @@ -589,16 +602,27 @@ class phpbb_db_tools foreach ($columns as $column_name => $column_data) { // If the column exists we change it, else we add it ;) - if ($this->sql_column_exists($table, $column_name)) + if ($column_exists = $this->sql_column_exists($table, $column_name)) { - $result = $this->sql_column_change($table, $column_name, $column_data); + $result = $this->sql_column_change($table, $column_name, $column_data, true); } else { - $result = $this->sql_column_add($table, $column_name, $column_data); + $result = $this->sql_column_add($table, $column_name, $column_data, true); } - if ($this->return_statements) + if ($sqlite) + { + if ($column_exists) + { + $sqlite_data[$table]['change_columns'][] = $result; + } + else + { + $sqlite_data[$table]['add_columns'][] = $result; + } + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -614,16 +638,27 @@ class phpbb_db_tools foreach ($columns as $column_name => $column_data) { // Only add the column if it does not exist yet, else change it (to be consistent) - if ($this->sql_column_exists($table, $column_name)) + if ($column_exists = $this->sql_column_exists($table, $column_name)) { - $result = $this->sql_column_change($table, $column_name, $column_data); + $result = $this->sql_column_change($table, $column_name, $column_data, true); } else { - $result = $this->sql_column_add($table, $column_name, $column_data); + $result = $this->sql_column_add($table, $column_name, $column_data, true); } - if ($this->return_statements) + if ($sqlite) + { + if ($column_exists) + { + $sqlite_data[$table]['change_columns'][] = $result; + } + else + { + $sqlite_data[$table]['add_columns'][] = $result; + } + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -658,9 +693,13 @@ class phpbb_db_tools // Only remove the column if it exists... if ($this->sql_column_exists($table, $column)) { - $result = $this->sql_column_remove($table, $column); + $result = $this->sql_column_remove($table, $column, true); - if ($this->return_statements) + if ($sqlite) + { + $sqlite_data[$table]['drop_columns'][] = $result; + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -674,9 +713,13 @@ class phpbb_db_tools { foreach ($schema_changes['add_primary_keys'] as $table => $columns) { - $result = $this->sql_create_primary_key($table, $columns); + $result = $this->sql_create_primary_key($table, $columns, true); - if ($this->return_statements) + if ($sqlite) + { + $sqlite_data[$table]['primary_key'] = $result; + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -717,6 +760,147 @@ class phpbb_db_tools } } + if ($sqlite) + { + foreach ($sqlite_data as $table_name => $sql_schema_changes) + { + // Create temporary table with original data + $statements[] = 'begin'; + + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + continue; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // Create a backup table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + // Get the columns... + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $plain_table_cols = trim($matches[1]); + $new_table_cols = preg_split('/,(?![\s\w]+\))/m', $plain_table_cols); + $column_list = array(); + + foreach ($new_table_cols as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + continue; + } + $column_list[] = $entities[0]; + } + + // note down the primary key notation because sqlite only supports adding it to the end for the new table + $primary_key = false; + $_new_cols = array(); + + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + $primary_key = $declaration; + continue; + } + $_new_cols[] = $declaration; + } + + $new_table_cols = $_new_cols; + + // First of all... change columns + if (!empty($sql_schema_changes['change_columns'])) + { + foreach ($sql_schema_changes['change_columns'] as $column_sql) + { + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if (strpos($column_sql, $entities[0] . ' ') === 0) + { + $new_table_cols[$key] = $column_sql; + } + } + } + } + + if (!empty($sql_schema_changes['add_columns'])) + { + foreach ($sql_schema_changes['add_columns'] as $column_sql) + { + $new_table_cols[] = $column_sql; + } + } + + // Now drop them... + if (!empty($sql_schema_changes['drop_columns'])) + { + foreach ($sql_schema_changes['drop_columns'] as $column_name) + { + // Remove from column list... + $new_column_list = array(); + foreach ($column_list as $key => $value) + { + if ($value === $column_name) + { + continue; + } + + $new_column_list[] = $value; + } + + $column_list = $new_column_list; + + // Remove from table... + $_new_cols = array(); + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if (strpos($column_name . ' ', $entities[0] . ' ') === 0) + { + continue; + } + $_new_cols[] = $declaration; + } + $new_table_cols = $_new_cols; + } + } + + // Primary key... + if (!empty($sql_schema_changes['primary_key'])) + { + $new_table_cols[] = 'PRIMARY KEY (' . implode(', ', $sql_schema_changes['primary_key']) . ')'; + } + // Add a new one or the old primary key + else if ($primary_key !== false) + { + $new_table_cols[] = $primary_key; + } + + $columns = implode(',', $column_list); + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $new_table_cols) . ');'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + } + } + if ($this->return_statements) { return $statements; @@ -1131,7 +1315,7 @@ class phpbb_db_tools /** * Add new column */ - function sql_column_add($table_name, $column_name, $column_data) + function sql_column_add($table_name, $column_name, $column_data, $inline = false) { $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); $statements = array(); @@ -1160,6 +1344,12 @@ class phpbb_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column_name . ' ' . $column_data['column_type_sql']; + } + if (version_compare(sqlite_libversion(), '3.0') == -1) { $sql = "SELECT sql @@ -1224,7 +1414,7 @@ class phpbb_db_tools /** * Drop column */ - function sql_column_remove($table_name, $column_name) + function sql_column_remove($table_name, $column_name, $inline = false) { $statements = array(); @@ -1252,6 +1442,12 @@ class phpbb_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column_name; + } + if (version_compare(sqlite_libversion(), '3.0') == -1) { $sql = "SELECT sql @@ -1294,7 +1490,7 @@ class phpbb_db_tools $columns = implode(',', $column_list); - $new_table_cols = $new_table_cols = preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols); + $new_table_cols = preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols); // create a new table and fill it up. destroy the temp one $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'; @@ -1349,6 +1545,11 @@ class phpbb_db_tools { $statements = array(); + if (!$this->sql_table_exists($table_name)) + { + return $this->_sql_run_sql($statements); + } + // the most basic operation, get rid of the table $statements[] = 'DROP TABLE ' . $table_name; @@ -1407,7 +1608,7 @@ class phpbb_db_tools /** * Add primary key */ - function sql_create_primary_key($table_name, $column) + function sql_create_primary_key($table_name, $column, $inline = false) { $statements = array(); @@ -1434,6 +1635,12 @@ class phpbb_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column; + } + $sql = "SELECT sql FROM sqlite_master WHERE type = 'table' @@ -1641,7 +1848,7 @@ class phpbb_db_tools /** * Change column type (not name!) */ - function sql_column_change($table_name, $column_name, $column_data) + function sql_column_change($table_name, $column_name, $column_data, $inline = false) { $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); $statements = array(); @@ -1739,6 +1946,11 @@ class phpbb_db_tools case 'sqlite': + if ($inline && $this->return_statements) + { + return $column_name . ' ' . $column_data['column_type_sql']; + } + $sql = "SELECT sql FROM sqlite_master WHERE type = 'table' -- cgit v1.2.1 From 61453bb2aba7c1acfedab0ea600c9d13ee751976 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Wed, 8 Jul 2009 14:30:01 +0000 Subject: Fixed Bug #24075 - GZIP status is not showed up correctly in debug mode Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9737 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 2 +- phpBB/includes/functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index e0d6a3f01c..f9d611f8db 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -485,7 +485,7 @@ class acp_main 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'TOTAL_ORPHAN' => $total_orphan, 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true, - 'GZIP_COMPRESSION' => ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF'], + 'GZIP_COMPRESSION' => ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'], 'DATABASE_INFO' => $db->sql_server_info(), 'BOARD_VERSION' => $config['version'], diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c6f6084918..60fe6a454f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3927,7 +3927,7 @@ function page_footer($run_cron = true) $db->sql_report('display'); } - $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); + $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) { -- cgit v1.2.1 From c875e2924969bc5d7a923ac7af3feb998136f5e4 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 8 Jul 2009 14:58:06 +0000 Subject: some changelog changes and a small SQL correction git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9738 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_warn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 4ce67e5f9b..63e5b19155 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -204,7 +204,7 @@ class mcp_warn $sql = 'SELECT u.*, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE post_id = $post_id + WHERE p.post_id = $post_id AND u.user_id = p.poster_id"; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); -- cgit v1.2.1 From 54ee31972af4f84e09ad5b12ca512e5712bbd87a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 11 Jul 2009 10:05:20 +0000 Subject: Fix bug #47775 - Properly convert and show filesize information Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9748 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_attachments.php | 10 +++-- phpBB/includes/functions.php | 71 ++++++++++++++++++++++++++++++---- phpBB/includes/functions_content.php | 8 ++-- phpBB/includes/functions_upload.php | 9 ++--- 4 files changed, 75 insertions(+), 23 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index de4092036e..0fc0fe0848 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -684,8 +684,9 @@ class acp_attachments $ext_group_row['max_filesize'] = (int) $config['max_filesize']; } - $size_format = ($ext_group_row['max_filesize'] >= 1048576) ? 'mb' : (($ext_group_row['max_filesize'] >= 1024) ? 'kb' : 'b'); - $ext_group_row['max_filesize'] = get_formatted_filesize($ext_group_row['max_filesize'], false); + $max_filesize = get_formatted_filesize($ext_group_row['max_filesize'], false, array('mb', 'kb', 'b')); + $size_format = $max_filesize['si_identifier']; + $ext_group_row['max_filesize'] = $max_filesize['value']; $img_path = $config['upload_icons_path']; @@ -1429,8 +1430,9 @@ class acp_attachments function max_filesize($value, $key = '') { // Determine size var and adjust the value accordingly - $size_var = ($value >= 1048576) ? 'mb' : (($value >= 1024) ? 'kb' : 'b'); - $value = get_formatted_filesize($value, false); + $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); + $size_var = $filesize['si_identifier']; + $value = $filesize['value']; return ' '; } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 60fe6a454f..84bbb964de 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -232,27 +232,82 @@ function unique_id($extra = 'c') /** * Return formatted string for filesizes +* +* @param int $value filesize in bytes +* @param bool $string_only true if language string should be returned +* @param array $allowed_units only allow these units (data array indexes) +* +* @return mixed data array if $string_only is false +* @author bantu */ -function get_formatted_filesize($bytes, $add_size_lang = true) +function get_formatted_filesize($value, $string_only = true, $allowed_units = false) { global $user; - if ($bytes >= pow(2, 30)) + $available_units = array( + 'gb' => array( + 'min' => 1073741824, // pow(2, 30) + 'index' => 3, + 'si_unit' => 'GB', + 'iec_unit' => 'GIB', + ), + 'mb' => array( + 'min' => 1048576, // pow(2, 20) + 'index' => 2, + 'si_unit' => 'MB', + 'iec_unit' => 'MIB', + ), + 'kb' => array( + 'min' => 1024, // pow(2, 10) + 'index' => 1, + 'si_unit' => 'KB', + 'iec_unit' => 'KIB', + ), + 'b' => array( + 'min' => 0, + 'index' => 0, + 'si_unit' => 'BYTES', // Language index + 'iec_unit' => 'BYTES', // Language index + ), + ); + + foreach ($available_units as $si_identifier => $unit_info) { - return ($add_size_lang) ? round($bytes / 1024 / 1024 / 1024, 2) . ' ' . $user->lang['GIB'] : round($bytes / 1024 / 1024 / 1024, 2); + if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) + { + continue; + } + + if ($value >= $unit_info['min']) + { + $unit_info['si_identifier'] = $si_identifier; + + break; + } } + unset($available_units); - if ($bytes >= pow(2, 20)) + for ($i = 0; $i < $unit_info['index']; $i++) { - return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2); + $value /= 1024; } + $value = round($value, 2); - if ($bytes >= pow(2, 10)) + // Lookup units in language dictionary + $unit_info['si_unit'] = (isset($user->lang[$unit_info['si_unit']])) ? $user->lang[$unit_info['si_unit']] : $unit_info['si_unit']; + $unit_info['iec_unit'] = (isset($user->lang[$unit_info['iec_unit']])) ? $user->lang[$unit_info['iec_unit']] : $unit_info['iec_unit']; + + // Default to IEC + $unit_info['unit'] = $unit_info['iec_unit']; + + if (!$string_only) { - return ($add_size_lang) ? round($bytes / 1024, 2) . ' ' . $user->lang['KIB'] : round($bytes / 1024, 2); + $unit_info['value'] = $value; + + return $unit_info; } - return ($add_size_lang) ? ($bytes) . ' ' . $user->lang['BYTES'] : ($bytes); + return $value . ' ' . $unit_info['unit']; } /** diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 3107177137..630f4105d0 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -853,16 +853,14 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, } } - $filesize = $attachment['filesize']; - $size_lang = ($filesize >= 1048576) ? $user->lang['MIB'] : (($filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); - $filesize = get_formatted_filesize($filesize, false); + $filesize = get_formatted_filesize($attachment['filesize'], false); $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); $block_array += array( 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize, - 'SIZE_LANG' => $size_lang, + 'FILESIZE' => $filesize['value'], + 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => basename($attachment['real_filename']), 'COMMENT' => $comment, ); diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 1ad6223aa1..c65d732984 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -417,10 +417,9 @@ class filespec // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0)) { - $size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] ); $max_filesize = get_formatted_filesize($this->upload->max_filesize, false); - $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang); + $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); return false; } @@ -855,10 +854,9 @@ class fileupload break; case 2: - $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); $max_filesize = get_formatted_filesize($this->max_filesize, false); - $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang); + $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); break; case 3: @@ -891,10 +889,9 @@ class fileupload // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0)) { - $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); $max_filesize = get_formatted_filesize($this->max_filesize, false); - $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang); + $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); } // check Filename -- cgit v1.2.1 From ecfe24528c46b264baa164ba5811fcc5cfab231e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 13 Jul 2009 19:20:17 +0000 Subject: Fix bug #47265 - Smilies and images not viewed in topic-print view Fix - Force full date for PMs print-view Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9753 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 185a7f523c..82aa5afd8f 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -29,6 +29,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $msg_id = (int) $msg_id; $folder_id = (int) $folder_id; $author_id = (int) $message_row['author_id']; + $view = request_var('view', ''); // Not able to view message, it was deleted by the sender if ($message_row['pm_deleted']) @@ -192,7 +193,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']), 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), - 'SENT_DATE' => $user->format_date($message_row['message_time']), + 'SENT_DATE' => ($view == 'print') ? $user->format_date($message_row['message_time'], false, true) : $user->format_date($message_row['message_time']), 'SUBJECT' => $message_row['message_subject'], 'MESSAGE' => $message, 'SIGNATURE' => ($message_row['enable_sig']) ? $signature : '', -- cgit v1.2.1 From 5cbf5d4b16a41ea2599cb7f56836d5b963ab4000 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 14 Jul 2009 12:02:11 +0000 Subject: Fix bug #44295 - Cannot prune users who never logged in Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9754 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_prune.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index a82a438db7..7eeb37133f 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -406,7 +406,12 @@ class acp_prune $where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : ''; $where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - if (sizeof($active) && $active_select != 'lt') + // First handle pruning of users who never logged in, last active date is 0000-00-00 + if (sizeof($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) + { + $where_sql .= ' AND user_lastvisit = 0'; + } + else if (sizeof($active) && $active_select != 'lt') { $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); } -- cgit v1.2.1 From 51748b00ed8e6b709f1a7df59570e8ecee6783d5 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 14 Jul 2009 14:46:38 +0000 Subject: Fix bug #46765 - View unread posts Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9755 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 84bbb964de..74f7e31bee 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3896,6 +3896,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), + 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), @@ -4119,4 +4120,94 @@ function phpbb_user_session_handler() return; } +/* +* Get list of unread topics +* only for registered users and non-cookie tracking this function is used +*/ +function get_unread_topics_list($user_id = false, $sql_extra = '') +{ + global $config, $db, $user; + + if($user_id === false) + { + $user_id = $user->data['user_id']; + } + + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); + $tracked_forums_list = array(); + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = {$user_id}"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = $row['forum_id']; + } + $db->sql_freeresult($result); + + // Get list of the unread topics - on topics tracking as the first step + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + WHERE t.topic_id = tt.topic_id + AND t.topic_last_post_time >= tt.mark_time + AND tt.user_id = {$user_id} + $sql_extra"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + if($row['topic_last_post_time'] == $row['mark_time']) + { + // Check if there're read topics for the forums having unread ones + $read_topics_list[$row['topic_id']] = $row['mark_time']; + } + else + { + $unread_topics_list[$row['topic_id']] = $row['mark_time']; + } + } + $db->sql_freeresult($result); + + // Get the full list of the tracked topics + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = {$user_id} + $sql_extra"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " + WHERE topic_last_post_time > {$user->data['user_lastmark']} + AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' + AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql_extra"; + $result = $db->sql_query_limit($sql, 1000); + while($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + // We do not implement unread topics list for cookie based tracking + // because it would require expensive database queries + } + + return $unread_topics_list; +} + ?> \ No newline at end of file -- cgit v1.2.1 From 0b2979c6bab97297f839937606635fd4cc6b1eae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 Jul 2009 20:25:41 +0000 Subject: Feature Bug #45375 - Add option to disable remote upload avatars Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9757 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/includes/acp/acp_users.php | 9 +++++---- phpBB/includes/ucp/ucp_groups.php | 14 +++++++++----- phpBB/includes/ucp/ucp_profile.php | 10 +++++----- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 008594a319..a4a2572c0f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -117,6 +117,7 @@ class acp_board 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index c663103e17..1cd7a405d5 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1484,10 +1484,11 @@ class acp_users $template->assign_vars(array( 'S_AVATAR' => true, - 'S_CAN_UPLOAD' => ($can_upload && $config['allow_avatar_upload']) ? true : false, - 'S_ALLOW_REMOTE' => ($config['allow_avatar_remote']) ? true : false, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, + 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, + 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, + 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, + 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, + 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 3f27f093ec..8aba34c733 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -688,24 +688,28 @@ class ucp_groups $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - if ($config['allow_avatar_local'] && $display_gallery) + if ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) { avatar_gallery($category, $avatar_select, 4); } - $avatars_enabled = ($can_upload || ($config['allow_avatar_local'] || $config['allow_avatar_remote'])) ? true : false; + $avatars_enabled = ($config['allow_avatar'] && (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; $template->assign_vars(array( 'S_EDIT' => true, 'S_INCLUDE_SWATCH' => true, - 'S_CAN_UPLOAD' => $can_upload, - 'S_FORM_ENCTYPE' => ($can_upload) ? ' enctype="multipart/form-data"' : '', + 'S_FORM_ENCTYPE' => ($config['allow_avatar'] && $can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', 'S_ERROR' => (sizeof($error)) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, + 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, + 'S_UPLOAD_AVATAR_FILE' => ($config['allow_avatar'] && $config['allow_avatar_upload'] && $can_upload) ? true : false, + 'S_UPLOAD_AVATAR_URL' => ($config['allow_avatar'] && $config['allow_avatar_remote_upload'] && $can_upload) ? true : false, + 'S_LINK_AVATAR' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, + 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local']) ? true : false, + 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index d93567c543..a7785e7163 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -564,7 +564,7 @@ class ucp_profile $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); - $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; add_form_key('ucp_avatar'); @@ -605,7 +605,7 @@ class ucp_profile 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), - 'S_FORM_ENCTYPE' => ($can_upload) ? ' enctype="multipart/form-data"' : '', + 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), )); @@ -616,15 +616,15 @@ class ucp_profile } else if ($config['allow_avatar']) { - $avatars_enabled = ($can_upload || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; + $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; $template->assign_vars(array( 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']), 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']), 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_UPLOAD_AVATAR_FILE' => $can_upload, - 'S_UPLOAD_AVATAR_URL' => $can_upload, + 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false, + 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false, 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) ); -- cgit v1.2.1 From e3866c939d78b925844cd61d6ad567988f24e42d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 Jul 2009 20:35:53 +0000 Subject: Feature Bug #43375 - Ability to delete warnings and keep warnings permanently Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9758 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 142 ++++++++++++++++++++++++++++++++++ phpBB/includes/acp/info/acp_users.php | 1 + phpBB/includes/functions.php | 2 +- 3 files changed, 144 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 1cd7a405d5..d8fef3f547 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1065,6 +1065,148 @@ class acp_users break; + case 'warnings': + $user->add_lang('mcp'); + + // Set up general vars + $start = request_var('start', 0); + $deletemark = (isset($_POST['delmarked'])) ? true : false; + $deleteall = (isset($_POST['delall'])) ? true : false; + $confirm = (isset($_POST['confirm'])) ? true : false; + $marked = request_var('mark', array(0)); + $message = utf8_normalize_nfc(request_var('message', '', true)); + + // Sort keys + $sort_days = request_var('st', 0); + $sort_key = request_var('sk', 't'); + $sort_dir = request_var('sd', 'd'); + + // Delete entries if requested and able + if ($deletemark || $deleteall || $confirm) + { + if (confirm_box(true)) + { + $where_sql = ''; + $deletemark = request_var('delmarked', 0); + $deleteall = request_var('delall', 0); + if ($deletemark && $marked) + { + $sql_in = array(); + foreach ($marked as $mark) + { + $sql_in[] = $mark; + } + $where_sql = ' AND ' . $db->sql_in_set('warning_id', $sql_in); + unset($sql_in); + } + + if ($where_sql || $deleteall) + { + $sql = 'DELETE FROM ' . WARNINGS_TABLE . " + WHERE user_id = $user_id + $where_sql"; + $db->sql_query($sql); + + if ($deleteall) + { + $deleted_warnings = '0'; + } + else + { + $deleted_warnings = ' user_warnings - ' . $db->sql_affectedrows(); + } + + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_warnings = $deleted_warnings + WHERE user_id = $user_id"; + $db->sql_query($sql); + + add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); + } + } + else + { + $s_hidden_fields = array( + 'i' => $id, + 'mode' => $mode, + 'u' => $user_id, + 'mark' => $marked, + ); + if (isset($_POST['delmarked'])) + { + $s_hidden_fields['delmarked'] = 1; + } + if (isset($_POST['delall'])) + { + $s_hidden_fields['delall'] = 1; + } + if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked))) + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); + } + } + } + + $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour + FROM ' . WARNINGS_TABLE . ' w + LEFT JOIN ' . LOG_TABLE . ' l + ON (w.log_id = l.log_id) + LEFT JOIN ' . USERS_TABLE . ' m + ON (l.user_id = m.user_id) + WHERE w.user_id = ' . $user_id . ' + ORDER BY w.warning_time DESC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (!$row['log_operation']) + { + // We do not have a log-entry anymore, so there is no data available + $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; + } + else + { + $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; + if (!empty($row['log_data'])) + { + $log_data_ary = @unserialize($row['log_data']); + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; + + if (isset($user->lang[$row['log_operation']])) + { + // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array + // It doesn't matter if we add more arguments than placeholders + if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); + } + $row['action'] = vsprintf($row['action'], $log_data_ary); + $row['action'] = bbcode_nl2br(censor_text($row['action'])); + } + else if (!empty($log_data_ary)) + { + $row['action'] .= '
' . implode('', $log_data_ary); + } + } + } + + + $template->assign_block_vars('warn', array( + 'ID' => $row['warning_id'], + 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', + 'ACTION' => make_clickable($row['action']), + 'DATE' => $user->format_date($row['warning_time']), + )); + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'S_WARNINGS' => true, + 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), + )); + + break; + case 'profile': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); diff --git a/phpBB/includes/acp/info/acp_users.php b/phpBB/includes/acp/info/acp_users.php index 0cd5f7ae97..10081ac870 100644 --- a/phpBB/includes/acp/info/acp_users.php +++ b/phpBB/includes/acp/info/acp_users.php @@ -22,6 +22,7 @@ class acp_users_info 'modes' => array( 'overview' => array('title' => 'ACP_MANAGE_USERS', 'auth' => 'acl_a_user', 'cat' => array('ACP_CAT_USERS')), 'feedback' => array('title' => 'ACP_USER_FEEDBACK', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), + 'warnings' => array('title' => 'ACP_USER_WARNINGS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'profile' => array('title' => 'ACP_USER_PROFILE', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'prefs' => array('title' => 'ACP_USER_PREFS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'avatar' => array('title' => 'ACP_USER_AVATAR', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74f7e31bee..eaaa8aaf6a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4025,7 +4025,7 @@ function page_footer($run_cron = true) // Tidy the cache $cron_type = 'tidy_cache'; } - else if (time() - $config['warnings_gc'] > $config['warnings_last_gc']) + else if ($config['warnings_last_gc'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } -- cgit v1.2.1 From 33033ad12555377a9b50cfbeb72b683ddd56b893 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 Jul 2009 20:40:45 +0000 Subject: Fix Bug #45675 - Do not allow setting group as default group for pending user Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9759 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 25 +++++++++++++++++++++++++ phpBB/includes/functions_user.php | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index d8fef3f547..c27c259b46 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -2017,6 +2017,29 @@ class acp_users } break; + + case 'approve': + + if (confirm_box(true)) + { + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + group_user_attributes($action, $group_id, $user_id); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'u' => $user_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'g' => $group_id)) + ); + } + + break; } // Add user to group? @@ -2109,10 +2132,12 @@ class acp_users 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], + 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], + 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, ) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 4ea094e451..c69c27c9d7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3109,6 +3109,27 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna break; case 'default': + // We only set default group for approved members of the group + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + AND user_pending = 0 + AND " . $db->sql_in_set('user_id', $user_id_ary); + $result = $db->sql_query($sql); + + $user_id_ary = $username_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $user_id_ary[] = $row['user_id']; + } + $db->sql_freeresult($result); + + $result = user_get_id_name($user_id_ary, $username_ary); + if (!sizeof($user_id_ary) || $result !== false) + { + return 'NO_USERS'; + } + $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); $result = $db->sql_query($sql); @@ -3197,7 +3218,7 @@ function group_validate_groupname($group_id, $group_name) */ function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) { - global $db; + global $cache, $db; if (empty($user_id_ary)) { @@ -3297,6 +3318,9 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal { group_update_listings($group_id); } + + // Because some tables/caches use usercolour-specific data we need to purge this here. + $cache->destroy('sql', MODERATOR_CACHE_TABLE); } /** -- cgit v1.2.1 From 7a5db8b55d163ae4b0b0bd433362dbbe8cbbfdf4 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 16 Jul 2009 10:17:20 +0000 Subject: assign vars git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9762 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd8fbce0fa..41ce242e91 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -133,6 +133,8 @@ class phpbb_recaptcha extends phpbb_default_captcha 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', 'RECAPTCHA_ERRORGET' => '', 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, )); return 'captcha_recaptcha.html'; -- cgit v1.2.1 From a7776919945450eb2c0a37af30b35695f93fae51 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Thu, 16 Jul 2009 17:57:05 +0000 Subject: - Add pagination for icons and smilies in the ACP and smilies in the smiley popup git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9763 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/includes/acp/acp_icons.php | 20 +++++++++++++++----- phpBB/includes/functions_posting.php | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 11 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index a4a2572c0f..5966d5a4b2 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -181,6 +181,7 @@ class acp_board 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true), 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), + 'smilies_per_page' => array('lang' => 'SMILIES_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true), 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'text:4:4', 'explain' => false), 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index a88090cb25..cd26d46044 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -173,7 +173,7 @@ class acp_icons FROM $table ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); $result = $db->sql_query($sql); - + $data = array(); $after = false; $display = 0; @@ -835,12 +835,20 @@ class acp_icons ); $spacer = false; + + $sql = "SELECT COUNT(*) AS count + FROM $table"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $item_count = $row['count']; $sql = "SELECT * FROM $table ORDER BY {$fields}_order ASC"; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $config['smilies_per_page'], request_var('start', 0)); + $pagination_start = request_var('start', 0); while ($row = $db->sql_fetchrow($result)) { $alt_text = ($mode == 'smilies') ? $row['code'] : ''; @@ -855,9 +863,9 @@ class acp_icons 'EMOTION' => (isset($row['emotion'])) ? $row['emotion'] : '', 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], - 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'], - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id']) - ); + 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, + 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id'] . '&start=' . $pagination_start, + )); if (!$spacer && !$row['display_on_posting']) { @@ -865,6 +873,8 @@ class acp_icons } } $db->sql_freeresult($result); + $template->assign_var('PAGINATION', generate_pagination( + $this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)); } } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 22fbfe3495..0c5aeb98d6 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -43,10 +43,25 @@ function generate_smilies($mode, $forum_id) } page_header($user->lang['SMILIES']); + + $sql = 'SELECT COUNT(smiley_id) AS count + FROM ' . SMILIES_TABLE . ' + GROUP BY smiley_url'; + $result = $db->sql_query($sql, 3600); + + $smiley_count = 0; + while ($row = $db->sql_fetchrow($result)) + { + ++$smiley_count; + } + $db->sql_freeresult($result); $template->set_filenames(array( 'body' => 'posting_smilies.html') ); + $template->assign_var('PAGINATION', + generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), + $smiley_count, $config['smilies_per_page'], request_var('start', 0), true)); } $display_link = false; @@ -64,13 +79,22 @@ function generate_smilies($mode, $forum_id) $db->sql_freeresult($result); } - $last_url = ''; + if ($mode == 'window') + { + $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height + FROM ' . SMILIES_TABLE . ' + GROUP BY smiley_url, smiley_width, smiley_height ORDER BY smiley_order'; + $result = $db->sql_query_limit($sql, $config['smilies_per_page'], request_var('start', 0), 3600); + } + else + { + $sql = 'SELECT * + FROM ' . SMILIES_TABLE . ' + WHERE display_on_posting = 1 + ORDER BY smiley_order'; - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . - (($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . ' - ORDER BY smiley_order'; - $result = $db->sql_query($sql, 3600); + $result = $db->sql_query($sql, 3600); + } $smilies = array(); while ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From dce2a9b039184a8c5dddf4825cf0b6b3081bc3fd Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 17 Jul 2009 09:05:09 +0000 Subject: A small correction to #r9763 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9764 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_icons.php | 38 ++++++++++++++++++------------------ phpBB/includes/functions_posting.php | 16 +++++++++------ 2 files changed, 29 insertions(+), 25 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index cd26d46044..e261a6cbf0 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -168,7 +168,7 @@ class acp_icons } } } - + $sql = "SELECT * FROM $table ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); @@ -180,7 +180,7 @@ class acp_icons $order_lists = array('', ''); $add_order_lists = array('', ''); $display_count = 0; - + while ($row = $db->sql_fetchrow($result)) { if ($action == 'add') @@ -234,12 +234,12 @@ class acp_icons $colspan = (($mode == 'smilies') ? '7' : '5'); $colspan += ($icon_id) ? 1 : 0; $colspan += ($action == 'add') ? 2 : 0; - + $template->assign_vars(array( 'S_EDIT' => true, 'S_SMILIES' => ($mode == 'smilies') ? true : false, 'S_ADD' => ($action == 'add') ? true : false, - + 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], 'S_ORDER_LIST_DISPLAY_COUNT' => $display_count + 1, @@ -286,10 +286,10 @@ class acp_icons 'S_ADD_CODE' => true, 'S_IMG_OPTIONS' => $smiley_options, - + 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], - + 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 'IMG_PATH' => $img_path, 'PHPBB_ROOT_PATH' => $phpbb_root_path, @@ -303,7 +303,7 @@ class acp_icons } return; - + break; case 'create': @@ -311,7 +311,7 @@ class acp_icons // Get items to create/modify $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); - + // Now really get the items $image_id = (isset($_POST['id'])) ? request_var('id', array('' => 0)) : array(); $image_order = (isset($_POST['order'])) ? request_var('order', array('' => 0)) : array(); @@ -426,13 +426,13 @@ class acp_icons $db->sql_query($sql); $icons_updated++; } - + } } - + $cache->destroy('_icons'); $cache->destroy('sql', $table); - + $level = E_USER_NOTICE; switch ($icons_updated) { @@ -440,11 +440,11 @@ class acp_icons $suc_lang = "{$lang}_NONE"; $level = E_USER_WARNING; break; - + case 1: $suc_lang = "{$lang}_ONE"; break; - + default: $suc_lang = $lang; } @@ -835,20 +835,19 @@ class acp_icons ); $spacer = false; - + $pagination_start = request_var('start', 0); + $sql = "SELECT COUNT(*) AS count FROM $table"; $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); + $item_count = (int) $db->sql_fetchfield('count'); $db->sql_freeresult($result); - $item_count = $row['count']; $sql = "SELECT * FROM $table ORDER BY {$fields}_order ASC"; - $result = $db->sql_query_limit($sql, $config['smilies_per_page'], request_var('start', 0)); + $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start); - $pagination_start = request_var('start', 0); while ($row = $db->sql_fetchrow($result)) { $alt_text = ($mode == 'smilies') ? $row['code'] : ''; @@ -874,7 +873,8 @@ class acp_icons } $db->sql_freeresult($result); $template->assign_var('PAGINATION', generate_pagination( - $this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)); + + $this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)); } } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 0c5aeb98d6..7db2875cda 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -24,6 +24,8 @@ function generate_smilies($mode, $forum_id) global $auth, $db, $user, $config, $template; global $phpEx, $phpbb_root_path; + $start = request_var('start', 0); + if ($mode == 'window') { if ($forum_id) @@ -43,12 +45,12 @@ function generate_smilies($mode, $forum_id) } page_header($user->lang['SMILIES']); - + $sql = 'SELECT COUNT(smiley_id) AS count FROM ' . SMILIES_TABLE . ' GROUP BY smiley_url'; $result = $db->sql_query($sql, 3600); - + $smiley_count = 0; while ($row = $db->sql_fetchrow($result)) { @@ -59,9 +61,11 @@ function generate_smilies($mode, $forum_id) $template->set_filenames(array( 'body' => 'posting_smilies.html') ); + $template->assign_var('PAGINATION', generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), - $smiley_count, $config['smilies_per_page'], request_var('start', 0), true)); + $smiley_count, $config['smilies_per_page'], $start, true) + ); } $display_link = false; @@ -83,8 +87,9 @@ function generate_smilies($mode, $forum_id) { $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url, smiley_width, smiley_height ORDER BY smiley_order'; - $result = $db->sql_query_limit($sql, $config['smilies_per_page'], request_var('start', 0), 3600); + GROUP BY smiley_url, smiley_width, smiley_height + ORDER BY smiley_order'; + $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); } else { @@ -92,7 +97,6 @@ function generate_smilies($mode, $forum_id) FROM ' . SMILIES_TABLE . ' WHERE display_on_posting = 1 ORDER BY smiley_order'; - $result = $db->sql_query($sql, 3600); } -- cgit v1.2.1 From 955939ee1b8f95948c37628ee996a6ac07c305a2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 17 Jul 2009 10:11:10 +0000 Subject: Fix bug #47495 - Move hardcoded language string to language file. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9765 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_database.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 1182e224cf..575137ea2d 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -548,7 +548,9 @@ class base_extractor if (!$this->fp) { - trigger_error('Unable to write temporary file to storage folder', E_USER_ERROR); + global $user; + + trigger_error($user->lang['FILE_WRITE_FAIL'], E_USER_ERROR); } } } -- cgit v1.2.1 From 2f9f52b151338903ed9721475f6cb3d753d100b9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 17 Jul 2009 10:11:48 +0000 Subject: ok, i misread this one. :) related to r9763 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9766 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_icons.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index e261a6cbf0..291f846999 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -872,9 +872,10 @@ class acp_icons } } $db->sql_freeresult($result); - $template->assign_var('PAGINATION', generate_pagination( - $this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)); + $template->assign_var('PAGINATION', + generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true) + ); } } -- cgit v1.2.1 From 6cacfce937c64cae1f90dedef130f3a39fa2c317 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 17 Jul 2009 11:27:50 +0000 Subject: Ability to empty a user's outbox from the user ACP quick tools. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9767 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 55 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index c27c259b46..cb342ac300 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -495,6 +495,56 @@ class acp_users break; + case 'deloutbox': + + if (confirm_box(true)) + { + $msg_ids = array(); + $lang = 'EMPTY'; + + $sql = 'SELECT msg_id + FROM ' . PRIVMSGS_TO_TABLE . " + WHERE author_id = $user_id + AND folder_id = " . PRIVMSGS_OUTBOX; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + if (!function_exists('delete_pm')) + { + include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); + } + + do + { + $msg_ids[] = (int) $row['msg_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $db->sql_freeresult($result); + + delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); + + add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']); + + $lang = 'EMPTIED'; + } + $db->sql_freeresult($result); + + trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'u' => $user_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'update' => true)) + ); + } + break; + case 'moveposts': if (!check_form_key($form_name)) @@ -842,7 +892,7 @@ class acp_users if ($user_id == $user->data['user_id']) { - $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); + $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); if ($user_row['user_new']) { $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; @@ -862,12 +912,13 @@ class acp_users $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE')); } - $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); + $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) { $quick_tool_ary['reactivate'] = 'FORCE'; } + if ($user_row['user_new']) { $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; -- cgit v1.2.1 From ab9715a9fe5577921180a6f77b5a89b990665b6e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 17 Jul 2009 11:32:27 +0000 Subject: Fix bugs #46615 & #46945 - Fail gracefully if store folder is not writable during update. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9768 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_compress.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 881e1ba5cc..590daabf1d 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -155,7 +155,12 @@ class compress_zip extends compress */ function compress_zip($mode, $file) { - return $this->fp = @fopen($file, $mode . 'b'); + $this->fp = @fopen($file, $mode . 'b'); + + if (!$this->fp) + { + trigger_error('Unable to open file ' . $file . ' [' . $mode . 'b]'); + } } /** -- cgit v1.2.1 From 5f6db9584c4b2594c437a07c0ecd60390ff39d5e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 17 Jul 2009 13:21:03 +0000 Subject: Correct escaping/unescaping in the LDAP authentication plugin. #48175 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9769 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/auth/auth_ldap.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index 11c62ad0bc..b70e644b14 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -63,9 +63,11 @@ function init_ldap() // ldap_connect only checks whether the specified server is valid, so the connection might still fail $search = @ldap_search( $ldap, - $config['ldap_base_dn'], + htmlspecialchars_decode($config['ldap_base_dn']), ldap_user_filter($user->data['username']), - (empty($config['ldap_email'])) ? array($config['ldap_uid']) : array($config['ldap_uid'], $config['ldap_email']), + (empty($config['ldap_email'])) ? + array(htmlspecialchars_decode($config['ldap_uid'])) : + array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])), 0, 1 ); @@ -85,7 +87,7 @@ function init_ldap() return sprintf($user->lang['LDAP_NO_IDENTITY'], $user->data['username']); } - if (!empty($config['ldap_email']) && !isset($result[0][$config['ldap_email']])) + if (!empty($config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($config['ldap_email'])])) { return $user->lang['LDAP_NO_EMAIL']; } @@ -152,7 +154,7 @@ function login_ldap(&$username, &$password) if ($config['ldap_user'] || $config['ldap_password']) { - if (!@ldap_bind($ldap, $config['ldap_user'], htmlspecialchars_decode($config['ldap_password']))) + if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password']))) { return $user->lang['LDAP_NO_SERVER_CONNECTION']; } @@ -160,9 +162,11 @@ function login_ldap(&$username, &$password) $search = @ldap_search( $ldap, - $config['ldap_base_dn'], + htmlspecialchars_decode($config['ldap_base_dn']), ldap_user_filter($username), - (empty($config['ldap_email'])) ? array($config['ldap_uid']) : array($config['ldap_uid'], $config['ldap_email']), + (empty($config['ldap_email'])) ? + array(htmlspecialchars_decode($config['ldap_uid'])) : + array(htmlspecialchars_decode($config['ldap_uid']), htmlspecialchars_decode($config['ldap_email'])), 0, 1 ); @@ -223,7 +227,7 @@ function login_ldap(&$username, &$password) $ldap_user_row = array( 'username' => $username, 'user_password' => phpbb_hash($password), - 'user_email' => (!empty($config['ldap_email'])) ? $ldap_result[0][$config['ldap_email']][0] : '', + 'user_email' => (!empty($config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($config['ldap_email'])][0]) : '', 'group_id' => (int) $row['group_id'], 'user_type' => USER_NORMAL, 'user_ip' => $user->ip, -- cgit v1.2.1 From e4afce607529f7834776b588ca22ebb93647948e Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Fri, 17 Jul 2009 13:40:26 +0000 Subject: - Add hard limit for smilies git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9771 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/constants.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 2e2c239d89..2173f2ee68 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -161,6 +161,9 @@ define('BBCODE_UID_LEN', 8); // Number of core BBCodes define('NUM_CORE_BBCODES', 12); +// Smiley hard limit +define('SMILEY_LIMIT', 1000); + // Magic url types define('MAGIC_URL_EMAIL', 1); define('MAGIC_URL_FULL', 2); -- cgit v1.2.1 From 9b9298cfaa0612372926ba83feef39a2c6c215fe Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Fri, 17 Jul 2009 13:56:24 +0000 Subject: - Add hard limit for smilies git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9772 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_icons.php | 55 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 291f846999..fa1e324cc6 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -231,7 +231,7 @@ class acp_icons $data = $_images; } - $colspan = (($mode == 'smilies') ? '7' : '5'); + $colspan = (($mode == 'smilies') ? 7 : 5); $colspan += ($icon_id) ? 1 : 0; $colspan += ($action == 'add') ? 2 : 0; @@ -348,6 +348,25 @@ class acp_icons } } + if ($mode == 'smilies' && $action == 'create') + { + $smiley_count = $this->item_count($table); + + $addable_smileys_count = sizeof($images); + foreach ($images as $image) + { + if (!isset($image_add[$image])) + { + --$addable_smileys_count; + } + } + + if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) + { + trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); + } + } + $icons_updated = 0; $errors = array(); foreach ($images as $image) @@ -495,7 +514,6 @@ class acp_icons } } - // The user has already selected a smilies_pak file if ($current == 'delete') { @@ -541,6 +559,15 @@ class acp_icons $db->sql_freeresult($result); } + if ($mode == 'smilies') + { + $smiley_count = $this->item_count($table); + if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) + { + trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); + } + } + foreach ($pak_ary as $pak_entry) { $data = array(); @@ -837,11 +864,7 @@ class acp_icons $spacer = false; $pagination_start = request_var('start', 0); - $sql = "SELECT COUNT(*) AS count - FROM $table"; - $result = $db->sql_query($sql); - $item_count = (int) $db->sql_fetchfield('count'); - $db->sql_freeresult($result); + $item_count = $this->item_count($table); $sql = "SELECT * FROM $table @@ -877,6 +900,24 @@ class acp_icons generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true) ); } + + /** + * Returns the count of smilies or icons in the database + * + * @param string $table The table of items to count. + * @return int number of items + */ + /* private */ function item_count($table) + { + global $db; + + $sql = "SELECT COUNT(*) AS count + FROM $table"; + $result = $db->sql_query($sql); + $item_count = (int) $db->sql_fetchfield('count'); + $db->sql_freeresult($result); + return $item_count; + } } ?> \ No newline at end of file -- cgit v1.2.1 From 50e5bdf08cac2c98c233876a5439aefa1d77e436 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 17 Jul 2009 16:39:16 +0000 Subject: Small change to r9765, Bug #47495 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9773 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_database.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 575137ea2d..bf02a58dce 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -548,9 +548,7 @@ class base_extractor if (!$this->fp) { - global $user; - - trigger_error($user->lang['FILE_WRITE_FAIL'], E_USER_ERROR); + trigger_error('FILE_WRITE_FAIL', E_USER_ERROR); } } } -- cgit v1.2.1 From ba08191a7027969eabaa03c4369f8d9bae4fd7a6 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Sat, 18 Jul 2009 09:44:03 +0000 Subject: - PHP4 compatibility git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9776 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index eaaa8aaf6a..5b0a2340b5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3306,6 +3306,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = $msg_long_text; } + if (!defined('E_DEPRECATED')) + { + define('E_DEPRECATED', 8192); + } + switch ($errno) { case E_NOTICE: @@ -3481,6 +3486,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; + + // PHP4 comptibility + case E_DEPRECATED: + return true; + break; } // If we notice an error not handled here we pass this back to PHP by returning false -- cgit v1.2.1 From 0fe2b41cfca76b51eb14cc687f2a978b0f4a4da0 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 18 Jul 2009 10:02:06 +0000 Subject: #42925 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9777 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5b0a2340b5..d1a560f96d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1164,7 +1164,7 @@ function tz_select($default = '', $truncate = false) if (is_numeric($offset)) { $selected = ($offset == $default) ? ' selected="selected"' : ''; - $tz_select .= ''; + $tz_select .= ''; } } -- cgit v1.2.1 From b6a1271c3aedab008be367565db9c9713e22e638 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 18 Jul 2009 19:19:38 +0000 Subject: - added ability to filter logs by log_operation git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9781 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 62 +++++++++++++++++++++++++++++++++++++- phpBB/includes/functions_admin.php | 5 +-- 2 files changed, 64 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 12953173f1..c44592a23c 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -104,6 +104,65 @@ class acp_logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + $log_operation = request_var('log_operation', ''); + $s_lang_keys = ''; + + switch ($mode) + { + case 'admin': + $log_type = LOG_ADMIN; + $sql_forum = ''; + break; + + case 'mod': + $log_type = LOG_MOD; + + if ($topic_id) + { + $sql_forum = 'AND topic_id = ' . intval($topic_id); + } + else if (is_array($forum_id)) + { + $sql_forum = 'AND ' . $db->sql_in_set('forum_id', array_map('intval', $forum_id)); + } + else + { + $sql_forum = ($forum_id) ? 'AND forum_id = ' . intval($forum_id) : ''; + } + break; + + case 'user': + $log_type = LOG_USERS; + $sql_forum = 'AND reportee_id = ' . (int) $user_id; + break; + + case 'users': + $log_type = LOG_USERS; + $sql_forum = ''; + break; + + case 'critical': + $log_type = LOG_CRITICAL; + $sql_forum = ''; + break; + + default: + return; + } + + $sql = "SELECT DISTINCT log_operation + FROM " . LOG_TABLE . " + WHERE log_type = $log_type + " . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . + $sql_forum; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; + $s_lang_keys .= ''; + } + $db->sql_freeresult($result); + $l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS']; $l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN']; @@ -123,7 +182,7 @@ class acp_logs // Grab log data $log_data = array(); $log_count = 0; - view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort); + view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $log_operation); $template->assign_vars(array( 'L_TITLE' => $l_title, @@ -136,6 +195,7 @@ class acp_logs 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, + 'S_LANG_KEYS' => $s_lang_keys, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), ) ); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index b634410afc..dd6378a2b5 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2278,7 +2278,7 @@ function cache_moderators() /** * View log */ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC') +function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $log_operation = '') { global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; @@ -2333,7 +2333,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . + (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); -- cgit v1.2.1 From 94e29c3c170a1fd1e6c2794090232220ecb2d5f4 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 18 Jul 2009 21:20:20 +0000 Subject: Fix #45315 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9783 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/auth/auth_ldap.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index b70e644b14..a6092baba5 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -281,7 +281,8 @@ function ldap_user_filter($username) $filter = '(' . $config['ldap_uid'] . '=' . ldap_escape(htmlspecialchars_decode($username)) . ')'; if ($config['ldap_user_filter']) { - $filter = "(&$filter({$config['ldap_user_filter']}))"; + $_filter = ($config['ldap_user_filter'][0] == '(' && substr($config['ldap_user_filter'], -1) == ')') ? $config['ldap_user_filter'] : "({$config['ldap_user_filter']})"; + $filter = "(&{$filter}{$_filter})"; } return $filter; } -- cgit v1.2.1 From d61afd3509de3823c4f405fc95f8f799f073c505 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 18 Jul 2009 23:29:25 +0000 Subject: Ensure user errors are displayed regardless of PHP settings. #47505 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9785 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d1a560f96d..2dd28b2ffe 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3295,7 +3295,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text; // Do not display notices if we suppress them via @ - if (error_reporting() == 0) + if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) { return; } -- cgit v1.2.1 From ba0d8b5a55ae69e228f303c01ba0fe2f545489ee Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sat, 18 Jul 2009 23:37:09 +0000 Subject: Initial commit for the QA captcha. Needs language & style finetuning and bug searching & fixing git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9786 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 758 +++++++++++++++++++++ 1 file changed, 758 insertions(+) create mode 100755 phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php new file mode 100755 index 0000000000..fe8a14c70f --- /dev/null +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -0,0 +1,758 @@ +add_lang('captcha_qa'); + // read input + $this->confirm_id = request_var('confirm_id', ''); + $this->answer = request_var('answer', ''); + + $this->type = (int) $type; + $this->question_lang = $user->data['user_lang']; + + $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\''; + $result = $db->sql_query($sql, 3600); + while ($row = $db->sql_fetchrow($result)) + { + $this->question_ids[$row['question_id']] = $row['question_id']; + } + $db->sql_freeresult($result); + if (!sizeof($this->question_ids)) + { + $this->question_lang = $config['default_lang']; + $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + $result = $db->sql_query($sql, 7200); + while ($row = $db->sql_fetchrow($result)) + { + $this->question_ids[$row['question_id']] = $row['question_id']; + } + $db->sql_freeresult($result); + } + + if (!strlen($this->confirm_id) || !$this->load_answer()) + { + // we have no confirm ID, better get ready to display something + $this->select_question(); + } + } + + + function &get_instance() + { + $instance =& new phpbb_captcha_qa(); + return $instance; + } + + + function is_installed() + { + global $db, $phpbb_root_path, $phpEx; + + if (!class_exists('phpbb_db_tools')) + { + include("$phpbb_root_path/includes/db/db_tools.$phpEx"); + } + $db_tool = new phpbb_db_tools($db); + if (!$db_tool->sql_table_exists(QUESTIONS_TABLE)) + { + return false; + } + } + + function is_available() + { + global $config, $db, $phpbb_root_path, $phpEx, $user; + + $user->add_lang('captcha_qa'); + + if (self::is_installed()) + { + return false; + } + $sql = 'SELECT COUNT(question_id) as count FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + return ((bool) $row['count']); + } + + function get_name() + { + return 'CAPTCHA_QA'; + } + + function get_class_name() + { + return 'phpbb_captcha_qa'; + } + + + function execute_demo() + { + } + + function execute() + { + } + + function get_template() + { + global $config, $user, $template, $phpEx, $phpbb_root_path; + + $template->assign_vars(array( + 'CONFIRM_QUESTION' => $this->question_text, + 'CONFIRM_ID' => $this->confirm_id, + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); + + return 'captcha_qa.html'; + } + + function get_demo_template($id) + { + return 'captcha_qa_acp_demo.html'; + } + + function get_hidden_fields() + { + $hidden_fields = array(); + + // this is required - otherwise we would forget about the captcha being already solved + if ($this->solved) + { + $hidden_fields['answer'] = $this->answer; + } + $hidden_fields['confirm_id'] = $this->confirm_id; + return $hidden_fields; + } + + function garbage_collect($type) + { + global $db, $config; + + $sql = 'SELECT DISTINCT c.session_id + FROM ' . QA_CONFIRM_TABLE . ' c + LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) + WHERE s.session_id IS NULL' . + ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $sql_in = array(); + do + { + $sql_in[] = (string) $row['session_id']; + } + while ($row = $db->sql_fetchrow($result)); + + if (sizeof($sql_in)) + { + $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . ' + WHERE ' . $db->sql_in_set('session_id', $sql_in); + $db->sql_query($sql); + } + } + $db->sql_freeresult($result); + } + + function uninstall() + { + $this->garbage_collect(0); + } + + function install() + { + global $db, $phpbb_root_path, $phpEx; + + if (!class_exists('phpbb_db_tools')) + { + include("$phpbb_root_path/includes/db/db_tools.$phpEx"); + } + $db_tool = new phpbb_db_tools($db); + $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE, QA_CONFIRM_TABLE); + + $schemas = array( + QUESTIONS_TABLE => array ( + 'COLUMNS' => array( + 'question_id' => array('UINT', Null, 'auto_increment'), + 'strict' => array('BOOL', 0), + 'lang_id' => array('UINT', 0), + 'lang_iso' => array('VCHAR:30', 0), + 'question_text' => array('TEXT', 0), + ), + 'PRIMARY_KEY' => 'question_id', + 'KEYS' => array( + 'question_id' => array('INDEX', array('question_id', 'language_iso')), + ), + ), + ANSWERS_TABLE => array ( + 'COLUMNS' => array( + 'question_id' => array('UINT', 0), + 'answer_text' => array('TEXT', 0), + ), + 'KEYS' => array( + 'question_id' => array('INDEX', 'question_id'), + ), + ), + QA_CONFIRM_TABLE => array ( + 'COLUMNS' => array( + 'session_id' => array('CHAR:32', ''), + 'confirm_id' => array('CHAR:32', ''), + 'lang_iso' => array('VCHAR:30', 0), + 'question_id' => array('UINT', 0), + 'attempts' => array('UINT', 0), + 'confirm_type' => array('USINT', 0), + ), + 'KEYS' => array( + 'confirm_id' => array('INDEX', 'confirm_id'), + 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), + ), + 'PRIMARY_KEY' => 'confirm_id', + ), + ); + + + foreach($schemas as $table => $schema) + { + if (!$db_tool->sql_table_exists($table)) + { + $db_tool->sql_create_table($table, $schema); + } + } + } + + + function validate() + { + global $config, $db, $user; + + $error = ''; + if (!$this->confirm_id) + { + $error = $user->lang['CONFIRM_QUESTION_WRONG']; + } + else + { + if ($this->check_answer()) + { + // $this->delete_code(); commented out to allow posting.php to repeat the question + $this->solved = true; + } + else + { + $error = $user->lang['CONFIRM_QUESTION_WRONG']; + } + } + + if (strlen($error)) + { + // okay, incorrect answer. Let's ask a new question. + $this->new_attempt(); + return $error; + } + else + { + return false; + } + } + + /** + * Select a question + */ + function select_question() + { + global $db, $user; + + $this->confirm_id = md5(unique_id($user->ip)); + $this->question = (int) array_rand($this->question_ids); + + $sql = 'INSERT INTO ' . QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'confirm_id' => (string) $this->confirm_id, + 'session_id' => (string) $user->session_id, + 'lang_iso' => (string) $this->question_lang, + 'confirm_type' => (int) $this->type, + 'question_id' => (int) $this->question, + )); + $db->sql_query($sql); + $this->load_answer(); + + } + + /** + * New Question, if desired. + */ + function reselect_question() + { + global $db, $user; + + $this->question = (int) array_rand($this->question_ids); + $this->solved = 0; + // compute $seed % 0x7fffffff + + $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'question' => (int) $this->question,)) . ' + WHERE + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; + $db->sql_query($sql); + $this->load_answer(); + } + + /** + * New Question, if desired. + */ + function new_attempt() + { + global $db, $user; + + $this->question = (int) array_rand($this->question_ids); + $this->solved = 0; + // compute $seed % 0x7fffffff + + $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'question_id' => (int) $this->question)) . ', + attempts = attempts + 1 + WHERE + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; + $db->sql_query($sql); + $this->load_answer(); + } + + /** + * Look up everything we need. + */ + function load_answer() + { + global $db, $user; + + $sql = 'SELECT con.question_id, attempts, question_text, strict + FROM ' . QA_CONFIRM_TABLE . ' con, ' . QUESTIONS_TABLE . " qes + WHERE con.question_id = qes.question_id + AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND qes.lang_iso = '" . $db->sql_escape($this->question_lang) . "' + AND confirm_type = " . $this->type; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + $this->question = $row['question_id']; + + $this->attempts = $row['attempts']; + $this->question_strict = $row['strict']; + $this->question_text = $row['question_text']; + return true; + } + return false; + } + + function check_answer() + { + global $db; + + $answer = ($this->question_strict) ? request_var('answer', '') : utf8_clean_string(request_var('answer', '')); + + $sql = 'SELECT answer_text + FROM ' . ANSWERS_TABLE . ' + WHERE question_id = ' . (int) $this->question; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $solution = ($this->question_strict) ? $row['answer_text'] : utf8_clean_string($row['answer_text'] ); + if ($solution === $answer) + { + $this->solved = true; + break; + } + } + $db->sql_freeresult($result); + return $this->solved; + } + + function delete_code() + { + global $db, $user; + + $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . " + WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . $this->type; + $db->sql_query($sql); + } + + function get_attempt_count() + { + return $this->attempts; + } + + function reset() + { + global $db, $user; + + $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . " + WHERE session_id = '" . $db->sql_escape($user->session_id) . "' + AND confirm_type = " . (int) $this->type; + $db->sql_query($sql); + + // we leave the class usable by generating a new question + $this->generate_code(); + } + + function is_solved() + { + if (request_var('answer', false) && $this->solved === 0) + { + $this->validate(); + } + return (bool) $this->solved; + } + + function acp_page($id, &$module) + { + global $db, $user, $auth, $template; + global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + + $user->add_lang('acp/board'); + $user->add_lang('captcha_qa'); + + if (!$this->is_installed()) + { + $this->install(); + } + $module->tpl_name = 'captcha_qa_acp'; + $module->page_title = 'ACP_VC_SETTINGS'; + $form_key = 'acp_captcha'; + add_form_key($form_key); + + $submit = request_var('submit', false); + $question_id = request_var('question_id', 0); + $action = request_var('action', ''); + + + $template->assign_vars(array( + 'U_ACTION' => $module->u_action, + 'QUESTION_ID' => $question_id , + 'CLASS' => $this->get_class_name(), + )); + + if (!$question_id && $action != 'add') + { + $this->acp_question_list($module); + } + else if ($question_id && $action == 'delete') + { + if (confirm_box(true)) + { + $this->acp_delete_question($question_id); + trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($module->u_action)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'question_id' => $question_id, + 'action' => $action, + 'configure' => 1, + 'select_captcha' => $this->get_class_name(), + )) + ); + } + } + else + { + + $error = false; + $input_question = request_var('question_text', ''); + $input_answers = request_var('answers', ''); + $input_lang = request_var('lang_iso', ''); + $input_strict = request_var('strict', false); + $langs = $this->get_languages(); + foreach ($langs as $lang => $entry) + { + $template->assign_block_vars('langs', array( + 'ISO' => $lang, + 'NAME' => $entry['name'], + )); + } + + if ($question_id) + { + if ($question = $this->acp_get_question_data($question_id)) + { + $answers = (isset($input_answers[$lang])) ? $input_answers[$lang] : implode("\n", $question['answers']); + $template->assign_vars(array( + 'QUESTION_TEXT' => ($input_question) ? $input_question : $question['question_text'], + 'LANG_ISO' => ($input_lang) ? $input_lang : $question['lang_iso'], + 'STRICT' => (isset($_REQUEST['strict'])) ? $input_strict : $question['strict'], + 'ANSWERS' => $answers, + )); + } + else + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + } + } + else + { + + $template->assign_vars(array( + 'QUESTION_TEXT' => $input_question, + 'LANG_ISO' => $input_lang, + 'STRICT' => $input_strict, + 'ANSWERS' => $input_answers, + )); + } + + if ($submit && check_form_key($form_key)) + { + $data = $this->acp_get_question_input(); + if (!$this->validate_input($data)) + { + $template->assign_vars(array( + 'S_ERROR' => true, + )); + } + else + { + if ($question_id) + { + $this->acp_update_question($data, $question_id); + } + else + { + $this->acp_add_question($data); + } + + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action . "&configure=1&select_captcha=" . $this->get_class_name())); + } + } + else if ($submit) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + } + } + } + + function acp_question_list(&$module) + { + global $db, $template; + + $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE 1'; + $result = $db->sql_query($sql); + $template->assign_vars(array( + 'S_LIST' => true, + )); + + while($row = $db->sql_fetchrow($result)) + { + $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_class_name() . "&"; + + $template->assign_block_vars('questions', array( + 'QUESTION_TEXT' => $row['question_text'], + 'QUESTION_ID' => $row['question_id'], + 'QUESTION_LANG' => $row['lang_iso'], + 'U_DELETE' => "{$url}action=delete", + 'U_EDIT' => "{$url}action=edit", + )); + } + $db->sql_freeresult($result); + } + + function acp_get_question_data($question_id) + { + global $db; + + + if ($question_id) + { + $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id; + $result = $db->sql_query($sql); + if ($row = $db->sql_fetchrow($result)) + { + $question = $row; + } + else + { + $db->sql_freeresult($result); + return false; + } + $question['answers'] = array(); + $sql = 'SELECT * FROM ' . ANSWERS_TABLE . ' WHERE question_id = ' . $question_id; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $question['answers'][] = $row['answer_text']; + } + $db->sql_freeresult($result); + return $question; + } + + } + + + function acp_get_question_input() + { + global $db; + + $question = array( + 'question_text' => request_var('question_text', ''), + 'strict' => request_var('strict', false), + 'lang_iso' => request_var('lang_iso', ''), + 'answers' => explode("\n", request_var('answers', '')), + ); + + return $question; + } + + + + function acp_update_question($data, $question_id) + { + global $db; + + $sql = "DELETE FROM " . ANSWERS_TABLE . " WHERE question_id = $question_id"; + $db->sql_query($sql); + $langs = $this->get_languages(); + $question_ary = $data; + $question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id']; + unset($question_ary['answers']); + $sql = "UPDATE " . QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . " + WHERE question_id = $question_id"; + $db->sql_query($sql); + $this->acp_insert_answers($data, $question_id); + } + + function acp_add_question($data) + { + global $db; + + $langs = $this->get_languages(); + $question_ary = $data; + + $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; + unset($question_ary['answers']); + $sql = "INSERT INTO " . QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); + $db->sql_query($sql); + $question_id = $db->sql_nextid(); + $this->acp_insert_answers($data, $question_id); + } + + function acp_insert_answers($data, $question_id) + { + global $db; + + foreach($data['answers'] as $answer) + { + $answer_ary = array( + 'question_id' => $question_id, + 'answer_text' => $answer, + ); + $sql = "INSERT INTO " . ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); + $db->sql_query($sql); + } + } + + + + function acp_delete_question($question_id) + { + global $db; + + $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE); + foreach($tables as $table) + { + $sql = "DELETE FROM $table WHERE question_id = $question_id"; + $db->sql_query($sql); + } + } + + + function validate_input($question_data) + { + $langs = $this->get_languages(); + if (!isset($question_data['lang_iso']) || + !isset($question_data['question_text']) || + !isset($question_data['strict']) || + !isset($question_data['answers'])) + { + return false; + } + if (!isset($langs[$question_data['lang_iso']]) || + !$question_data['question_text'] || + !sizeof($question_data['answers'])) + { + return false; + } + + return true; + } + + function get_languages() + { + global $db; + + $langs = array(); + $sql = 'SELECT * FROM ' . LANG_TABLE . ' WHERE 1'; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $langs[$row['lang_iso']] = array( + 'name' => $row['lang_local_name'], + 'id' => $row['lang_id'], + ); + } + $db->sql_freeresult($result); + return $langs; + } + +} + +?> \ No newline at end of file -- cgit v1.2.1 From 08a7255c8eb517a2b536e7be1f198619a30c7f69 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sat, 18 Jul 2009 23:39:45 +0000 Subject: Initial commit for the QA captcha. Needs language & style finetuning and bug searching & fixing git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9787 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php old mode 100755 new mode 100644 -- cgit v1.2.1 From 4f6f9c424d124ec3839809828bbe45ae7a17436a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 19 Jul 2009 00:20:03 +0000 Subject: Permit null values for non-required integer custom profile fields and ensure zero complies with the range limits. #40925 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9788 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_profile_fields.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index bb1ec476c4..9e356414a9 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -90,18 +90,6 @@ class custom_profile */ function validate_profile_field($field_type, &$field_value, $field_data) { - switch ($field_type) - { - case FIELD_INT: - case FIELD_DROPDOWN: - $field_value = (int) $field_value; - break; - - case FIELD_BOOL: - $field_value = (bool) $field_value; - break; - } - switch ($field_type) { case FIELD_DATE: @@ -133,6 +121,8 @@ class custom_profile break; case FIELD_BOOL: + $field_value = (bool) $field_value; + if (!$field_value && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -140,10 +130,12 @@ class custom_profile break; case FIELD_INT: - if (empty($field_value) && !$field_data['field_required']) + if (trim($field_value) === '' && !$field_data['field_required']) { return false; } + + $field_value = (int) $field_value; if ($field_value < $field_data['field_minlen']) { @@ -156,6 +148,8 @@ class custom_profile break; case FIELD_DROPDOWN: + $field_value = (int) $field_value; + if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { return 'FIELD_REQUIRED'; @@ -514,7 +508,7 @@ class custom_profile switch ($this->profile_types[$field_type]) { case 'int': - if ($value == '') + if ($value === '') { return NULL; } @@ -644,7 +638,7 @@ class custom_profile } } - return (is_null($value)) ? '' : (int) $value; + return (is_null($value) || $value === '') ? '' : (int) $value; } else { -- cgit v1.2.1 From 208f74970b15d255a83f9c9a58c5ba4ddf596b86 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 19 Jul 2009 01:00:33 +0000 Subject: Allow changing forum from drop down under certain circumstances. #37525 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9789 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_reports.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 27d841c81b..cc701a0540 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -258,7 +258,7 @@ class mcp_reports } unset($forum_list_read); - if ($topic_id && $forum_id) + if ($topic_id) { $topic_info = get_topic_data(array($topic_id)); @@ -267,12 +267,15 @@ class mcp_reports trigger_error('TOPIC_NOT_EXIST'); } - $topic_info = $topic_info[$topic_id]; - $forum_id = $topic_info['forum_id']; - } - else if ($topic_id && !$forum_id) - { - $topic_id = 0; + if ($forum_id != $topic_info[$topic_id]['forum_id']) + { + $topic_id = 0; + } + else + { + $topic_info = $topic_info[$topic_id]; + $forum_id = (int) $topic_info['forum_id']; + } } $forum_list = array(); -- cgit v1.2.1 From 45e127fc64bd6876aedd77e4d28d74a547baae04 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 19 Jul 2009 09:51:25 +0000 Subject: First round of fixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9793 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index fe8a14c70f..bcb1370a1b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -97,10 +97,7 @@ class phpbb_captcha_qa include("$phpbb_root_path/includes/db/db_tools.$phpEx"); } $db_tool = new phpbb_db_tools($db); - if (!$db_tool->sql_table_exists(QUESTIONS_TABLE)) - { - return false; - } + return $db_tool->sql_table_exists(QUESTIONS_TABLE); } function is_available() @@ -109,7 +106,7 @@ class phpbb_captcha_qa $user->add_lang('captcha_qa'); - if (self::is_installed()) + if (!self::is_installed()) { return false; } -- cgit v1.2.1 From a8c759a033195431b35137987fed2d0a556c6a1a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 19 Jul 2009 09:51:50 +0000 Subject: First round of fixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9794 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index bcb1370a1b..1992117e09 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -225,7 +225,7 @@ class phpbb_captcha_qa ), 'PRIMARY_KEY' => 'question_id', 'KEYS' => array( - 'question_id' => array('INDEX', array('question_id', 'language_iso')), + 'question_id' => array('INDEX', array('question_id', 'lang_iso')), ), ), ANSWERS_TABLE => array ( -- cgit v1.2.1 From 21094ac790ff2206cf8e07b89b7d5130db63e03c Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 19 Jul 2009 11:34:01 +0000 Subject: Copy poll options properly when copying topic. #39065 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9797 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_main.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 0dfe3b0086..3c265d56da 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1064,7 +1064,9 @@ function mcp_fork_topic($topic_ids) 'topic_bumper' => (int) $topic_row['topic_bumper'], 'poll_title' => (string) $topic_row['poll_title'], 'poll_start' => (int) $topic_row['poll_start'], - 'poll_length' => (int) $topic_row['poll_length'] + 'poll_length' => (int) $topic_row['poll_length'], + 'poll_max_options' => (int) $topic_row['poll_max_options'], + 'poll_vote_change' => (int) $topic_row['poll_vote_change'], ); $db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); -- cgit v1.2.1 From b3767cd1436bf2b579ad2e0c1c17f55881d4dc4e Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Mon, 20 Jul 2009 00:57:18 +0000 Subject: - added filtration ability to MCP - added missing lang variable - fixed a pagination bug in filtration routines git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9800 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 6 +++++- phpBB/includes/functions_admin.php | 3 ++- phpBB/includes/mcp/mcp_logs.php | 36 +++++++++++++++++++++++++++++++++++- phpBB/includes/mcp/mcp_notes.php | 22 +++++++++++++++++++++- 4 files changed, 63 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index c44592a23c..f13979ec0f 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -158,8 +158,12 @@ class acp_logs $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { + if (empty($row['log_operation'])) + { + continue; + } $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - $s_lang_keys .= ''; + $s_lang_keys .= ''; } $db->sql_freeresult($result); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index dd6378a2b5..ff7f687945 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2499,7 +2499,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql = 'SELECT COUNT(l.log_id) AS total_entries FROM ' . LOG_TABLE . " l WHERE l.log_type = $log_type - AND l.log_time >= $limit_days + AND l.log_time >= $limit_days " . + (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum"; $result = $db->sql_query($sql); $log_count = (int) $db->sql_fetchfield('total_entries'); diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index a6b1935c88..b83e364811 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -164,10 +164,43 @@ class mcp_logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + $log_operation = request_var('log_operation', ''); + $s_lang_keys = ''; + + if ($topic_id) + { + $sql_forum = 'AND topic_id = ' . intval($topic_id); + } + else if (is_array($forum_id)) + { + $sql_forum = 'AND ' . $db->sql_in_set('forum_id', array_map('intval', $forum_id)); + } + else + { + $sql_forum = ($forum_id) ? 'AND forum_id = ' . intval($forum_id) : ''; + } + + $sql = "SELECT DISTINCT log_operation + FROM " . LOG_TABLE . ' + WHERE log_type = ' . LOG_MOD . ' + ' . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . + $sql_forum; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + if (empty($row['log_operation'])) + { + continue; + } + $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; + $s_lang_keys .= ''; + } + $db->sql_freeresult($result); + // Grab log data $log_data = array(); $log_count = 0; - view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort); + view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $log_operation); $template->assign_vars(array( 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), @@ -181,6 +214,7 @@ class mcp_logs 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, + 'S_LANG_KEYS' => $s_lang_keys, 'S_LOGS' => ($log_count > 0), ) ); diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 7480b24a46..d07874524a 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -193,9 +193,28 @@ class mcp_notes $sql_where = ($st) ? (time() - ($st * 86400)) : 0; $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); + $log_operation = request_var('log_operation', ''); + $s_lang_keys = ''; + + $sql = "SELECT DISTINCT log_operation + FROM " . LOG_TABLE . ' + WHERE log_type = ' . LOG_USERS . + (($limit_days) ? " AND log_time >= $sql_where" : ''); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + if (empty($row['log_operation'])) + { + continue; + } + $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; + $s_lang_keys .= ''; + } + $db->sql_freeresult($result); + $log_data = array(); $log_count = 0; - view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); + view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $log_operation); if ($log_count) { @@ -219,6 +238,7 @@ class mcp_notes 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, + 'S_LANG_KEYS' => $s_lang_keys, 'L_TITLE' => $user->lang['MCP_NOTES_USER'], -- cgit v1.2.1 From ff60fc9c1e6565eb12f4c8f4591c5cafc012bfb7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 20 Jul 2009 10:22:13 +0000 Subject: fixing back links git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9801 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 12 ++++++++---- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 1992117e09..d6ef8f50b1 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -474,6 +474,7 @@ class phpbb_captcha_qa $question_id = request_var('question_id', 0); $action = request_var('action', ''); + $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_class_name(); $template->assign_vars(array( 'U_ACTION' => $module->u_action, @@ -490,7 +491,7 @@ class phpbb_captcha_qa if (confirm_box(true)) { $this->acp_delete_question($question_id); - trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($module->u_action)); + trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); } else { @@ -520,6 +521,9 @@ class phpbb_captcha_qa )); } + $template->assign_vars(array( + 'U_LIST' => $list_url, + )); if ($question_id) { if ($question = $this->acp_get_question_data($question_id)) @@ -534,7 +538,7 @@ class phpbb_captcha_qa } else { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); } } else @@ -568,12 +572,12 @@ class phpbb_captcha_qa $this->acp_add_question($data); } - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action . "&configure=1&select_captcha=" . $this->get_class_name())); + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url)); } } else if ($submit) { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); } } } diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 41ce242e91..f148b12656 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -36,7 +36,7 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $db, $user; - $user->add_lang('recaptcha'); + $user->add_lang('captcha_recaptcha'); parent::init($type); $this->challenge = request_var('recaptcha_challenge_field', ''); $this->response = request_var('recaptcha_response_field', ''); @@ -51,7 +51,7 @@ class phpbb_recaptcha extends phpbb_default_captcha function is_available() { global $config, $user; - $user->add_lang('recaptcha'); + $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } -- cgit v1.2.1 From 04b948c5fd8e7bf8be35c1cedf9bdab1f309e0cb Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 20 Jul 2009 10:42:27 +0000 Subject: cleaning git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9803 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 133 ++++++++++++++++++--- 1 file changed, 116 insertions(+), 17 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index d6ef8f50b1..fdbbf1d218 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -24,6 +24,7 @@ define('QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm'); /** +* And now to something completely different. Let's make a captcha without extending the abstract class. * QA CAPTCHA sample implementation * * @package VC @@ -39,9 +40,12 @@ class phpbb_captcha_qa var $question_strict; var $attempts = 0; var $type; + // dirty trick: 0 is false, but can still encode that the captcha is not yet validated var $solved = 0; - var $captcha_vars = false; + /** + * @param int $type as per the CAPTCHA API docs, the type + */ function init($type) { global $config, $db, $user; @@ -53,7 +57,8 @@ class phpbb_captcha_qa $this->type = (int) $type; $this->question_lang = $user->data['user_lang']; - + // we need all defined questions - shouldn't be too many, so we can just grab them + // try the user's lang first $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\''; $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) @@ -61,6 +66,7 @@ class phpbb_captcha_qa $this->question_ids[$row['question_id']] = $row['question_id']; } $db->sql_freeresult($result); + // fallback to the board default lang if (!sizeof($this->question_ids)) { $this->question_lang = $config['default_lang']; @@ -73,21 +79,26 @@ class phpbb_captcha_qa $db->sql_freeresult($result); } + // okay, if there is a confirm_id, we try to load that confirm's state if (!strlen($this->confirm_id) || !$this->load_answer()) { - // we have no confirm ID, better get ready to display something + // we have no valid confirm ID, better get ready to ask something $this->select_question(); } } - + /** + * API function + */ function &get_instance() { $instance =& new phpbb_captcha_qa(); return $instance; } - + /** + * See if the captcha has created its tables. + */ function is_installed() { global $db, $phpbb_root_path, $phpEx; @@ -100,6 +111,9 @@ class phpbb_captcha_qa return $db_tool->sql_table_exists(QUESTIONS_TABLE); } + /** + * API function - for the captcha to be available, it must have installed itself and there has to be at least one question in the board's default lang + */ function is_available() { global $config, $db, $phpbb_root_path, $phpEx, $user; @@ -117,28 +131,43 @@ class phpbb_captcha_qa return ((bool) $row['count']); } + /** + * API function + */ function get_name() { return 'CAPTCHA_QA'; } + /** + * API function + */ function get_class_name() { return 'phpbb_captcha_qa'; } + /** + * API function - not needed as we don't display an image + */ function execute_demo() { } + /** + * API function - not needed as we don't display an image + */ function execute() { } + /** + * API function - send the question to the template + */ function get_template() { - global $config, $user, $template, $phpEx, $phpbb_root_path; + global $template; $template->assign_vars(array( 'CONFIRM_QUESTION' => $this->question_text, @@ -150,11 +179,17 @@ class phpbb_captcha_qa return 'captcha_qa.html'; } - function get_demo_template($id) + /** + * API function - we just display a mockup so that the captcha doesn't need to be installed + */ + function get_demo_template() { return 'captcha_qa_acp_demo.html'; } + /** + * API function + */ function get_hidden_fields() { $hidden_fields = array(); @@ -168,6 +203,9 @@ class phpbb_captcha_qa return $hidden_fields; } + /** + * API function + */ function garbage_collect($type) { global $db, $config; @@ -198,11 +236,17 @@ class phpbb_captcha_qa $db->sql_freeresult($result); } + /** + * API function - we don't drop the tables here, as that would cause the loss of all entered questions. + */ function uninstall() { $this->garbage_collect(0); } + /** + * API function - set up shop + */ function install() { global $db, $phpbb_root_path, $phpEx; @@ -226,6 +270,7 @@ class phpbb_captcha_qa 'PRIMARY_KEY' => 'question_id', 'KEYS' => array( 'question_id' => array('INDEX', array('question_id', 'lang_iso')), + 'lang_iso' => array('INDEX', 'lang_iso'), ), ), ANSWERS_TABLE => array ( @@ -254,7 +299,6 @@ class phpbb_captcha_qa ), ); - foreach($schemas as $table => $schema) { if (!$db_tool->sql_table_exists($table)) @@ -265,6 +309,9 @@ class phpbb_captcha_qa } + /** + * API function - see what has to be done to validate + */ function validate() { global $config, $db, $user; @@ -342,12 +389,13 @@ class phpbb_captcha_qa } /** - * New Question, if desired. + * Wrong answer, so we increase the attempts and use a different question. */ function new_attempt() { global $db, $user; + // yah, I would prefer a stronger rand, but this should work $this->question = (int) array_rand($this->question_ids); $this->solved = 0; // compute $seed % 0x7fffffff @@ -363,7 +411,7 @@ class phpbb_captcha_qa } /** - * Look up everything we need. + * Look up everything we need and populate the instance variables. */ function load_answer() { @@ -392,6 +440,9 @@ class phpbb_captcha_qa return false; } + /** + * The actual validation + */ function check_answer() { global $db; @@ -415,6 +466,9 @@ class phpbb_captcha_qa return $this->solved; } + /** + * API function - clean the entry + */ function delete_code() { global $db, $user; @@ -426,11 +480,17 @@ class phpbb_captcha_qa $db->sql_query($sql); } + /** + * API function + */ function get_attempt_count() { return $this->attempts; } + /** + * API function + */ function reset() { global $db, $user; @@ -443,7 +503,10 @@ class phpbb_captcha_qa // we leave the class usable by generating a new question $this->generate_code(); } - + + /** + * API function + */ function is_solved() { if (request_var('answer', false) && $this->solved === 0) @@ -453,6 +516,10 @@ class phpbb_captcha_qa return (bool) $this->solved; } + + /** + * API function - The ACP backend, this marks the end of the easy methods + */ function acp_page($id, &$module) { global $db, $user, $auth, $template; @@ -474,6 +541,7 @@ class phpbb_captcha_qa $question_id = request_var('question_id', 0); $action = request_var('action', ''); + // we have two pages, so users might want to navigate from one to the other $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_class_name(); $template->assign_vars(array( @@ -481,7 +549,8 @@ class phpbb_captcha_qa 'QUESTION_ID' => $question_id , 'CLASS' => $this->get_class_name(), )); - + + // show the list? if (!$question_id && $action != 'add') { $this->acp_question_list($module); @@ -506,7 +575,7 @@ class phpbb_captcha_qa } else { - + // okay, show the editor $error = false; $input_question = request_var('question_text', ''); $input_answers = request_var('answers', ''); @@ -582,6 +651,10 @@ class phpbb_captcha_qa } } + + /** + * This handles the list overview + */ function acp_question_list(&$module) { global $db, $template; @@ -606,7 +679,10 @@ class phpbb_captcha_qa } $db->sql_freeresult($result); } - + + /** + * Grab a question and bring it into a format the editor understands + */ function acp_get_question_data($question_id) { global $db; @@ -639,6 +715,9 @@ class phpbb_captcha_qa } + /** + * Grab a question from input and bring it into a format the editor understands + */ function acp_get_question_input() { global $db; @@ -653,12 +732,15 @@ class phpbb_captcha_qa return $question; } - - + /** + * Update a question. + * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data + */ function acp_update_question($data, $question_id) { global $db; + // easier to delete all answers than to figure out which to update $sql = "DELETE FROM " . ANSWERS_TABLE . " WHERE question_id = $question_id"; $db->sql_query($sql); $langs = $this->get_languages(); @@ -671,6 +753,10 @@ class phpbb_captcha_qa $this->acp_insert_answers($data, $question_id); } + /** + * Insert a question. + * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data + */ function acp_add_question($data) { global $db; @@ -686,6 +772,10 @@ class phpbb_captcha_qa $this->acp_insert_answers($data, $question_id); } + /** + * Insert the answers. + * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data + */ function acp_insert_answers($data, $question_id) { global $db; @@ -702,7 +792,9 @@ class phpbb_captcha_qa } - + /** + * Delete a question. + */ function acp_delete_question($question_id) { global $db; @@ -716,6 +808,10 @@ class phpbb_captcha_qa } + /** + * Check if the entered data can be inserted/used + * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data + */ function validate_input($question_data) { $langs = $this->get_languages(); @@ -736,6 +832,9 @@ class phpbb_captcha_qa return true; } + /** + * List the installed language packs + */ function get_languages() { global $db; -- cgit v1.2.1 From 783da3064a2a4e7163230b75cacb6ef7073493dc Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 20 Jul 2009 18:27:26 +0000 Subject: rename variables to avoid name clashes in aggregating plugins git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9808 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index fdbbf1d218..cd5ee8c91d 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -50,10 +50,11 @@ class phpbb_captcha_qa { global $config, $db, $user; + // load our language file $user->add_lang('captcha_qa'); // read input - $this->confirm_id = request_var('confirm_id', ''); - $this->answer = request_var('answer', ''); + $this->confirm_id = request_var('qa_confirm_id', ''); + $this->answer = request_var('qa_answer', ''); $this->type = (int) $type; $this->question_lang = $user->data['user_lang']; @@ -118,6 +119,7 @@ class phpbb_captcha_qa { global $config, $db, $phpbb_root_path, $phpEx, $user; + // load language file for pretty display in the ACP dropdown $user->add_lang('captcha_qa'); if (!self::is_installed()) @@ -170,8 +172,8 @@ class phpbb_captcha_qa global $template; $template->assign_vars(array( - 'CONFIRM_QUESTION' => $this->question_text, - 'CONFIRM_ID' => $this->confirm_id, + 'QA_CONFIRM_QUESTION' => $this->question_text, + 'QA_CONFIRM_ID' => $this->confirm_id, 'S_CONFIRM_CODE' => true, 'S_TYPE' => $this->type, )); @@ -197,9 +199,9 @@ class phpbb_captcha_qa // this is required - otherwise we would forget about the captcha being already solved if ($this->solved) { - $hidden_fields['answer'] = $this->answer; + $hidden_fields['qa_answer'] = $this->answer; } - $hidden_fields['confirm_id'] = $this->confirm_id; + $hidden_fields['qa_confirm_id'] = $this->confirm_id; return $hidden_fields; } @@ -447,7 +449,7 @@ class phpbb_captcha_qa { global $db; - $answer = ($this->question_strict) ? request_var('answer', '') : utf8_clean_string(request_var('answer', '')); + $answer = ($this->question_strict) ? request_var('qa_answer', '') : utf8_clean_string(request_var('qa_answer', '')); $sql = 'SELECT answer_text FROM ' . ANSWERS_TABLE . ' @@ -509,7 +511,7 @@ class phpbb_captcha_qa */ function is_solved() { - if (request_var('answer', false) && $this->solved === 0) + if (request_var('qa_answer', false) && $this->solved === 0) { $this->validate(); } -- cgit v1.2.1 From 3a3872766177c30c580353c2946b0d308685a2c5 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 21 Jul 2009 10:26:18 +0000 Subject: copy regiustration attempt setting to acp_captcha - although the setting is pointless git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9809 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_captcha.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 2fc8fe7486..c3588ceb9e 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -52,9 +52,10 @@ class acp_captcha $captchas = phpbb_captcha_factory::get_captcha_types(); $config_vars = array( - 'enable_confirm' => 'REG_ENABLE', - 'enable_post_confirm' => 'POST_ENABLE', - 'confirm_refresh' => 'CONFIRM_REFRESH', + 'enable_confirm' => array('tpl' => 'REG_ENABLE', 'default' => false), + 'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false), + 'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false), + 'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0), ); $this->tpl_name = 'acp_captcha'; @@ -67,10 +68,9 @@ class acp_captcha if ($submit && check_form_key($form_key)) { $config_vars = array_keys($config_vars); - - foreach ($config_vars as $config_var) + foreach ($config_vars as $config_var => $options) { - set_config($config_var, request_var($config_var, false)); + set_config($config_var, request_var($config_var, $options['default'])); } if ($selected !== $config['captcha_plugin']) @@ -115,9 +115,9 @@ class acp_captcha $demo_captcha =& phpbb_captcha_factory::get_instance($selected); - foreach ($config_vars as $config_var => $template_var) + foreach ($config_vars as $config_var => $options) { - $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; + $template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ; } $template->assign_vars(array( -- cgit v1.2.1 From b613781d3af6d7c5e5d9d0fa1592e78b54647c0f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 21 Jul 2009 10:58:31 +0000 Subject: Preserve newlines in template files (one newline had been always dropped after a template variable due to PHP's handling of closing tags) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9811 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 11 +++++++++-- phpBB/includes/template.php | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index a951579db5..1d3a4d74f8 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -251,15 +251,22 @@ class template_compile $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); } + // Remove unused opening/closing tags + $template_php = str_replace(' ?>([\r\n])#', '?>\1\1', $template_php); + // There will be a number of occasions where we switch into and out of // PHP mode instantaneously. Rather than "burden" the parser with this // we'll strip out such occurences, minimising such switching if ($no_echo) { - return "\$$echo_var .= '" . str_replace(' ?>root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; + $this->_rootref = &$this->_tpldata['.'][0]; + return true; } -- cgit v1.2.1 From 6e4a7c03d14d6fcc03955fbe26c3d5f725eb929d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 21 Jul 2009 20:59:11 +0000 Subject: Users can report PMs to moderators which are then visible in a new MCP module git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9814 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/includes/functions_privmsgs.php | 92 +++++++- phpBB/includes/mcp/info/mcp_pm_reports.php | 39 ++++ phpBB/includes/mcp/mcp_front.php | 92 ++++++++ phpBB/includes/mcp/mcp_pm_reports.php | 323 +++++++++++++++++++++++++++++ phpBB/includes/mcp/mcp_reports.php | 170 ++++++++++----- phpBB/includes/ucp/ucp_pm_viewfolder.php | 73 +------ phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 + 8 files changed, 667 insertions(+), 125 deletions(-) create mode 100644 phpBB/includes/mcp/info/mcp_pm_reports.php create mode 100644 phpBB/includes/mcp/mcp_pm_reports.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 5966d5a4b2..3a2ad6f89a 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -81,6 +81,7 @@ class acp_board 'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_pm_report' => array('lang' => 'ALLOW_PM_REPORT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 8851b53680..883d8ff13f 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1405,7 +1405,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'to_address' => implode(':', $to), - 'bcc_address' => implode(':', $bcc) + 'bcc_address' => implode(':', $bcc), + 'message_reported' => 0, ); break; @@ -1880,4 +1881,93 @@ function set_user_message_limit() $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit; } +/** +* Generates an array of coloured recipient names from a list of PMs - (groups & users) +* +* @param array $pm_by_id An array of rows from PRIVMSGS_TABLE, keys are the msg_ids. +* +* @return array 2D Array: array(msg_id => array('username or group string', ...), ...) +* Usernames are generated with {@link get_username_string get_username_string} +* Groups are coloured and have a link to the membership page +*/ +function get_recipient_strings($pm_by_id) +{ + global $user, $db; + + $address_list = $recipient_list = $address = array(); + + $_types = array('u', 'g'); + + foreach ($pm_by_id as $message_id => $row) + { + $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); + + foreach ($_types as $ug_type) + { + if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) + { + foreach ($address[$message_id][$ug_type] as $ug_id => $in_to) + { + $recipient_list[$ug_type][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); + } + } + } + } + + foreach ($_types as $ug_type) + { + if (!empty($recipient_list[$ug_type])) + { + if ($ug_type == 'u') + { + $sql = 'SELECT user_id as id, username as name, user_colour as colour + FROM ' . USERS_TABLE . ' + WHERE '; + } + else + { + $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type + FROM ' . GROUPS_TABLE . ' + WHERE '; + } + $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); + + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if ($ug_type == 'g') + { + $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name']; + } + + $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); + } + $db->sql_freeresult($result); + } + } + + foreach ($address as $message_id => $adr_ary) + { + foreach ($adr_ary as $type => $id_ary) + { + foreach ($id_ary as $ug_id => $_id) + { + if ($type == 'u') + { + $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); + } + else + { + $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; + $link = ''; + $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '' : ''); + } + } + } + } + + return $address_list; +} + ?> \ No newline at end of file diff --git a/phpBB/includes/mcp/info/mcp_pm_reports.php b/phpBB/includes/mcp/info/mcp_pm_reports.php new file mode 100644 index 0000000000..103f560597 --- /dev/null +++ b/phpBB/includes/mcp/info/mcp_pm_reports.php @@ -0,0 +1,39 @@ + 'mcp_pm_reports', + 'title' => 'MCP_PM_REPORTS', + 'version' => '1.0.0', + 'modes' => array( + 'pm_reports' => array('title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report', 'cat' => array('MCP_REPORTS')), + 'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report', 'cat' => array('MCP_REPORTS')), + 'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report', 'cat' => array('MCP_REPORTS')), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 05c1b796ac..ee75c1daff 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -152,6 +152,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT COUNT(r.report_id) AS total FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p WHERE r.post_id = p.post_id + AND r.pm_id = 0 AND r.report_closed = 0 AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; $result = $db->sql_query($sql); @@ -181,6 +182,7 @@ function mcp_front_view($id, $mode, $action) ), 'WHERE' => 'r.post_id = p.post_id + AND r.pm_id = 0 AND r.report_closed = 0 AND r.reason_id = rr.reason_id AND p.topic_id = t.topic_id @@ -243,6 +245,96 @@ function mcp_front_view($id, $mode, $action) } } + // Latest 5 reported PMs + if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report')) + { + $template->assign_var('S_SHOW_PM_REPORTS', true); + + $sql = 'SELECT COUNT(r.report_id) AS total + FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p + WHERE r.post_id = 0 + AND r.pm_id = p.msg_id + AND r.report_closed = 0'; + $result = $db->sql_query($sql); + $total = (int) $db->sql_fetchfield('total'); + $db->sql_freeresult($result); + + if ($total) + { + include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); + $user->add_lang(array('ucp')); + + $sql = $db->sql_build_query('SELECT', array( + 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id', + + 'FROM' => array( + REPORTS_TABLE => 'r', + REPORTS_REASONS_TABLE => 'rr', + USERS_TABLE => array('u', 'u2'), + PRIVMSGS_TABLE => 'p' + ), + + 'WHERE' => 'r.pm_id = p.msg_id + AND r.post_id = 0 + AND r.report_closed = 0 + AND r.reason_id = rr.reason_id + AND r.user_id = u.user_id + AND p.author_id = u2.user_id', + + 'ORDER_BY' => 'p.message_time DESC' + )); + $result = $db->sql_query_limit($sql, 5); + + $pm_by_id = $pm_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $pm_by_id[(int) $row['msg_id']] = $row; + $pm_list[] = (int) $row['msg_id']; + } + + $address_list = get_recipient_strings($pm_by_id); + + foreach ($pm_list as $message_id) + { + $row = $pm_by_id[$message_id]; + + $template->assign_block_vars('pm_report', array( + 'U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"), + + 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), + + 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), + 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), + 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), + 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), + + 'PM_SUBJECT' => $row['message_subject'], + 'REPORT_TIME' => $user->format_date($row['report_time']), + 'PM_TIME' => $user->format_date($row['message_time']), + 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), + )); + } + } + + if ($total == 0) + { + $template->assign_vars(array( + 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], + 'S_HAS_PM_REPORTS' => false) + ); + } + else + { + $template->assign_vars(array( + 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), + 'S_HAS_REPORTS' => true) + ); + } + } + // Latest 5 logs if ($module->loaded('logs')) { diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php new file mode 100644 index 0000000000..0e94d7e017 --- /dev/null +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -0,0 +1,323 @@ +p_master = &$p_master; + } + + function main($id, $mode) + { + global $auth, $db, $user, $template, $cache; + global $config, $phpbb_root_path, $phpEx, $action; + + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); + + $start = request_var('start', 0); + + $this->page_title = 'MCP_PM_REPORTS'; + + switch ($action) + { + case 'close': + case 'delete': + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + + $report_id_list = request_var('report_id_list', array(0)); + + if (!sizeof($report_id_list)) + { + trigger_error('NO_REPORT_SELECTED'); + } + + if (!function_exists('close_report')) + { + include($phpbb_root_path . 'includes/mcp/mcp_reports.' . $phpEx); + } + + close_report($report_id_list, $mode, $action, true); + + break; + } + + switch ($mode) + { + case 'pm_report_details': + + $user->add_lang(array('posting', 'viewforum', 'viewtopic', 'ucp')); + + $report_id = request_var('r', 0); + + $sql = 'SELECT r.pm_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour + FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u + WHERE r.report_id = ' . $report_id . ' + AND rr.reason_id = r.reason_id + AND r.user_id = u.user_id + AND r.post_id = 0 + ORDER BY report_closed ASC'; + $result = $db->sql_query_limit($sql, 1); + $report = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$report_id || !$report) + { + trigger_error('NO_REPORT'); + } + + $pm_id = $report['pm_id']; + $report_id = $report['report_id']; + + $pm_info = get_pm_data(array($pm_id)); + + if (!sizeof($pm_info)) + { + trigger_error('NO_REPORT_SELECTED'); + } + + $pm_info = $pm_info[$pm_id]; + + write_pm_addresses(array('to' => $pm_info['to_address'], 'bcc' => $pm_info['bcc_address']), (int) $pm_info['author_id']); + + $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); + if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) + { + $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; + $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; + } + + // Process message, leave it uncensored + $message = $pm_info['message_text']; + + if ($pm_info['bbcode_bitfield']) + { + include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); + $bbcode = new bbcode($pm_info['bbcode_bitfield']); + $bbcode->bbcode_second_pass($message, $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield']); + } + + $message = bbcode_nl2br($message); + $message = smiley_text($message); + + if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) + { + $sql = 'SELECT * + FROM ' . ATTACHMENTS_TABLE . ' + WHERE post_msg_id = ' . $pm_id . ' + AND in_message = 1 + ORDER BY filetime DESC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $attachments[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($attachments)) + { + $update_count = array(); + parse_attachments(0, $message, $attachments, $update_count); + } + + // Display not already displayed Attachments for this post, we already parsed them. ;) + if (!empty($attachments)) + { + $template->assign_var('S_HAS_ATTACHMENTS', true); + + foreach ($attachments as $attachment) + { + $template->assign_block_vars('attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + } + + $template->assign_vars(array( + 'S_MCP_REPORT' => true, + 'S_PM' => true, + 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), + 'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'), + 'S_POST_REPORTED' => $pm_info['message_reported'], + 'S_USER_NOTES' => true, + + 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), + 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']), + 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']), + 'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', + 'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '', + + 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), + 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'), + + 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '', ''), + 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), + 'REPORT_DATE' => $user->format_date($report['report_time']), + 'REPORT_ID' => $report_id, + 'REPORT_REASON_TITLE' => $reason['title'], + 'REPORT_REASON_DESCRIPTION' => $reason['description'], + 'REPORT_TEXT' => $report['report_text'], + + 'POST_AUTHOR_FULL' => get_username_string('full', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), + 'POST_AUTHOR_COLOUR' => get_username_string('colour', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), + 'POST_AUTHOR' => get_username_string('username', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), + 'U_POST_AUTHOR' => get_username_string('profile', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), + + 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), + 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), + 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), + 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), + + 'POST_PREVIEW' => $message, + 'POST_SUBJECT' => ($pm_info['message_subject']) ? $pm_info['message_subject'] : $user->lang['NO_SUBJECT'], + 'POST_DATE' => $user->format_date($pm_info['message_time']), + 'POST_IP' => $pm_info['author_ip'], + 'POST_IPADDR' => ($auth->acl_getf_global('m_info') && request_var('lookup', '')) ? @gethostbyaddr($pm_info['author_ip']) : '', + 'POST_ID' => $pm_info['msg_id'], + + 'U_LOOKUP_IP' => ($auth->acl_getf_global('m_info')) ? $this->u_action . '&r=' . $report_id . '&pm=' . $pm_id . '&lookup=' . $pm_info['author_ip'] . '#ip' : '', + )); + + $this->tpl_name = 'mcp_post'; + + break; + + case 'pm_reports': + case 'pm_reports_closed': + $user->add_lang(array('ucp')); + + $sort_days = $total = 0; + $sort_key = $sort_dir = ''; + $sort_by_sql = $sort_order_sql = array(); + mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total); + + $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; + + if ($mode == 'pm_reports') + { + $report_state = 'pm.message_reported = 1 AND r.report_closed = 0'; + } + else + { + $report_state = 'r.report_closed = 1'; + } + + $sql = 'SELECT r.report_id + FROM ' . PRIVMSGS_TABLE . ' pm, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . " + WHERE $report_state + AND r.pm_id = pm.msg_id + " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = pm.author_id' : '') . ' + ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . " + AND r.post_id = 0 + $limit_time_sql + ORDER BY $sort_order_sql"; + $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); + + $i = 0; + $report_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $report_ids[] = $row['report_id']; + $row_num[$row['report_id']] = $i++; + } + $db->sql_freeresult($result); + + if (sizeof($report_ids)) + { + $sql = 'SELECT p.*, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id + FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru + WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . " + AND r.pm_id = p.msg_id + AND p.author_id = u.user_id + AND ru.user_id = r.user_id + ORDER BY $sort_order_sql"; + $result = $db->sql_query($sql); + + $pm_list = $pm_by_id = array(); + while ($row = $db->sql_fetchrow($result)) + { + $pm_by_id[(int) $row['msg_id']] = $row; + $pm_list[] = (int) $row['msg_id']; + } + $db->sql_freeresult($result); + + if (sizeof($pm_list)) + { + $address_list = get_recipient_strings($pm_by_id); + + foreach ($pm_list as $message_id) + { + $row = $pm_by_id[$message_id]; + $template->assign_block_vars('postrow', array( + 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=pm_reports&mode=pm_report_details&r={$row['report_id']}"), + + 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour']), + 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour']), + 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour']), + 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour']), + + 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), + 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), + 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), + 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), + + 'PM_SUBJECT' => ($row['message_subject']) ? $row['message_subject'] : $user->lang['NO_SUBJECT'], + 'PM_TIME' => $user->format_date($row['message_time']), + 'REPORT_ID' => $row['report_id'], + 'REPORT_TIME' => $user->format_date($row['report_time']), + + 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), + )); + } + } + } + + // Now display the page + $template->assign_vars(array( + 'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], + 'L_TITLE' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'], + + 'S_PM' => true, + 'S_MCP_ACTION' => $this->u_action, + 'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false, + + 'PAGINATION' => generate_pagination($this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), + 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), + 'TOTAL' => $total, + 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), + ) + ); + + $this->tpl_name = 'mcp_reports'; + break; + } + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index cc701a0540..270b0055d9 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -77,6 +77,7 @@ class mcp_reports WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id + AND r.pm_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); @@ -149,13 +150,11 @@ class mcp_reports if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { - $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); - $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; + ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -332,7 +331,7 @@ class mcp_reports mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; - $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; + $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; if ($mode == 'reports') { @@ -349,9 +348,10 @@ class mcp_reports $report_state AND r.post_id = p.post_id " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' - ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . ' + ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id + AND r.pm_id = 0 $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -374,6 +374,7 @@ class mcp_reports AND r.post_id = p.post_id AND u.user_id = p.poster_id AND ru.user_id = r.user_id + AND r.pm_id = 0 ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); @@ -441,35 +442,54 @@ class mcp_reports /** * Closes a report */ -function close_report($report_id_list, $mode, $action) +function close_report($report_id_list, $mode, $action, $pm = false) { - global $db, $template, $user, $config; + global $db, $template, $user, $config, $auth; global $phpEx, $phpbb_root_path; - $sql = 'SELECT r.post_id - FROM ' . REPORTS_TABLE . ' r - WHERE ' . $db->sql_in_set('r.report_id', $report_id_list); + $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; + $id_column = ($pm) ? 'pm_id' : 'post_id'; + $module = ($pm) ? 'pm_reports' : 'reports'; + $pm_prefix = ($pm) ? 'PM_' : ''; + + $sql = "SELECT r.$id_column + FROM " . REPORTS_TABLE . ' r + WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where; $result = $db->sql_query($sql); $post_id_list = array(); while ($row = $db->sql_fetchrow($result)) { - $post_id_list[] = $row['post_id']; + $post_id_list[] = $row[$id_column]; } $post_id_list = array_unique($post_id_list); - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) + if ($pm) + { + if (!$auth->acl_getf_global('m_report')) + { + trigger_error('NOT_AUTHORISED'); + } + } + else { - trigger_error('NOT_AUTHORISED'); + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) + { + trigger_error('NOT_AUTHORISED'); + } } if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false) { $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports'); } + elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) + { + $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports'); + } else if ($action == 'close' && !request_var('r', 0)) { - $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=reports'); + $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module); } else { @@ -480,7 +500,7 @@ function close_report($report_id_list, $mode, $action) $topic_ids = array(); $s_hidden_fields = build_hidden_fields(array( - 'i' => 'reports', + 'i' => $module, 'mode' => $mode, 'report_id_list' => $report_id_list, 'action' => $action, @@ -489,13 +509,13 @@ function close_report($report_id_list, $mode, $action) if (confirm_box(true)) { - $post_info = get_post_data($post_id_list, 'm_report'); + $post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report'); - $sql = 'SELECT r.report_id, r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type - FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u + $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type + FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' - AND r.user_id = u.user_id'; + AND r.user_id = u.user_id' . $pm_where; $result = $db->sql_query($sql); $reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array(); @@ -506,8 +526,12 @@ function close_report($report_id_list, $mode, $action) if (!$report['report_closed']) { - $close_report_posts[] = $report['post_id']; - $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; + $close_report_posts[] = $report[$id_column]; + + if (!$pm) + { + $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; + } } if ($report['user_notify'] && !$report['report_closed']) @@ -522,7 +546,7 @@ function close_report($report_id_list, $mode, $action) $close_report_posts = array_unique($close_report_posts); $close_report_topics = array_unique($close_report_topics); - if (sizeof($close_report_posts)) + if (!$pm && sizeof($close_report_posts)) { // Get a list of topics that still contain reported posts $sql = 'SELECT DISTINCT topic_id @@ -561,18 +585,33 @@ function close_report($report_id_list, $mode, $action) if (sizeof($close_report_posts)) { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 0 - WHERE ' . $db->sql_in_set('post_id', $close_report_posts); - $db->sql_query($sql); + if ($pm) + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_reported = 0 + WHERE ' . $db->sql_in_set('msg_id', $close_report_posts); + $db->sql_query($sql); - if (sizeof($close_report_topics)) + if ($action == 'delete') + {echo "aha"; + delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX); + } + } + else { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 0 - WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' - OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_reported = 0 + WHERE ' . $db->sql_in_set('post_id', $close_report_posts); $db->sql_query($sql); + + if (sizeof($close_report_topics)) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_reported = 0 + WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' + OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); + $db->sql_query($sql); + } } } @@ -582,7 +621,14 @@ function close_report($report_id_list, $mode, $action) foreach ($reports as $report) { - add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); + if ($pm) + { + add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); + } + else + { + add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); + } } $messenger = new messenger(); @@ -597,39 +643,53 @@ function close_report($report_id_list, $mode, $action) continue; } - $post_id = $reporter['post_id']; + $post_id = $reporter[$id_column]; - $messenger->template('report_' . $action . 'd', $reporter['user_lang']); + $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); $messenger->to($reporter['user_email'], $reporter['username']); $messenger->im($reporter['user_jabber'], $reporter['username']); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($reporter['username']), - 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) - ); + if ($pm) + { + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($reporter['username']), + 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), + 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), + )); + } + else + { + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($reporter['username']), + 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), + 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) + ); + } $messenger->send($reporter['user_notify_type']); } } - foreach ($post_info as $post) + if (!$pm) { - $forum_ids[$post['forum_id']] = $post['forum_id']; - $topic_ids[$post['topic_id']] = $post['topic_id']; + foreach ($post_info as $post) + { + $forum_ids[$post['forum_id']] = $post['forum_id']; + $topic_ids[$post['topic_id']] = $post['topic_id']; + } } - + unset($notify_reporters, $post_info, $reports); $messenger->save_queue(); - $success_msg = (sizeof($report_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_' . strtoupper($action) . 'D_SUCCESS'; + $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; } else { - confirm_box(false, $user->lang[strtoupper($action) . '_REPORT' . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); + confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); } $redirect = request_var('redirect', "index.$phpEx"); @@ -642,15 +702,21 @@ function close_report($report_id_list, $mode, $action) else { meta_refresh(3, $redirect); + $return_forum = ''; - if (sizeof($forum_ids == 1)) - { - $return_forum = sprintf($user->lang['RETURN_FORUM'], '', '') . '

'; - } $return_topic = ''; - if (sizeof($topic_ids == 1)) + + if (!$pm) { - $return_topic = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

'; + if (sizeof($forum_ids) === 1) + { + $return_forum = sprintf($user->lang['RETURN_FORUM'], '', '') . '

'; + } + + if (sizeof($topic_ids) === 1) + { + $return_topic = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

'; + } } trigger_error($user->lang[$success_msg] . '

' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "", '')); diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index b2ceb30f9e..f947518ba8 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -115,78 +115,7 @@ function view_folder($id, $mode, $folder_id, $folder) // Build Recipient List if in outbox/sentbox - max two additional queries if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { - $recipient_list = $address = array(); - - foreach ($folder_info['rowset'] as $message_id => $row) - { - $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - $_save = array('u', 'g'); - foreach ($_save as $save) - { - if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save])) - { - foreach (array_keys($address[$message_id][$save]) as $ug_id) - { - $recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); - } - } - } - } - - $_types = array('u', 'g'); - foreach ($_types as $ug_type) - { - if (!empty($recipient_list[$ug_type])) - { - if ($ug_type == 'u') - { - $sql = 'SELECT user_id as id, username as name, user_colour as colour - FROM ' . USERS_TABLE . ' - WHERE '; - } - else - { - $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type - FROM ' . GROUPS_TABLE . ' - WHERE '; - } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($ug_type == 'g') - { - $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name']; - } - - $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); - } - $db->sql_freeresult($result); - } - } - - foreach ($address as $message_id => $adr_ary) - { - foreach ($adr_ary as $type => $id_ary) - { - foreach ($id_ary as $ug_id => $_id) - { - if ($type == 'u') - { - $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); - } - else - { - $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; - $link = ''; - $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '' : ''); - } - } - } - } - unset($recipient_list, $address); + $address_list = get_recipient_strings($folder_info['rowset']); } $data = array(); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 82aa5afd8f..dd15f5ff37 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -190,6 +190,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['SEND_EMAIL']), 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']), 'REPLY_IMG' => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']), + 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']), 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), @@ -210,6 +211,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_EMAIL' => $user_info['email'], + 'U_REPORT' => ($config['allow_pm_report']) ? append_sid("{$phpbb_root_path}report.$phpEx", "pm=" . $message_row['msg_id']) : '', 'U_QUOTE' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_EDIT' => (($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_POST_REPLY_PM' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '', -- cgit v1.2.1 From 8e8c40bc75f1394dfcb9fd772858069388b86b06 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 22 Jul 2009 00:11:46 +0000 Subject: - Added install_id to data collector - config variable whitelist, so sensitive MOD info is not transmitted, currently mostly bool/int values - should we reduce the amount of data? git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9818 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_send_statistics.php | 15 +- phpBB/includes/questionnaire/questionnaire.php | 260 ++++++++++++++++++++----- 2 files changed, 224 insertions(+), 51 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index 6c29b9fbb5..c76b450605 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -29,12 +29,23 @@ class acp_send_statistics { global $config, $template; - $collect_url = "http://www.phpbb.com/stats/getstatdata.php"; + $collect_url = "http://www.phpbb.com/stats/receive_stats.php"; $this->tpl_name = 'acp_send_statistics'; $this->page_title = 'ACP_SEND_STATISTICS'; - $collector = new phpbb_questionnaire_data_collector(); + // generate a unique id if necessary + if (!isset($config['questionnaire_unique_id'])) + { + $install_id = unique_id(); + set_config('questionnaire_unique_id', $install_id); + } + else + { + $install_id = $config['questionnaire_unique_id']; + } + + $collector = new phpbb_questionnaire_data_collector($install_id); // Add data provider $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 42ac44d38a..e9f9172754 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -30,15 +30,16 @@ class phpbb_questionnaire_data_collector { var $providers; var $data = null; + var $install_id = ''; /** * Constructor. * - * @param array * @param string */ - function phpbb_questionnaire_data_collector() + function phpbb_questionnaire_data_collector($install_id) { + $this->install_id = $install_id; $this->providers = array(); } @@ -79,6 +80,7 @@ class phpbb_questionnaire_data_collector $provider = &$this->providers[$key]; $this->data[$provider->get_identifier()] = $provider->get_data(); } + $this->data['install_id'] = $this->install_id; } } @@ -229,62 +231,222 @@ class phpbb_questionnaire_phpbb_data_provider */ function get_data() { - // Exclude certain config vars - $exclude_config_vars = array( - 'avatar_gallery_path' => true, - 'avatar_path' => true, - 'avatar_salt' => true, - 'board_contact' => true, - 'board_disable_msg' => true, - 'board_email' => true, - 'board_email_sig' => true, - 'cookie_name' => true, - 'icons_path' => true, - 'icons_path' => true, - 'jab_host' => true, - 'jab_password' => true, - 'jab_port' => true, - 'jab_username' => true, - 'ldap_base_dn' => true, - 'ldap_email' => true, - 'ldap_password' => true, - 'ldap_port' => true, - 'ldap_server' => true, - 'ldap_uid' => true, - 'ldap_user' => true, - 'ldap_user_filter' => true, - 'ranks_path' => true, - 'script_path' => true, - 'server_name' => true, - 'server_port' => true, - 'server_protocol' => true, - 'site_desc' => true, - 'sitename' => true, - 'smilies_path' => true, - 'smtp_host' => true, - 'smtp_password' => true, - 'smtp_port' => true, - 'smtp_username' => true, - 'upload_icons_path' => true, - 'upload_path' => true, - 'newest_user_colour' => true, - 'newest_user_id' => true, - 'newest_username' => true, - 'rand_seed' => true, + global $phpbb_root_path, $phpEx; + include("{$phpbb_root_path}config.$phpEx"); + + // Only send certain config vars + $config_vars = array( + 'active_sessions' => true, + 'allow_attachments' => true, + 'allow_autologin' => true, + 'allow_avatar' => true, + 'allow_avatar_local' => true, + 'allow_avatar_remote' => true, + 'allow_avatar_upload' => true, + 'allow_bbcode' => true, + 'allow_birthdays' => true, + 'allow_bookmarks' => true, + 'allow_emailreuse' => true, + 'allow_forum_notify' => true, + 'allow_mass_pm' => true, + 'allow_name_chars' => true, + 'allow_namechange' => true, + 'allow_nocensors' => true, + 'allow_pm_attach' => true, + 'allow_post_flash' => true, + 'allow_post_links' => true, + 'allow_privmsg' => true, + 'allow_quick_reply' => true, + 'allow_sig' => true, + 'allow_sig_bbcode' => true, + 'allow_sig_flash' => true, + 'allow_sig_img' => true, + 'allow_sig_links' => true, + 'allow_sig_pm' => true, + 'allow_sig_smilies' => true, + 'allow_smilies' => true, + 'allow_topic_notify' => true, + 'attachment_quota' => true, + 'auth_bbcode_pm' => true, + 'auth_flash_pm' => true, + 'auth_img_pm' => true, + 'auth_method' => true, + 'auth_smilies_pm' => true, + 'avatar_filesize' => true, + 'avatar_max_height' => true, + 'avatar_max_width' => true, + 'avatar_min_height' => true, + 'avatar_min_width' => true, + 'board_dst' => true, + 'board_email_form' => true, + 'board_hide_emails' => true, + 'board_timezone' => true, + 'browser_check' => true, + 'bump_interval' => true, + 'bump_type' => true, + 'cache_gc' => true, + 'captcha_plugin' => true, + 'captcha_gd' => true, + 'captcha_gd_foreground_noise' => true, + 'captcha_gd_x_grid' => true, + 'captcha_gd_y_grid' => true, + 'captcha_gd_wave' => true, + 'captcha_gd_3d_noise' => true, + 'captcha_gd_fonts' => true, + 'confirm_refresh' => true, + 'check_attachment_content' => true, + 'check_dnsbl' => true, + 'chg_passforce' => true, + 'cookie_secure' => true, + 'coppa_enable' => true, + 'database_gc' => true, + 'dbms_version' => true, + 'default_dateformat' => true, + 'display_last_edited' => true, + 'display_order' => true, + 'edit_time' => true, + 'email_check_mx' => true, + 'email_enable' => true, + 'email_function_name' => true, + 'email_package_size' => true, + 'enable_confirm' => true, + 'enable_pm_icons' => true, + 'enable_post_confirm' => true, + 'feed_enable' => true, + 'feed_limit' => true, + 'feed_overall_forums' => true, + 'feed_overall_forums_limit' => true, + 'feed_overall_topics' => true, + 'feed_overall_topics_limit' => true, + 'feed_forum' => true, + 'feed_topic' => true, + 'feed_item_statistics' => true, + 'flood_interval' => true, + 'force_server_vars' => true, + 'form_token_lifetime' => true, + 'form_token_mintime' => true, + 'form_token_sid_guests' => true, + 'forward_pm' => true, + 'forwarded_for_check' => true, + 'full_folder_action' => true, + 'fulltext_native_common_thres' => true, + 'fulltext_native_load_upd' => true, + 'fulltext_native_max_chars' => true, + 'fulltext_native_min_chars' => true, + 'gzip_compress' => true, + 'hot_threshold' => true, + 'img_create_thumbnail' => true, + 'img_display_inlined' => true, + 'img_imagick' => true, + 'img_link_height' => true, + 'img_link_width' => true, + 'img_max_height' => true, + 'img_max_thumb_width' => true, + 'img_max_width' => true, + 'img_min_thumb_filesize' => true, + 'ip_check' => true, + 'jab_enable' => true, + 'jab_package_size' => true, + 'jab_use_ssl' => true, + 'limit_load' => true, + 'limit_search_load' => true, + 'load_anon_lastread' => true, + 'load_birthdays' => true, + 'load_cpf_memberlist' => true, + 'load_cpf_viewprofile' => true, + 'load_cpf_viewtopic' => true, + 'load_db_lastread' => true, + 'load_db_track' => true, + 'load_jumpbox' => true, + 'load_moderators' => true, + 'load_online' => true, + 'load_online_guests' => true, + 'load_online_time' => true, + 'load_onlinetrack' => true, + 'load_search' => true, + 'load_tplcompile' => true, + 'load_user_activity' => true, + 'max_attachments' => true, + 'max_attachments_pm' => true, + 'max_autologin_time' => true, + 'max_filesize' => true, + 'max_filesize_pm' => true, + 'max_login_attempts' => true, + 'max_name_chars' => true, + 'max_num_search_keywords' => true, + 'max_pass_chars' => true, + 'max_poll_options' => true, + 'max_post_chars' => true, + 'max_post_font_size' => true, + 'max_post_img_height' => true, + 'max_post_img_width' => true, + 'max_post_smilies' => true, + 'max_post_urls' => true, + 'max_quote_depth' => true, + 'max_reg_attempts' => true, + 'max_sig_chars' => true, + 'max_sig_font_size' => true, + 'max_sig_img_height' => true, + 'max_sig_img_width' => true, + 'max_sig_smilies' => true, + 'max_sig_urls' => true, + 'min_name_chars' => true, + 'min_pass_chars' => true, + 'min_post_chars' => true, + 'min_search_author_chars' => true, + 'mime_triggers' => true, + 'new_member_post_limit' => true, + 'new_member_group_default' => true, + 'override_user_style' => true, + 'pass_complex' => true, + 'pm_edit_time' => true, + 'pm_max_boxes' => true, + 'pm_max_msgs' => true, + 'pm_max_recipients' => true, + 'posts_per_page' => true, + 'print_pm' => true, + 'queue_interval' => true, + 'require_activation' => true, + 'referer_validation' => true, + 'search_block_size' => true, + 'search_gc' => true, + 'search_interval' => true, + 'search_anonymous_interval' => true, + 'search_type' => true, + 'search_store_results' => true, + 'secure_allow_deny' => true, + 'secure_allow_empty_referer' => true, + 'secure_downloads' => true, + 'session_gc' => true, + 'session_length' => true, + 'smtp_auth_method' => true, + 'smtp_delivery' => true, + 'topics_per_page' => true, + 'tpl_allow_php' => true, + 'version' => true, + 'warnings_expire_days' => true, + 'warnings_gc' => true, + + 'num_files' => true, + 'num_posts' => true, + 'num_topics' => true, + 'num_users' => true, + 'record_online_users' => true, ); $result = array(); foreach ($this->config as $name => $value) { - // Mods may add columns for storing passwords - we do not want to grab them - if (isset($exclude_config_vars[$name]) || strpos($name, 'password') !== false) + if (!isset($exclude_config_vars[$name])) { - continue; + $result['config.' . $name] = $value; } - - $result['config.' . $name] = $value; } + $result['dbms'] = $dbms; + $result['acm_type'] = $acm_type; + $result['load_extensions'] = $load_extensions; + return $result; } } -- cgit v1.2.1 From 2bb2e4a43b30bd3a686106865c84786de42d50e8 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 01:01:55 +0000 Subject: Do not try to enter passive mode before logging in. Return error if ftp_nlist() returned error. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9819 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index c345f81e1d..2146d5fa0b 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -316,15 +316,15 @@ class ftp extends transfer return 'ERR_CONNECTING_SERVER'; } - // attempt to turn pasv mode on - @ftp_pasv($this->connection, true); - // login to the server if (!@ftp_login($this->connection, $this->username, $this->password)) { return 'ERR_UNABLE_TO_LOGIN'; } + // attempt to turn pasv mode on + @ftp_pasv($this->connection, true); + // change to the root directory if (!$this->_chdir($this->root_path)) { @@ -462,6 +462,12 @@ class ftp extends transfer { $list = @ftp_nlist($this->connection, $dir); + // Return on error + if ($list === false) + { + return false; + } + // Remove path if prepended foreach ($list as $key => $item) { -- cgit v1.2.1 From 81e67fbef141ea47249b5f9d1a4e1cb34263b248 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 01:26:09 +0000 Subject: Fix bug #46295 - Be less strict with FTP daemons when getting directory filelists. Authorised by: bantu ;-) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9820 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 2146d5fa0b..c1211eda52 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -462,6 +462,14 @@ class ftp extends transfer { $list = @ftp_nlist($this->connection, $dir); + // See bug #46295 - Some FTP daemons don't like './' + if ($dir === './') + { + // Let's try some alternatives + $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; + $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; + } + // Return on error if ($list === false) { -- cgit v1.2.1 From 2a84b76f3062a87c0069da1db2bdca83509882b1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 02:57:36 +0000 Subject: Fix two potential problems with the ftp_fsock class. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9821 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index c1211eda52..7c5cd329a4 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -737,7 +737,12 @@ class ftp_fsock extends transfer $list = array(); while (!@feof($this->data_connection)) { - $list[] = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); + $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); + + if ($filename !== '') + { + $list[] = $filename; + } } $this->_close_data_connection(); @@ -840,7 +845,7 @@ class ftp_fsock extends transfer $result = @fgets($this->connection, 512); $response .= $result; } - while (substr($response, 3, 1) != ' '); + while (substr($result, 3, 1) !== ' '); if (!preg_match('#^[123]#', $response)) { -- cgit v1.2.1 From 16e393b61d53843dfec3b88257925a0848c027ed Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 03:02:45 +0000 Subject: Also fix bug #46295 in ftp_fsock class. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9822 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 7c5cd329a4..046abede8e 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -483,7 +483,7 @@ class ftp extends transfer $item = str_replace('\\', '/', $item); $dir = str_replace('\\', '/', $dir); - if (strpos($item, $dir) === 0) + if (!empty($dir) && strpos($item, $dir) === 0) { $item = substr($item, strlen($dir)); } @@ -749,6 +749,20 @@ class ftp_fsock extends transfer // Clear buffer $this->_check_command(); + // See bug #46295 - Some FTP daemons don't like './' + if ($dir === './' && empty($list)) + { + // Let's try some alternatives + $list = $this->_ls('.'); + + if (empty($list)) + { + $list = $this->_ls(''); + } + + return $list; + } + // Remove path if prepended foreach ($list as $key => $item) { @@ -756,7 +770,7 @@ class ftp_fsock extends transfer $item = str_replace('\\', '/', $item); $dir = str_replace('\\', '/', $dir); - if (strpos($item, $dir) === 0) + if (!empty($dir) && strpos($item, $dir) === 0) { $item = substr($item, strlen($dir)); } -- cgit v1.2.1 From cef8c2d87e2c1e55a7fd6d57e3f998e531fd0bf2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 22 Jul 2009 09:07:24 +0000 Subject: Parse email text files with the template engine. Did not check if this influences styles template cache list/purge/etc. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9823 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 75 ++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 22 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 4916ee41d7..2255b3dcb5 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -27,6 +27,8 @@ class messenger var $mail_priority = MAIL_NORMAL_PRIORITY; var $use_queue = true; + + var $tpl_obj = NULL; var $tpl_msg = array(); var $eol = "\n"; @@ -177,7 +179,7 @@ class messenger if (!trim($template_file)) { - trigger_error('No template file set', E_USER_ERROR); + trigger_error('No template file for emailing set.', E_USER_ERROR); } if (!trim($template_lang)) @@ -185,25 +187,25 @@ class messenger $template_lang = basename($config['default_lang']); } - if (empty($this->tpl_msg[$template_lang . $template_file])) + // tpl_msg now holds a template object we can use to parse the template file + if (!isset($this->tpl_msg[$template_lang . $template_file])) { - $tpl_file = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $tpl_file .= $template_lang . "/email/$template_file.txt"; + $this->tpl_msg[$template_lang . $template_file] = new template(); + $tpl = &$this->tpl_msg[$template_lang . $template_file]; - if (!file_exists($tpl_file)) - { - trigger_error("Could not find email template file [ $tpl_file ]", E_USER_ERROR); - } + $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; + $template_path .= $template_lang . '/email'; - if (($data = @file_get_contents($tpl_file)) === false) - { - trigger_error("Failed opening template file [ $tpl_file ]", E_USER_ERROR); - } + $tpl->set_custom_template($template_path, $template_lang . '_email'); - $this->tpl_msg[$template_lang . $template_file] = $data; + $tpl->set_filenames(array( + 'body' => $template_file . '.txt', + )); } - $this->msg = $this->tpl_msg[$template_lang . $template_file]; + $this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file]; + $this->vars = &$this->tpl_obj->_rootref; + $this->tpl_msg = ''; return true; } @@ -213,7 +215,22 @@ class messenger */ function assign_vars($vars) { - $this->vars = (empty($this->vars)) ? $vars : $this->vars + $vars; + if (!is_object($this->tpl_obj)) + { + return; + } + + $this->tpl_obj->assign_vars($vars); + } + + function assign_block_vars($blockname, $vars) + { + if (!is_object($this->tpl_obj)) + { + return; + } + + $this->tpl_obj->assign_block_vars($blockname, $vars); } /** @@ -224,15 +241,29 @@ class messenger global $config, $user; // We add some standard variables we always use, no need to specify them always - $this->vars['U_BOARD'] = (!isset($this->vars['U_BOARD'])) ? generate_board_url() : $this->vars['U_BOARD']; - $this->vars['EMAIL_SIG'] = (!isset($this->vars['EMAIL_SIG'])) ? str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])) : $this->vars['EMAIL_SIG']; - $this->vars['SITENAME'] = (!isset($this->vars['SITENAME'])) ? htmlspecialchars_decode($config['sitename']) : $this->vars['SITENAME']; + if (!isset($this->vars['U_BOARD'])) + { + $this->assign_vars(array( + 'U_BOARD' => generate_board_url(), + )); + } - // Escape all quotes, else the eval will fail. - $this->msg = str_replace ("'", "\'", $this->msg); - $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . ((isset(\$this->vars['\\1'])) ? \$this->vars['\\1'] : '') . '", $this->msg); + if (!isset($this->vars['EMAIL_SIG'])) + { + $this->assign_vars(array( + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), + )); + } + + if (!isset($this->vars['SITENAME'])) + { + $this->assign_vars(array( + 'SITENAME' => htmlspecialchars_decode($config['sitename']), + )); + } - eval("\$this->msg = '$this->msg';"); + // Parse message through template + $this->msg = trim($this->tpl_obj->assign_display('body')); // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable -- cgit v1.2.1 From 43d30134cb98bcfbbd29511c3a33d38b3b61f59e Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 22 Jul 2009 10:09:25 +0000 Subject: removed spaces git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9825 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/questionnaire/questionnaire.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index e9f9172754..fe6e8a3bd7 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -23,8 +23,8 @@ if (!defined('IN_PHPBB')) * to a central server. For privacy reasons we try to collect only data which aren't private * or don't give any information which might help to identify the user. * -* @author Johannes Schlueter -* @copyright (c) 2007-2008 Johannes Schlueter +* @author Johannes Schlueter +* @copyright (c) 2007-2008 Johannes Schlueter */ class phpbb_questionnaire_data_collector { @@ -35,7 +35,7 @@ class phpbb_questionnaire_data_collector /** * Constructor. * - * @param string + * @param string */ function phpbb_questionnaire_data_collector($install_id) { @@ -51,7 +51,7 @@ class phpbb_questionnaire_data_collector /** * Get data as an array. * - * @return array All Data + * @return array All Data */ function get_data_raw() { @@ -71,7 +71,7 @@ class phpbb_questionnaire_data_collector /** * Collect info into the data property. * - * @return void + * @return void */ function collect() { @@ -80,7 +80,7 @@ class phpbb_questionnaire_data_collector $provider = &$this->providers[$key]; $this->data[$provider->get_identifier()] = $provider->get_data(); } - $this->data['install_id'] = $this->install_id; + $this->data['install_id'] = $this->install_id; } } @@ -100,7 +100,7 @@ class phpbb_questionnaire_php_data_provider /** * Get data about the PHP runtime setup. * - * @return array + * @return array */ function get_data() { @@ -144,7 +144,7 @@ class phpbb_questionnaire_system_data_provider /** * Get data about the general system information, like OS or IP (shortened). * - * @return array + * @return array */ function get_data() { -- cgit v1.2.1 From c04626fa4db74dd5effda4574616460d919bedb9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 22 Jul 2009 10:42:01 +0000 Subject: index for GC git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9826 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index cd5ee8c91d..c8951cd167 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -294,7 +294,7 @@ class phpbb_captcha_qa 'confirm_type' => array('USINT', 0), ), 'KEYS' => array( - 'confirm_id' => array('INDEX', 'confirm_id'), + 'session_id' => array('INDEX', 'session_id'), 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), ), 'PRIMARY_KEY' => 'confirm_id', -- cgit v1.2.1 From 2dfd327828a5f6387ea051aa9e588f39249ed059 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 22 Jul 2009 10:57:56 +0000 Subject: index for GC git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9827 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index c8951cd167..7367816ae8 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -271,7 +271,6 @@ class phpbb_captcha_qa ), 'PRIMARY_KEY' => 'question_id', 'KEYS' => array( - 'question_id' => array('INDEX', array('question_id', 'lang_iso')), 'lang_iso' => array('INDEX', 'lang_iso'), ), ), -- cgit v1.2.1 From 818b252f208b92157b56b101aac555eb1efb8cee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 22 Jul 2009 11:47:37 +0000 Subject: fix r9758 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9828 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 19 ++++++++++++++++--- phpBB/includes/functions.php | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cb342ac300..7921b6df67 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1160,11 +1160,13 @@ class acp_users if ($deleteall) { - $deleted_warnings = '0'; + $log_warnings = $deleted_warnings = 0; } else { - $deleted_warnings = ' user_warnings - ' . $db->sql_affectedrows(); + $num_warnings = (int) $db->sql_affectedrows(); + $deleted_warnings = ' user_warnings - ' . $num_warnings; + $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; } $sql = 'UPDATE ' . USERS_TABLE . " @@ -1172,7 +1174,18 @@ class acp_users WHERE user_id = $user_id"; $db->sql_query($sql); - add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); + switch ($log_warnings) + { + case 2: + add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings); + break; + case 1: + add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); + break; + default: + add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']); + break; + } } } else diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2dd28b2ffe..1a791ebff9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4035,7 +4035,7 @@ function page_footer($run_cron = true) // Tidy the cache $cron_type = 'tidy_cache'; } - else if ($config['warnings_last_gc'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) + else if ($config['warnings_expire_days'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } -- cgit v1.2.1 From 00e81e704d78c7f4f45d1536ad170ed8dd985e84 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 22 Jul 2009 13:33:54 +0000 Subject: fix mcp sorting for pm_reports, and some minor language changes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9830 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_pm_reports.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 0e94d7e017..72f77fae7c 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -221,7 +221,7 @@ class mcp_pm_reports if ($mode == 'pm_reports') { - $report_state = 'pm.message_reported = 1 AND r.report_closed = 0'; + $report_state = 'p.message_reported = 1 AND r.report_closed = 0'; } else { @@ -229,10 +229,10 @@ class mcp_pm_reports } $sql = 'SELECT r.report_id - FROM ' . PRIVMSGS_TABLE . ' pm, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . " + FROM ' . PRIVMSGS_TABLE . ' p, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . " WHERE $report_state - AND r.pm_id = pm.msg_id - " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = pm.author_id' : '') . ' + AND r.pm_id = p.msg_id + " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.author_id' : '') . ' ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . " AND r.post_id = 0 $limit_time_sql -- cgit v1.2.1 From e90f25e9b4090be3e631fe951c558f226add0c9f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 22 Jul 2009 15:50:31 +0000 Subject: geez I'm blind - use the right template and lang vars git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9834 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_front.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index ee75c1daff..b844796955 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -322,15 +322,15 @@ function mcp_front_view($id, $mode, $action) if ($total == 0) { $template->assign_vars(array( - 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], + 'L_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], 'S_HAS_PM_REPORTS' => false) ); } else { $template->assign_vars(array( - 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), - 'S_HAS_REPORTS' => true) + 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), + 'S_HAS_PM_REPORTS' => true) ); } } -- cgit v1.2.1 From 89332c00b7198b5bd07fdb98b21d4734c300da15 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:47:10 +0000 Subject: Fix Bug #40515 - Fix set_custom_template for database-stored styles Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9839 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 7cf865072f..fa7cf437fd 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -39,6 +39,8 @@ class template var $files_inherit = array(); var $files_template = array(); var $inherit_root = ''; + var $orig_tpl_storedb = 'undefined'; + var $orig_tpl_inherits_id = 'undefined'; // this will hash handle names to the compiled/uncompiled code for that handle. var $compiled_code = array(); @@ -55,6 +57,16 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; + if ($this->orig_tpl_storedb == 'undefined') + { + $this->orig_tpl_storedb = $user->theme['template_storedb']; + } + if ($this->orig_tpl_inherits_id == 'undefined') + { + $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; + } + $user->theme['template_storedb'] = $this->orig_tpl_storedb; + $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; if ($user->theme['template_inherits_id']) { @@ -77,10 +89,12 @@ class template */ function set_custom_template($template_path, $template_name) { - global $phpbb_root_path; + global $phpbb_root_path, $user; $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; + $user->theme['template_storedb'] = false; + $user->theme['template_inherits_id'] = false; $this->_rootref = &$this->_tpldata['.'][0]; -- cgit v1.2.1 From 224aa404f6c8f0014a0dc48b9776ff431b8d4f48 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:49:51 +0000 Subject: Fix bug #47825 - Banning an already banned user states to be successful, but has no effect - Patch by Pyramide Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9840 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c69c27c9d7..e8584239ad 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1016,7 +1016,17 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } while ($row = $db->sql_fetchrow($result)); - $banlist_ary = array_unique(array_diff($banlist_ary, $banlist_ary_tmp)); + $banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp); + + if (sizeof($banlist_ary_tmp)) + { + // One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length + $sql = 'DELETE FROM ' . BANLIST_TABLE . ' + WHERE ' . $db->sql_in_set($type, $banlist_ary_tmp) . ' + AND ban_exclude = ' . (int) $ban_exclude; + $db->sql_query($sql); + } + unset($banlist_ary_tmp); } $db->sql_freeresult($result); -- cgit v1.2.1 From f84cbee47c06dd9df3b2cf7085a3b37ab9095d09 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:52:56 +0000 Subject: Fix bug #18005 - Do not add style-parameter to URL again, after admin re-authentification - Patch by leviatan21 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9841 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 9ae5a7c793..c8617057c4 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1534,7 +1534,7 @@ class user extends session $this->add_lang($lang_set); unset($lang_set); - if (!empty($_GET['style']) && $auth->acl_get('a_styles')) + if (!empty($_GET['style']) && $auth->acl_get('a_styles') && !defined('ADMIN_START')) { global $SID, $_EXTRA_URL; -- cgit v1.2.1 From 433f03107de1162744a1d0b8c9fa3c4ba1b3ed21 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:56:06 +0000 Subject: Fix bug #31505 - Do not cut post-message in between HTML-Entities on search.php - Patch by leviatan21 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9842 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 630f4105d0..de5df37299 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -250,6 +250,11 @@ function get_context($text, $words, $length = 400) // first replace all whitespaces with single spaces $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); + // we need to turn the entities back into their original form, to not cut the message in between them + $entities = array('<', '>', '[', ']', '.', ':', ':'); + $characters = array('<', '>', '[', ']', '.', ':', ':'); + $text = str_replace($entities, $characters, $text); + $word_indizes = array(); if (sizeof($words)) { @@ -345,13 +350,13 @@ function get_context($text, $words, $length = 400) } } } - return $final_text; + return str_replace($characters, $entities, $final_text); } } if (!sizeof($words) || !sizeof($word_indizes)) { - return (utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text; + return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); } } -- cgit v1.2.1 From 780854818b22ccdf36fe50e4e4bf5e68027c9e2b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 09:01:29 +0000 Subject: Fix bug #48265 - Correctly set attachment flag for topics, posts and pms after deleting attachments - Patch by WorldWar and nickvergessen Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9843 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 58 ++++++++++++++++++++++++++++++----- phpBB/includes/functions_posting.php | 15 +++++++++ phpBB/includes/message_parser.php | 15 +++++++-- phpBB/includes/ucp/ucp_pm_compose.php | 17 +++++++++- 4 files changed, 93 insertions(+), 12 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index ff7f687945..457fac2458 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -892,19 +892,61 @@ function delete_attachments($mode, $ids, $resync = true) // Update post indicators for posts now no longer having attachments if (sizeof($post_ids)) { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); + // Just check which posts are still having an assigned attachment not orphaned by querying the attachments table + $sql = 'SELECT post_msg_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' + AND in_message = 0 + AND is_orphan = 0'; + $result = $db->sql_query($sql); + + $remaining_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $remaining_ids[] = $row['post_msg_id']; + } + $db->sql_freeresult($result); + + // Now only unset those ids remaining + $post_ids = array_diff($post_ids, $remaining_ids); + + if (sizeof($post_ids)) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_attachment = 0 + WHERE ' . $db->sql_in_set('post_id', $post_ids); + $db->sql_query($sql); + } } // Update message table if messages are affected if (sizeof($message_ids)) { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_attachment = 0 - WHERE ' . $db->sql_in_set('msg_id', $message_ids); - $db->sql_query($sql); + // Just check which messages are still having an assigned attachment not orphaned by querying the attachments table + $sql = 'SELECT post_msg_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_msg_id', $message_ids) . ' + AND in_message = 1 + AND is_orphan = 0'; + $result = $db->sql_query($sql); + + $remaining_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $remaining_ids[] = $row['post_msg_id']; + } + $db->sql_freeresult($result); + + // Now only unset those ids remaining + $message_ids = array_diff($message_ids, $remaining_ids); + + if (sizeof($message_ids)) + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_attachment = 0 + WHERE ' . $db->sql_in_set('msg_id', $message_ids); + $db->sql_query($sql); + } } // Now update the topics. This is a bit trickier, because there could be posts still having attachments within the topic diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 7db2875cda..e348694cfe 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1549,6 +1549,21 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) break; } + if (($post_mode == 'delete') || ($post_mode == 'delete_last_post') || ($post_mode == 'delete_first_post')) + { + $sql = 'SELECT 1 AS has_attachments + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $result = $db->sql_query($sql); + $has_attachments = (int) $db->sql_fetchfield('has_attachments'); + $db->sql_freeresult($result); + + if (!$has_attachments) + { + $sql_data[TOPICS_TABLE] .= ', topic_attachment = 0'; + } + } + // $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : ''; $db->sql_transaction('begin'); diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 7370c2057c..7a2d35dbc6 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1334,7 +1334,7 @@ class parse_message extends bbcode_firstpass /** * Parse Attachments */ - function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false) + function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false, $post_msg_id = 0, $topic_id = 0) { global $config, $auth, $user, $phpbb_root_path, $phpEx, $db; @@ -1487,16 +1487,25 @@ class parse_message extends bbcode_firstpass 'filesize' => $filedata['filesize'], 'filetime' => $filedata['filetime'], 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, + 'is_orphan' => ($post_msg_id) ? 0 : 1, 'in_message' => ($is_message) ? 1 : 0, 'poster_id' => $user->data['user_id'], ); + if ($post_msg_id) + { + $sql_ary['post_msg_id'] = $post_msg_id; + if ($topic_id) + { + $sql_ary['topic_id'] = $topic_id; + } + } + $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_entry = array( 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, + 'is_orphan' => ($post_msg_id) ? 0 : 1, 'real_filename' => $filedata['real_filename'], 'attach_comment'=> $this->filename_data['filecomment'], ); diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index edee64bd18..cf82925e1d 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -665,7 +665,22 @@ function compose_pm($id, $mode, $action) } // Parse Attachments - before checksum is calculated - $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true); + if ($action == 'edit') + { + $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true, $msg_id); + if (sizeof($message_parser->attachment_data)) + { + // Update attachment indicators for pms having attachments now, as a precaution if the pm does not get stored by submit + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_attachment = 1 + WHERE msg_id = ' . $msg_id; + $db->sql_query($sql); + } + } + else + { + $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true); + } if (sizeof($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc)) { -- cgit v1.2.1 From 4739c7ba3957dfe585973dafe7465cb9fd8c6d1f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 24 Jul 2009 11:13:32 +0000 Subject: [Feature] Added new functionality to inactive users module: - Ability to set users per page. - Ability to sort by posts/number of reminders/last reminded date. - Show number of posts and ability to search posts. - Show number of reminders sent to user. - Show date of last reminder sent to user. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9845 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_inactive.php | 73 ++++++++++++++++++++++++++++--------- phpBB/includes/functions_admin.php | 4 +- 2 files changed, 57 insertions(+), 20 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index a38b47a704..e41e8f661d 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -51,6 +51,19 @@ class acp_inactive $form_key = 'acp_inactive'; add_form_key($form_key); + // We build the sort key and per page settings here, because they may be needed later + + // Number of entries to display + $per_page = request_var('users_per_page', (int) $config['topics_per_page']); + + // Sorting + $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); + $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']); + $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded'); + + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); + if ($submit && sizeof($mark)) { if ($action !== 'delete' && !check_form_key($form_key)) @@ -67,7 +80,7 @@ class acp_inactive FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); $result = $db->sql_query($sql); - + $user_affected = array(); while ($row = $db->sql_fetchrow($result)) { @@ -122,6 +135,12 @@ class acp_inactive $messenger->save_queue(); } + + // For activate we really need to redirect, else a refresh can result in users being deactivated again + $u_action = $this->u_action . "&$u_sort_param&start=$start"; + $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; + + redirect($u_action); } else if ($action == 'delete') { @@ -175,7 +194,7 @@ class acp_inactive include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $messenger = new messenger(); - $usernames = array(); + $usernames = $user_ids = array(); do { @@ -198,28 +217,34 @@ class acp_inactive $messenger->send($row['user_notify_type']); $usernames[] = $row['username']; + $user_ids[] = (int) $row['user_id']; } while ($row = $db->sql_fetchrow($result)); $messenger->save_queue(); + // Add the remind state to the database + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_reminded = user_reminded + 1, + user_reminded_time = ' . time() . ' + WHERE ' . $db->sql_in_set('user_id', $user_ids); + $db->sql_query($sql); + add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames)); unset($usernames); } $db->sql_freeresult($result); - + + // For remind we really need to redirect, else a refresh can result in more than one reminder + $u_action = $this->u_action . "&$u_sort_param&start=$start"; + $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; + + redirect($u_action); + break; } } - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME']); - $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - // Define where and sort sql for use in displaying logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); @@ -227,19 +252,30 @@ class acp_inactive $inactive = array(); $inactive_count = 0; - $start = view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort); + $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort); foreach ($inactive as $row) { $template->assign_block_vars('inactive', array( 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), + 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), + 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], - 'USERNAME' => $row['username'], - 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) - ); + 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, + 'REMINDED' => $row['user_reminded'], + + 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), + + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + + 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), + 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', + )); } $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); @@ -255,9 +291,10 @@ class acp_inactive 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, - 'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true), - + 'S_ON_PAGE' => on_page($inactive_count, $per_page, $start), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param&users_per_page=$per_page", $inactive_count, $per_page, $start, true), + 'USERS_PER_PAGE' => $per_page, + 'U_ACTION' => $this->u_action . '&start=' . $start, )); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 457fac2458..aeb378953d 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2375,7 +2375,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; @@ -2685,7 +2685,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; } - $sql = 'SELECT user_id, username, user_regdate, user_lastvisit, user_inactive_time, user_inactive_reason + $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_type = ' . USER_INACTIVE . (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . " -- cgit v1.2.1 From b902fc20ae78438af7eb44e9b1f078cdcc213e16 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 25 Jul 2009 10:16:13 +0000 Subject: Small change to r9839 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9847 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index fa7cf437fd..fece30e4cd 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -39,8 +39,8 @@ class template var $files_inherit = array(); var $files_template = array(); var $inherit_root = ''; - var $orig_tpl_storedb = 'undefined'; - var $orig_tpl_inherits_id = 'undefined'; + var $orig_tpl_storedb; + var $orig_tpl_inherits_id; // this will hash handle names to the compiled/uncompiled code for that handle. var $compiled_code = array(); @@ -57,14 +57,17 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; - if ($this->orig_tpl_storedb == 'undefined') + + if ($this->orig_tpl_storedb === null) { $this->orig_tpl_storedb = $user->theme['template_storedb']; } - if ($this->orig_tpl_inherits_id == 'undefined') + + if ($this->orig_tpl_inherits_id === null) { $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; } + $user->theme['template_storedb'] = $this->orig_tpl_storedb; $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; -- cgit v1.2.1 From ba37fa4f49c17047da9aeeb8ada5efaf1030e795 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sun, 26 Jul 2009 10:16:52 +0000 Subject: Fix r9755 for #46765 Authorised by: ToonArmy git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9855 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1a791ebff9..2d86b233f7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4138,7 +4138,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') { global $config, $db, $user; - if($user_id === false) + if ($user_id === false) { $user_id = $user->data['user_id']; } @@ -4150,25 +4150,28 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') { // List of the tracked forums (not ideal, hope the better way will be found) // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user_id}"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $tracked_forums_list[] = $row['forum_id']; } $db->sql_freeresult($result); - + // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id AND t.topic_last_post_time >= tt.mark_time AND tt.user_id = {$user_id} - $sql_extra"; + $sql_extra + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - if($row['topic_last_post_time'] == $row['mark_time']) + if ($row['topic_last_post_time'] == $row['mark_time']) { // Check if there're read topics for the forums having unread ones $read_topics_list[$row['topic_id']] = $row['mark_time']; @@ -4179,33 +4182,41 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } } $db->sql_freeresult($result); - + // Get the full list of the tracked topics $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); // Get list of the unread topics - on forums tracking as the second step // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft WHERE t.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " AND ft.user_id = {$user_id} - $sql_extra"; + $sql_extra + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $unread_topics_list[$row['topic_id']] = $row['mark_time']; } $db->sql_freeresult($result); - + + // Refresh the full list of the tracked topics + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . " WHERE topic_last_post_time > {$user->data['user_lastmark']} AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " - $sql_extra"; + $sql_extra + ORDER BY topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; } -- cgit v1.2.1 From 4faf662623fdc9956604049c57499546149f3655 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 26 Jul 2009 11:33:48 +0000 Subject: made a mistake when turning stats into a whitelist git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9856 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/questionnaire/questionnaire.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index fe6e8a3bd7..88873efdc5 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -253,6 +253,7 @@ class phpbb_questionnaire_phpbb_data_provider 'allow_namechange' => true, 'allow_nocensors' => true, 'allow_pm_attach' => true, + 'allow_pm_report' => true, 'allow_post_flash' => true, 'allow_post_links' => true, 'allow_privmsg' => true, @@ -435,11 +436,11 @@ class phpbb_questionnaire_phpbb_data_provider ); $result = array(); - foreach ($this->config as $name => $value) + foreach ($config_vars as $name => $void) { - if (!isset($exclude_config_vars[$name])) + if (isset($this->config[$name])) { - $result['config.' . $name] = $value; + $result['config.' . $name] = $this->config[$name]; } } -- cgit v1.2.1 From 1a0bd316e41ba78b8519558c47665877e8661970 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 26 Jul 2009 11:34:11 +0000 Subject: correctly add the install_id to the data git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9857 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_send_statistics.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index c76b450605..6784d29262 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -61,6 +61,11 @@ class acp_send_statistics foreach ($raw as $provider => $data) { + if ($provider == 'install_id') + { + $data = array($provider => $data); + } + $template->assign_block_vars('providers', array( 'NAME' => htmlspecialchars($provider), )); -- cgit v1.2.1 From 68e2102f20fa583dd184cefec19511d61caa5602 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 26 Jul 2009 14:54:02 +0000 Subject: Make some adjustments to the log filter. r9781, r9800 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9858 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 20 +++++++++++++++++++- phpBB/includes/mcp/mcp_logs.php | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index f13979ec0f..567606cfc7 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -156,14 +156,32 @@ class acp_logs " . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . $sql_forum; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { if (empty($row['log_operation'])) { continue; } + $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - $s_lang_keys .= ''; + + if (isset($user->lang[$row['log_operation']])) + { + $text = htmlspecialchars(strip_tags(str_replace('
', ' ', $user->lang[$row['log_operation']])), ENT_COMPAT, 'UTF-8'); + + // Fill in sprintf placeholders with translated placeholder text + if (substr_count($text, '%')) + { + $text = vsprintf($text, array_fill(0, substr_count($text, '%'), $user->lang['LOGS_PLACEHOLDER'])); + } + } + else + { + $text = ucfirst(str_replace('_', ' ', strtolower($row['log_operation']))); + } + + $s_lang_keys .= ''; } $db->sql_freeresult($result); diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index b83e364811..db22259ec4 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -186,14 +186,32 @@ class mcp_logs ' . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . $sql_forum; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { if (empty($row['log_operation'])) { continue; } + $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - $s_lang_keys .= ''; + + if (isset($user->lang[$row['log_operation']])) + { + $text = htmlspecialchars(strip_tags(str_replace('
', ' ', $user->lang[$row['log_operation']])), ENT_COMPAT, 'UTF-8'); + + // Fill in sprintf placeholders with translated placeholder text + if (substr_count($text, '%')) + { + $text = vsprintf($text, array_fill(0, substr_count($text, '%'), $user->lang['LOGS_PLACEHOLDER'])); + } + } + else + { + $text = ucfirst(str_replace('_', ' ', strtolower($row['log_operation']))); + } + + $s_lang_keys .= ''; } $db->sql_freeresult($result); -- cgit v1.2.1 From b6ebd2e4972f8cff7e16ed96788b1fa861f7568d Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 26 Jul 2009 17:58:10 +0000 Subject: XHTML mistakes in the updater. #46585 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9861 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php index 02fb6ccc37..5cb1b6ada9 100644 --- a/phpBB/includes/diff/renderer.php +++ b/phpBB/includes/diff/renderer.php @@ -536,7 +536,7 @@ class diff_renderer_raw extends diff_renderer */ function get_diff_content($diff) { - return ''; + return ''; } function _block_header($xbeg, $xlen, $ybeg, $ylen) -- cgit v1.2.1 From e7b3a68259b37c497037a1a2a0c2c7e3f862623f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 26 Jul 2009 20:22:41 +0000 Subject: geez, maybe we should stop displaying text and this would become easier git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9864 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_front.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index b844796955..3f73bde7d8 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -322,14 +322,14 @@ function mcp_front_view($id, $mode, $action) if ($total == 0) { $template->assign_vars(array( - 'L_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], + 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], 'S_HAS_PM_REPORTS' => false) ); } else { $template->assign_vars(array( - 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), + 'L_PM_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), 'S_HAS_PM_REPORTS' => true) ); } -- cgit v1.2.1 From 63dc25e5b4596d0f00e4f1dff7fb232141e5227c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 06:15:47 +0000 Subject: #48685 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9865 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 7367816ae8..0a0a9f9211 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -54,7 +54,7 @@ class phpbb_captcha_qa $user->add_lang('captcha_qa'); // read input $this->confirm_id = request_var('qa_confirm_id', ''); - $this->answer = request_var('qa_answer', ''); + $this->answer = request_var('qa_answer', '', true); $this->type = (int) $type; $this->question_lang = $user->data['user_lang']; @@ -448,7 +448,7 @@ class phpbb_captcha_qa { global $db; - $answer = ($this->question_strict) ? request_var('qa_answer', '') : utf8_clean_string(request_var('qa_answer', '')); + $answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true)); $sql = 'SELECT answer_text FROM ' . ANSWERS_TABLE . ' @@ -578,9 +578,9 @@ class phpbb_captcha_qa { // okay, show the editor $error = false; - $input_question = request_var('question_text', ''); - $input_answers = request_var('answers', ''); - $input_lang = request_var('lang_iso', ''); + $input_question = request_var('question_text', '', true); + $input_answers = request_var('answers', '', true); + $input_lang = request_var('lang_iso', '', true); $input_strict = request_var('strict', false); $langs = $this->get_languages(); foreach ($langs as $lang => $entry) @@ -724,10 +724,10 @@ class phpbb_captcha_qa global $db; $question = array( - 'question_text' => request_var('question_text', ''), + 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => explode("\n", request_var('answers', '')), + 'answers' => explode("\n", request_var('answers', '', true)), ); return $question; -- cgit v1.2.1 From a0acfb6a3fce9a547d19c28ac99654275152ac98 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 11:39:28 +0000 Subject: Minor captcha API change - disable display of plugin by returning false in get_template. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9869 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../includes/captcha/plugins/captcha_abstract.php | 37 +++++++++++++--------- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 21 ++++++++---- .../captcha/plugins/phpbb_recaptcha_plugin.php | 27 ++++++++++------ phpBB/includes/functions.php | 1 - phpBB/includes/ucp/ucp_register.php | 3 +- 5 files changed, 54 insertions(+), 35 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index fb64063a90..d24e554188 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -87,21 +87,28 @@ class phpbb_default_captcha { global $config, $user, $template, $phpEx, $phpbb_root_path; - $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; - - $template->assign_vars(array( - 'CONFIRM_IMAGE_LINK' => $link, - 'CONFIRM_IMAGE' => '', - 'CONFIRM_IMG' => '', - 'CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, - 'L_CONFIRM_EXPLAIN' => $explain, - )); - - return 'captcha_default.html'; + if ($this->is_solved()) + { + return false; + } + else + { + $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); + $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; + + $template->assign_vars(array( + 'CONFIRM_IMAGE_LINK' => $link, + 'CONFIRM_IMAGE' => '', + 'CONFIRM_IMG' => '', + 'CONFIRM_ID' => $this->confirm_id, + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, + 'L_CONFIRM_EXPLAIN' => $explain, + )); + + return 'captcha_default.html'; + } } function get_demo_template($id) diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 0a0a9f9211..1b34f26bfa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -171,14 +171,21 @@ class phpbb_captcha_qa { global $template; - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $this->question_text, - 'QA_CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); + if ($this->is_solved()) + { + return false; + } + else + { + $template->assign_vars(array( + 'QA_CONFIRM_QUESTION' => $this->question_text, + 'QA_CONFIRM_ID' => $this->confirm_id, + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); - return 'captcha_qa.html'; + return 'captcha_qa.html'; + } } /** diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index f148b12656..9a2cc11ebd 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -128,16 +128,23 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $user, $template; - $template->assign_vars(array( - 'RECAPTCHA_SERVER' => $this->recaptcha_server, - 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', - 'RECAPTCHA_ERRORGET' => '', - 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); - - return 'captcha_recaptcha.html'; + if ($this->is_solved()) + { + return false; + } + else + { + $template->assign_vars(array( + 'RECAPTCHA_SERVER' => $this->recaptcha_server, + 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', + 'RECAPTCHA_ERRORGET' => '', + 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); + + return 'captcha_recaptcha.html'; + } } function get_demo_template($id) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2d86b233f7..4badd69e9f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2752,7 +2752,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha->reset(); $template->assign_vars(array( - 'S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index da62061a72..f428b4603c 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -446,10 +446,9 @@ class ucp_register $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm'] && !$captcha->is_solved()) + if ($config['enable_confirm']) { $template->assign_vars(array( - 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); } -- cgit v1.2.1 From d2aca86b4a1858200a032e7bf4fdd997bc339331 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 27 Jul 2009 12:43:57 +0000 Subject: Fix a bug in r9781 #48595 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9871 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 567606cfc7..d1e8b6d9c4 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -33,6 +33,7 @@ class acp_logs // Set up general vars $action = request_var('action', ''); $forum_id = request_var('f', 0); + $topic_id = request_var('t', 0); $start = request_var('start', 0); $deletemark = (!empty($_POST['delmarked'])) ? true : false; $deleteall = (!empty($_POST['delall'])) ? true : false; -- cgit v1.2.1 From 986576e2457522e4d8fc1f877210b3aff60eefea Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 27 Jul 2009 12:57:29 +0000 Subject: Fix an SQL error git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9872 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index aeb378953d..8fc895efdc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2376,7 +2376,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id WHERE l.log_type = $log_type AND u.user_id = l.user_id " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . - (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + (!empty($log_operation) ? " AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); -- cgit v1.2.1 From f0820bc4426983ec7ef64e4ae7684020464fe6dc Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 13:19:06 +0000 Subject: typo git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9874 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 9a2cc11ebd..3ad58851b4 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -156,7 +156,7 @@ class phpbb_recaptcha extends phpbb_default_captcha { $hidden_fields = array(); - // this is required for postig.php - otherwise we would forget about the captcha being already solved + // this is required for posting.php - otherwise we would forget about the captcha being already solved if ($this->solved) { $hidden_fields['confirm_code'] = $this->confirm_code; -- cgit v1.2.1 From 78b1c4caaa17cc8760b685ad41c19f15f9d89b68 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 27 Jul 2009 15:05:59 +0000 Subject: Do not send private message back to sender if sender is in the same group the private message was sent to. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9876 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 883d8ff13f..b201329b20 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1356,6 +1356,12 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) while ($row = $db->sql_fetchrow($result)) { + // Additionally, do not include the sender if he is in the group he wants to send to. ;) + if ($row['user_id'] === $user->data['user_id']) + { + continue; + } + $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; $recipients[$row['user_id']] = $field; } @@ -1901,7 +1907,7 @@ function get_recipient_strings($pm_by_id) foreach ($pm_by_id as $message_id => $row) { $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - + foreach ($_types as $ug_type) { if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) -- cgit v1.2.1 From fc4aaa3f5a32d8d7295197f15b2b9355b851342a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 28 Jul 2009 07:05:17 +0000 Subject: #48735 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9877 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 1b34f26bfa..4836d7906f 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -32,7 +32,6 @@ define('QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm'); class phpbb_captcha_qa { var $confirm_id; - var $confirm_code; var $answer; var $question_ids; var $question_text; @@ -509,7 +508,7 @@ class phpbb_captcha_qa $db->sql_query($sql); // we leave the class usable by generating a new question - $this->generate_code(); + $this->select_question(); } /** -- cgit v1.2.1 From 6510aef869e455ae6748e4719cb6cb187264f4bb Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 28 Jul 2009 11:47:32 +0000 Subject: Fix bug #48345 - Adding users to group - default rank does not changing correctly Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9879 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index e8584239ad..324be2b1ed 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2780,7 +2780,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, if ($default) { - group_set_user_default($group_id, $user_id_ary, $group_attributes); + group_user_attributes('default', $group_id, $user_id_ary, false, $group_name, $group_attributes); } $db->sql_transaction('commit'); -- cgit v1.2.1 From da169625a6a4e7682f0b3a2623f2081e52ad4a49 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Tue, 28 Jul 2009 13:58:01 +0000 Subject: - Display version check on ACP main page. - Cache version check. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9880 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 21 ++++++++++++++++++++ phpBB/includes/acp/acp_update.php | 8 ++------ phpBB/includes/functions_admin.php | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index f9d611f8db..8a5918b558 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -395,6 +395,25 @@ class acp_main } } + // Version check + $user->add_lang('install'); + + $latest_version_info = false; + if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false) + { + $template->assign_var('S_VERSIONCHECK_FAIL', true); + } + else + { + $latest_version_info = explode("\n", $latest_version_info); + $latest_version = trim($latest_version_info[0]); + $template->assign_var('S_VERSION_UP_TO_DATE', + version_compare( + str_replace('rc', 'RC', strtolower($config['version'])), + str_replace('rc', 'RC', strtolower($latest_version)), + '<') ? false : true); + } + // Get forum statistics $total_posts = $config['num_posts']; $total_topics = $config['num_topics']; @@ -492,6 +511,8 @@ class acp_main 'U_ACTION' => $this->u_action, 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'), 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'), + 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&mode=version_check'), + 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=1&versioncheck_force=1'), 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index dbb25bdbbd..121c72aeb3 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -37,12 +37,7 @@ class acp_update $errstr = ''; $errno = 0; - $info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); - - if ($info === false) - { - trigger_error($errstr, E_USER_WARNING); - } + $info = obtain_latest_version_info(request_var('versioncheck_force', false), true); $info = explode("\n", $info); $latest_version = trim($info[0]); @@ -68,6 +63,7 @@ class acp_update 'S_UP_TO_DATE_AUTO' => $up_to_date_automatic, 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, + 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 8fc895efdc..afd00f88bf 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3054,4 +3054,43 @@ function add_permission_language() return true; } +/** + * Obtains the latest version information + * + * @param bool $force_update Ignores cached data. Defaults to false. + * @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false. + * @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours). + * + * @return string | false Version info on success, false on failure. + */ +function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400) +{ + global $cache; + + $info = $cache->get('versioncheck'); + + if ($info === false || $force_update) + { + $errstr = ''; + $errno = 0; + + $info = get_remote_file('www.phpbb.com', '/updatecheck', + ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); + + if ($info === false) + { + $cache->destroy('versioncheck'); + if ($warn_fail) + { + trigger_error($errstr, E_USER_WARNING); + } + return false; + } + + $cache->put('versioncheck', $info, $ttl); + } + + return $info; +} + ?> \ No newline at end of file -- cgit v1.2.1 From d2420fe5550454871e784be846849d3e57dde5e8 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 28 Jul 2009 14:34:12 +0000 Subject: Fix r9855 for #46765 Authorised by: bantu git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9882 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4badd69e9f..639e9aa899 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4210,7 +4210,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " WHERE topic_last_post_time > {$user->data['user_lastmark']} - AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' + AND " . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " $sql_extra ORDER BY topic_last_post_time DESC"; -- cgit v1.2.1 From e2d24413b6323ec1863b01413082ef7f7daa739b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 14:56:39 +0000 Subject: More small adjustments to get_unread_topics_list(). #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9883 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 639e9aa899..289f7f084f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4139,7 +4139,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') if ($user_id === false) { - $user_id = $user->data['user_id']; + $user_id = (int) $user->data['user_id']; } $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); @@ -4151,11 +4151,12 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') // This list is to fetch later the forums user never read (fully) before $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user_id}"; + WHERE user_id = $user_id"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $tracked_forums_list[] = $row['forum_id']; + $tracked_forums_list[] = (int) $row['forum_id']; } $db->sql_freeresult($result); @@ -4164,20 +4165,21 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id AND t.topic_last_post_time >= tt.mark_time - AND tt.user_id = {$user_id} + AND tt.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { if ($row['topic_last_post_time'] == $row['mark_time']) { // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = $row['mark_time']; + $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; } else { - $unread_topics_list[$row['topic_id']] = $row['mark_time']; + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; } } $db->sql_freeresult($result); @@ -4192,13 +4194,14 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') WHERE t.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = {$user_id} + AND ft.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = $row['mark_time']; + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; } $db->sql_freeresult($result); @@ -4208,16 +4211,17 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') // And the last step - find unread topics were not found before (that can mean a user has never read some forums) $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . " - WHERE topic_last_post_time > {$user->data['user_lastmark']} - AND " . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' + FROM ' . TOPICS_TABLE . ' + WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " $sql_extra ORDER BY topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); + while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; } $db->sql_freeresult($result); } -- cgit v1.2.1 From da0da0dd8990b11b4005c290ab448fb0dc175454 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 15:30:47 +0000 Subject: Move get_unread_topics_list() up in functions.php, added some documentation. Related to #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9884 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 216 ++++++++++++++++++++++--------------------- 1 file changed, 111 insertions(+), 105 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 289f7f084f..3aaa6fbcab 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1644,6 +1644,117 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis return $last_read; } +/** +* Get list of unread topics +* only for registered users and non-cookie tracking +* +* @param int $user_id User ID (or false for currect user) +* @param string $sql_extra Extra WHERE SQL statement +* +* @return array[int][int] Topic ids as keys, mark_time of topic as value +* @author rxu +*/ +function get_unread_topics_list($user_id = false, $sql_extra = '') +{ + global $config, $db, $user; + + if ($user_id === false) + { + $user_id = (int) $user->data['user_id']; + } + + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); + $tracked_forums_list = array(); + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + // Get list of the unread topics - on topics tracking as the first step + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + WHERE t.topic_id = tt.topic_id + AND t.topic_last_post_time >= tt.mark_time + AND tt.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['topic_last_post_time'] == $row['mark_time']) + { + // Check if there're read topics for the forums having unread ones + $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + else + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + } + $db->sql_freeresult($result); + + // Get the full list of the tracked topics + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + $db->sql_freeresult($result); + + // Refresh the full list of the tracked topics + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql_extra + ORDER BY topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, 1000); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + // We do not implement unread topics list for cookie based tracking + // because it would require expensive database queries + } + + return $unread_topics_list; +} + /** * Check for read forums and update topic tracking info accordingly * @@ -4129,109 +4240,4 @@ function phpbb_user_session_handler() return; } -/* -* Get list of unread topics -* only for registered users and non-cookie tracking this function is used -*/ -function get_unread_topics_list($user_id = false, $sql_extra = '') -{ - global $config, $db, $user; - - if ($user_id === false) - { - $user_id = (int) $user->data['user_id']; - } - - $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = array(); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt - WHERE t.topic_id = tt.topic_id - AND t.topic_last_post_time >= tt.mark_time - AND tt.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_last_post_time'] == $row['mark_time']) - { - // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - else - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - } - $db->sql_freeresult($result); - - // Get the full list of the tracked topics - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); - - // Refresh the full list of the tracked topics - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " - $sql_extra - ORDER BY topic_last_post_time DESC"; - $result = $db->sql_query_limit($sql, 1000); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; - } - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - // We do not implement unread topics list for cookie based tracking - // because it would require expensive database queries - } - - return $unread_topics_list; -} - ?> \ No newline at end of file -- cgit v1.2.1 From 8880e86f7b93c8b03e4f788c6abc17b429b390e7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 20:29:34 +0000 Subject: Fix tiny typo in r9884, #46765. Thanks rxu. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9885 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3aaa6fbcab..241bed408f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1648,7 +1648,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * Get list of unread topics * only for registered users and non-cookie tracking * -* @param int $user_id User ID (or false for currect user) +* @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement * * @return array[int][int] Topic ids as keys, mark_time of topic as value -- cgit v1.2.1 From 1b8a1f73d77d3df21b8404611a130bb4ee19b822 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 22:09:46 +0000 Subject: [Feature] Ability to copy permissions from one forum to several other forums. [Fix] Add log entry when copying forum permissions. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9887 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 58 +---------- phpBB/includes/acp/acp_permissions.php | 66 +++++++++++++ phpBB/includes/acp/info/acp_permissions.php | 1 + phpBB/includes/functions_admin.php | 143 ++++++++++++++++++++++++++++ 4 files changed, 211 insertions(+), 57 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 810caa62d5..b6a13acd01 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -187,63 +187,7 @@ class acp_forums if (!empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id'] && (($action != 'edit') || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) { - // if we edit a forum delete current permissions first - if ($action == 'edit') - { - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE forum_id = ' . (int) $forum_data['forum_id']; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE forum_id = ' . (int) $forum_data['forum_id']; - $db->sql_query($sql); - } - - // From the mysql documentation: - // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. - // Due to this we stay on the safe side if we do the insertion "the manual way" - - // Copy permisisons from/to the acl users table (only forum_id gets changed) - $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_USERS_TABLE . ' - WHERE forum_id = ' . $forum_perm_from; - $result = $db->sql_query($sql); - - $users_sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $users_sql_ary[] = array( - 'user_id' => (int) $row['user_id'], - 'forum_id' => (int) $forum_data['forum_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'] - ); - } - $db->sql_freeresult($result); - - // Copy permisisons from/to the acl groups table (only forum_id gets changed) - $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_GROUPS_TABLE . ' - WHERE forum_id = ' . $forum_perm_from; - $result = $db->sql_query($sql); - - $groups_sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups_sql_ary[] = array( - 'group_id' => (int) $row['group_id'], - 'forum_id' => (int) $forum_data['forum_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'] - ); - } - $db->sql_freeresult($result); - - // Now insert the data - $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); - $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); + copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); cache_moderators(); } diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 8e03a7fa52..6bbe550e4f 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -57,6 +57,21 @@ class acp_permissions trigger_error('NO_MODE', E_USER_ERROR); } + // Copy forum permissions + if ($mode == 'setting_forum_copy') + { + $this->tpl_name = 'permission_forum_copy'; + + if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) + { + $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY'; + $this->copy_forum_permissions(); + return; + } + + trigger_error('NO_MODE', E_USER_ERROR); + } + // Set some vars $action = request_var('action', array('' => 0)); $action = key($action); @@ -1152,6 +1167,57 @@ class acp_permissions )); } + /** + * Handles copying permissions from one forum to others + */ + function copy_forum_permissions() + { + global $auth, $cache, $template, $user; + + $user->add_lang('acp/forums'); + + $submit = isset($_POST['submit']) ? true : false; + + if ($submit) + { + $src = request_var('src_forum_id', 0); + $dest = request_var('dest_forum_ids', array(0)); + + if (confirm_box(true)) + { + if (copy_forum_permissions($src, $dest)) + { + cache_moderators(); + + $auth->acl_clear_prefetch(); + $cache->destroy('sql', FORUMS_TABLE); + + trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); + } + else + { + trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); + } + } + else + { + $s_hidden_fields = array( + 'submit' => $submit, + 'src_forum_id' => $src, + 'dest_forum_ids' => $dest, + ); + + $s_hidden_fields = build_hidden_fields($s_hidden_fields); + + confirm_box(false, $user->lang['CONFIRM_OPERATION'] . ' ' . $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); + } + } + + $template->assign_vars(array( + 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false), + )); + } + /** * Get already assigned users/groups */ diff --git a/phpBB/includes/acp/info/acp_permissions.php b/phpBB/includes/acp/info/acp_permissions.php index 22de666af3..6f341742f3 100644 --- a/phpBB/includes/acp/info/acp_permissions.php +++ b/phpBB/includes/acp/info/acp_permissions.php @@ -24,6 +24,7 @@ class acp_permissions_info 'trace' => array('title' => 'ACP_PERMISSION_TRACE', 'auth' => 'acl_a_viewauth', 'display' => false, 'cat' => array('ACP_PERMISSION_MASKS')), 'setting_forum_local' => array('title' => 'ACP_FORUM_PERMISSIONS', 'auth' => 'acl_a_fauth && (acl_a_authusers || acl_a_authgroups)', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), + 'setting_forum_copy' => array('title' => 'ACP_FORUM_PERMISSIONS_COPY', 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), 'setting_mod_local' => array('title' => 'ACP_FORUM_MODERATORS', 'auth' => 'acl_a_mauth && (acl_a_authusers || acl_a_authgroups)', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS')), 'setting_user_global' => array('title' => 'ACP_USERS_PERMISSIONS', 'auth' => 'acl_a_authusers && (acl_a_aauth || acl_a_mauth || acl_a_uauth)', 'cat' => array('ACP_GLOBAL_PERMISSIONS', 'ACP_CAT_USERS')), 'setting_user_local' => array('title' => 'ACP_USERS_FORUM_PERMISSIONS', 'auth' => 'acl_a_authusers && (acl_a_mauth || acl_a_fauth)', 'cat' => array('ACP_FORUM_BASED_PERMISSIONS', 'ACP_CAT_USERS')), diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index afd00f88bf..e9a95f1ec6 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -306,6 +306,149 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl return $rows; } +/** +* Copies permissions from one forum to others +* +* @param int $src_forum_id The source forum we want to copy permissions from +* @param array $dest_forum_ids The destination forum(s) we want to copy to +* @param bool $clear_dest_perms True if destination permissions should be deleted +* @param bool $add_log True if log entry should be added +* +* @return bool False on error +* +* @author bantu +*/ +function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true) +{ + global $db; + + // Only one forum id specified + if (!is_array($dest_forum_ids)) + { + $dest_forum_ids = array($dest_forum_ids); + } + + // Make sure forum ids are integers + $src_forum_id = (int) $src_forum_id; + $dest_forum_ids = array_map('intval', $dest_forum_ids); + + // No source forum or no destination forums specified + if (empty($src_forum_id) || empty($dest_forum_ids)) + { + return false; + } + + // Check if source forums exists + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + $src_forum_name = $db->sql_fetchfield('forum_name'); + + // Source forum doesn't exist + if (empty($src_forum_name)) + { + return false; + } + + // Check if destination forums exists + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $dest_forum_ids[] = (int) $row['forum_id']; + $dest_forum_names[] = $row['forum_name']; + } + $db->sql_freeresult($result); + + // No destination forum exists + if (empty($dest_forum_ids)) + { + return false; + } + + // From the mysql documentation: + // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear + // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. + // Due to this we stay on the safe side if we do the insertion "the manual way" + + // Rowsets we're going to insert + $users_sql_ary = $groups_sql_ary = array(); + + // Query acl users table for source forum data + $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting + FROM ' . ACL_USERS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row = array( + 'user_id' => (int) $row['user_id'], + 'auth_option_id' => (int) $row['auth_option_id'], + 'auth_role_id' => (int) $row['auth_role_id'], + 'auth_setting' => (int) $row['auth_setting'], + ); + + foreach ($dest_forum_ids as $dest_forum_id) + { + $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id); + } + } + $db->sql_freeresult($result); + + // Query acl groups table for source forum data + $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting + FROM ' . ACL_GROUPS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row = array( + 'group_id' => (int) $row['group_id'], + 'auth_option_id' => (int) $row['auth_option_id'], + 'auth_role_id' => (int) $row['auth_role_id'], + 'auth_setting' => (int) $row['auth_setting'], + ); + + foreach ($dest_forum_ids as $dest_forum_id) + { + $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id); + } + } + $db->sql_freeresult($result); + + $db->sql_transaction('begin'); + + // Clear current permissions of destination forums + if ($clear_dest_perms) + { + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $db->sql_query($sql); + } + + $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); + $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); + + if ($add_log) + { + add_log('admin', 'LOG_FORUM_COPIED_PERMISSIONS', $src_forum_name, implode(', ', $dest_forum_names)); + } + + $db->sql_transaction('commit'); + + return true; +} + /** * Get physical file listing */ -- cgit v1.2.1 From 01fe852ad8eb19e0700e6dd87ec518493adae897 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 29 Jul 2009 09:26:50 +0000 Subject: Slightly adjust version check on index page to be a bit more descriptive git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9889 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 8a5918b558..815a55b5a9 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -345,15 +345,15 @@ class acp_main add_log('admin', 'LOG_PURGE_CACHE'); break; - + case 'purge_sessions': if ((int) $user->data['user_type'] !== USER_FOUNDER) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - + $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); - + foreach ($tables as $table) { switch ($db->sql_layer) @@ -368,7 +368,7 @@ class acp_main break; } } - + // let's restore the admin session $reinsert_ary = array( 'session_id' => (string) $user->session_id, @@ -385,10 +385,10 @@ class acp_main 'session_admin' => 1, 'session_viewonline' => (int) $user->data['session_viewonline'], ); - + $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); $db->sql_query($sql); - + add_log('admin', 'LOG_PURGE_SESSIONS'); break; } @@ -406,12 +406,13 @@ class acp_main else { $latest_version_info = explode("\n", $latest_version_info); - $latest_version = trim($latest_version_info[0]); - $template->assign_var('S_VERSION_UP_TO_DATE', - version_compare( - str_replace('rc', 'RC', strtolower($config['version'])), - str_replace('rc', 'RC', strtolower($latest_version)), - '<') ? false : true); + + $latest_version = str_replace('rc', 'RC', strtolower(trim($latest_version_info[0]))); + $current_version = str_replace('rc', 'RC', strtolower($config['version'])); + + $template->assign_vars(array( + 'S_VERSION_UP_TO_DATE' => version_compare($current_version, $latest_version, '<') ? false : true, + )); } // Get forum statistics -- cgit v1.2.1 From 49625a2aec3f1fbc83952d9d7ba207995120a436 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 29 Jul 2009 22:59:51 +0000 Subject: Props. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9891 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 4836d7906f..76e5a3163c 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -2,7 +2,7 @@ /** * * @package VC -* @version $Id: captcha_abstract.php 9709 2009-06-30 14:23:16Z Kellanved $ +* @version $Id$ * @copyright (c) 2006, 2008 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * -- cgit v1.2.1 From e1db7e08dc560faf176995972d2bc7dbd97627fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Jul 2009 13:39:38 +0000 Subject: Fix Bug #47295 - Min/max characters per posts also affects polls option Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9892 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 7a2d35dbc6..2d7dfb6004 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1062,10 +1062,21 @@ class parse_message extends bbcode_firstpass { global $config, $db, $user; - $mode = ($mode != 'post') ? 'sig' : 'post'; - $this->mode = $mode; + if (!isset($config['max_' . $mode . '_chars'])) + { + $config['max_' . $mode . '_chars'] = 0; + } + if (!isset($config['max_' . $mode . '_smilies'])) + { + $config['max_' . $mode . '_smilies'] = 0; + } + if (!isset($config['max_' . $mode . '_urls'])) + { + $config['max_' . $mode . '_urls'] = 0; + } + $this->allow_img_bbcode = $allow_img_bbcode; $this->allow_flash_bbcode = $allow_flash_bbcode; $this->allow_quote_bbcode = $allow_quote_bbcode; @@ -1100,7 +1111,7 @@ class parse_message extends bbcode_firstpass } // Minimum message length check for post only - if ($mode !== 'sig') + if ($mode === 'post') { if (!$message_length || $message_length < (int) $config['min_post_chars']) { @@ -1153,7 +1164,7 @@ class parse_message extends bbcode_firstpass // Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length. // The maximum length check happened before any parsings. - if ($mode !== 'sig' && utf8_clean_string($this->message) === '') + if ($mode === 'post' && utf8_clean_string($this->message) === '') { $this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; return (!$update_this_message) ? $return_message : $this->warn_msg; @@ -1629,7 +1640,7 @@ class parse_message extends bbcode_firstpass $this->message = $poll['poll_option_text']; $bbcode_bitfield = $this->bbcode_bitfield; - $poll['poll_option_text'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false); + $poll['poll_option_text'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); $bbcode_bitfield = base64_encode(base64_decode($bbcode_bitfield) | base64_decode($this->bbcode_bitfield)); $this->message = $tmp_message; @@ -1652,7 +1663,7 @@ class parse_message extends bbcode_firstpass { $this->warn_msg[] = $user->lang['POLL_TITLE_TOO_LONG']; } - $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false); + $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); if (strlen($poll['poll_title']) > 255) { $this->warn_msg[] = $user->lang['POLL_TITLE_COMP_TOO_LONG']; -- cgit v1.2.1 From 4616cdb066304031adef41ab56a132870ebaea89 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Jul 2009 13:47:27 +0000 Subject: Fix bug #48885, introduced in r9843 Authorised by: kellanved git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9893 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e348694cfe..543472ad4e 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1553,8 +1553,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) { $sql = 'SELECT 1 AS has_attachments FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); + WHERE topic_id = ' . $topic_id; + $result = $db->sql_query_limit($sql, 1); $has_attachments = (int) $db->sql_fetchfield('has_attachments'); $db->sql_freeresult($result); -- cgit v1.2.1 From 686f84a8fc63b867b722573716722b47213cc1de Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 30 Jul 2009 14:35:29 +0000 Subject: Fix Bug #48875 - we compare the bitlength, therefore we indeed do not need to re-cache if we think acl options got changed (which we did) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9894 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 2a269c3c80..02819f9e78 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -64,9 +64,9 @@ class auth $db->sql_freeresult($result); $cache->put('_acl_options', $this->acl_options); - $this->acl_cache($userdata); } - else if (!trim($userdata['user_permissions'])) + + if (!trim($userdata['user_permissions'])) { $this->acl_cache($userdata); } -- cgit v1.2.1 From 312f2c87edbc81af7e332c14d7ce590df183cf60 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 31 Jul 2009 12:46:15 +0000 Subject: Add box if users decided not to select a forum to copy permissions from on forum creation git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9896 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index b6a13acd01..7977654c0a 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -74,6 +74,13 @@ class acp_forums { trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } + + case 'copy_perm': + + if (!(($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) + { + trigger_error($user->lang['NO_PERMISSION_COPY'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } break; } @@ -190,6 +197,12 @@ class acp_forums copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); cache_moderators(); } + else if (($action != 'edit') && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) + { + $this->copy_permission_page($forum_data); + return; + } + $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); @@ -687,6 +700,36 @@ class acp_forums return; break; + + case 'copy_perm': + $forum_perm_from = request_var('forum_perm_from', 0); + + // Copy permissions? + if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) + { + copy_forum_permissions($forum_perm_from, $forum_id, true); + cache_moderators(); + $auth->acl_clear_prefetch(); + $cache->destroy('sql', FORUMS_TABLE); + + $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; + + $message = $user->lang['FORUM_UPDATED']; + + // Redirect to permissions + if ($auth->acl_get('a_fauth')) + { + $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); + } + + // redirect directly to permission settings screen if authed + if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth')) + { + meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); + } + + trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + } } // Default management page @@ -1876,6 +1919,30 @@ class acp_forums adm_page_footer(); } + + function copy_permission_page($forum_data) + { + global $phpEx, $phpbb_admin_path, $template, $user; + + $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; + $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); + + + $l_acl = sprintf($user->lang['COPY_TO_ACL'], '', ''); + + + + $this->tpl_name = 'acp_forums_copy_perm'; + + $template->assign_vars(array( + 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), + 'L_ACL_LINK' => $l_acl, + 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), + 'S_COPY_ACTION' => $action, + 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], false, false, false, false), + )); + } + } ?> \ No newline at end of file -- cgit v1.2.1 From a718e22a3112e85039e562172de9e7fc487f9017 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 31 Jul 2009 14:05:24 +0000 Subject: check changed to allow for undefined lang entries. Proposed by a_jelly_donut git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9898 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index f428b4603c..babedd4f12 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -223,7 +223,7 @@ class ucp_register if ($config['enable_confirm']) { $vc_response = $captcha->validate($data); - if ($vc_response) + if ($vc_response !== false) { $error[] = $vc_response; } -- cgit v1.2.1 From 154f143a8cc866b2d84c9b42257e4f59aa50a945 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 31 Jul 2009 15:49:14 +0000 Subject: Fix bug #48695 - Do not try to create thumbnails for images we cannot open properly. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9899 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 543472ad4e..bf3eef02c4 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -696,6 +696,11 @@ function create_thumbnail($source, $destination, $mimetype) break; } + if (empty($image)) + { + return false; + } + if ($type['version'] == 1) { $new_image = imagecreate($new_width, $new_height); -- cgit v1.2.1 From 3461eaf828848bd27d4777cfd796319dd55c53ce Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 11:01:18 +0000 Subject: Fallback options for missing language files. (Bug #38575 - Patch by EXreaction) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9901 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index c8617057c4..a49716a8db 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2006,6 +2006,34 @@ class user extends session $language_filename = $this->lang_path . $this->lang_name . '/' . (($use_help) ? 'help_' : '') . $lang_file . '.' . $phpEx; } + if (!file_exists($language_filename)) + { + global $config; + + if ($this->lang_name == 'en') + { + // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en. + $language_filename = str_replace($this->lang_path . 'en', $this->lang_path . $this->data['user_lang'], $language_filename); + trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); + } + else if ($this->lang_name == basename($config['default_lang'])) + { + // Fall back to the English Language + $this->lang_name = 'en'; + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); + } + else if ($this->lang_name == $this->data['user_lang']) + { + // Fall back to the board default language + $this->lang_name = basename($config['default_lang']); + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); + } + + // Reset the lang name + $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); + return; + } + // Do not suppress error if in DEBUG_EXTRA mode $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); @@ -2262,11 +2290,11 @@ class user extends session if ($group = remove_newly_registered($this->data['user_id'], $this->data)) { $this->data['group_id'] = $group; - + } $this->data['user_permissions'] = ''; $this->data['user_new'] = 0; - + return true; } } -- cgit v1.2.1 From 530f4963cbc12e0f47f20c13c70587a60d3ad37c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 1 Aug 2009 11:43:39 +0000 Subject: Fix Bug #37585 - Correctly log action when users request to join a group Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9903 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 324be2b1ed..ca6aae2540 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2793,7 +2793,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = get_group_name($group_id); } - $log = ($leader) ? 'LOG_MODS_ADDED' : 'LOG_USERS_ADDED'; + $log = ($leader) ? 'LOG_MODS_ADDED' : (($pending) ? 'LOG_USERS_PENDING' : 'LOG_USERS_ADDED'); add_log('admin', $log, $group_name, implode(', ', $username_ary)); -- cgit v1.2.1 From 6bc7e1516206862472091e53d8f3f357a755eac8 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sat, 1 Aug 2009 12:13:16 +0000 Subject: Addition to r9899 for bug #48695 - trying to create thumbnail for broken jpeg image Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9904 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index bf3eef02c4..ee0d3b7f5d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -684,6 +684,7 @@ function create_thumbnail($source, $destination, $mimetype) break; case IMG_JPG: + @ini_set('gd.jpeg_ignore_warning', 1); $image = @imagecreatefromjpeg($source); break; -- cgit v1.2.1 From 2958890439f29b9cf45997c52c8cfa57e0f16bc8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 12:28:50 +0000 Subject: Apply locale-independent basename() to attachment filenames. New function added: utf8_basename(). (Bug #43335 - Patch by ocean=Yohsuke) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9905 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_attachments.php | 4 ++-- phpBB/includes/functions_admin.php | 4 ++-- phpBB/includes/functions_content.php | 6 +++--- phpBB/includes/functions_convert.php | 10 ++++----- phpBB/includes/functions_posting.php | 10 ++++----- phpBB/includes/functions_privmsgs.php | 2 +- phpBB/includes/functions_upload.php | 8 +++---- phpBB/includes/mcp/mcp_main.php | 4 ++-- phpBB/includes/utf/utf_tools.php | 38 +++++++++++++++++++++++++++++----- 9 files changed, 57 insertions(+), 29 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 0fc0fe0848..849c076f0e 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1027,8 +1027,8 @@ class acp_attachments $template->assign_block_vars('orphan', array( 'FILESIZE' => get_formatted_filesize($row['filesize']), 'FILETIME' => $user->format_date($row['filetime']), - 'REAL_FILENAME' => basename($row['real_filename']), - 'PHYSICAL_FILENAME' => basename($row['physical_filename']), + 'REAL_FILENAME' => utf8_basename($row['real_filename']), + 'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']), 'ATTACH_ID' => $row['attach_id'], 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e9a95f1ec6..38388236eb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1235,7 +1235,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) // Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself. $sql = 'SELECT COUNT(attach_id) AS num_entries FROM ' . ATTACHMENTS_TABLE . " - WHERE physical_filename = '" . $db->sql_escape(basename($filename)) . "'"; + WHERE physical_filename = '" . $db->sql_escape(utf8_basename($filename)) . "'"; $result = $db->sql_query($sql); $num_entries = (int) $db->sql_fetchfield('num_entries'); $db->sql_freeresult($result); @@ -1246,7 +1246,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) return false; } - $filename = ($mode == 'thumbnail') ? 'thumb_' . basename($filename) : basename($filename); + $filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename); return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename); } diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index de5df37299..c4ac48e8e8 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -841,8 +841,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, // Some basics... $attachment['extension'] = strtolower(trim($attachment['extension'])); - $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); - $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']); + $filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']); + $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']); $upload_icon = ''; @@ -866,7 +866,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, 'UPLOAD_ICON' => $upload_icon, 'FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], - 'DOWNLOAD_NAME' => basename($attachment['real_filename']), + 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment, ); diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index f6710ded30..82ec114c09 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -551,7 +551,7 @@ function _import_check($config_var, $source, $use_target) ); // copy file will prepend $phpBB_root_path - $target = $config[$config_var] . '/' . basename(($use_target === false) ? $source : $use_target); + $target = $config[$config_var] . '/' . utf8_basename(($use_target === false) ? $source : $use_target); if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) { @@ -567,11 +567,11 @@ function _import_check($config_var, $source, $use_target) if ($result['copied']) { - $result['target'] = basename($target); + $result['target'] = utf8_basename($target); } else { - $result['target'] = ($use_target !== false) ? $result['orig_source'] : basename($target); + $result['target'] = ($use_target !== false) ? $result['orig_source'] : utf8_basename($target); } return $result; @@ -600,7 +600,7 @@ function import_attachment($source, $use_target = false) { $thumb_dir = $convert->convertor['thumbnails'][0]; $thumb_prefix = $convert->convertor['thumbnails'][1]; - $thumb_source = $thumb_dir . $thumb_prefix . basename($result['source']); + $thumb_source = $thumb_dir . $thumb_prefix . utf8_basename($result['source']); if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) { @@ -2257,7 +2257,7 @@ function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $sour if (substr($trg, -1) == '/') { - $trg .= basename($src); + $trg .= utf8_basename($src); } $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); $trg_path = $trg; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index ee0d3b7f5d..40df716ac9 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -785,7 +785,7 @@ function posting_gen_inline_attachments(&$attachment_data) foreach ($attachment_data as $i => $attachment) { - $s_inline_attachment_options .= ''; + $s_inline_attachment_options .= ''; } $template->assign_var('S_INLINE_ATTACHMENT_OPTIONS', $s_inline_attachment_options); @@ -819,7 +819,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a foreach ($attachment_data as $count => $attach_row) { $hidden = ''; - $attach_row['real_filename'] = basename($attach_row['real_filename']); + $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); foreach ($attach_row as $key => $value) { @@ -829,8 +829,8 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false); $template->assign_block_vars('attach_row', array( - 'FILENAME' => basename($attach_row['real_filename']), - 'A_FILENAME' => addslashes(basename($attach_row['real_filename'])), + 'FILENAME' => utf8_basename($attach_row['real_filename']), + 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), 'FILE_COMMENT' => $attach_row['attach_comment'], 'ATTACH_ID' => $attach_row['attach_id'], 'S_IS_ORPHAN' => $attach_row['is_orphan'], @@ -2175,7 +2175,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u else { // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) + if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) { continue; } diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index b201329b20..955b310335 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1552,7 +1552,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) else { // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) + if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) { continue; } diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index c65d732984..40ff4de2d1 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -58,7 +58,7 @@ class filespec $this->filename = $upload_ary['tmp_name']; $this->filesize = $upload_ary['size']; - $name = trim(htmlspecialchars(basename($upload_ary['name']))); + $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name']))); $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name; $this->mimetype = $upload_ary['type']; @@ -290,7 +290,7 @@ class filespec $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy'; $upload_mode = ($this->local) ? 'local' : $upload_mode; - $this->destination_file = $this->destination_path . '/' . basename($this->realname); + $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); // Check if the file already exist, else there is something wrong... if (file_exists($this->destination_file) && !$overwrite) @@ -634,7 +634,7 @@ class fileupload if ($filedata === false) { - $_FILES[$form_name]['name'] = basename($source_file); + $_FILES[$form_name]['name'] = utf8_basename($source_file); $_FILES[$form_name]['size'] = 0; $mimetype = ''; @@ -746,7 +746,7 @@ class fileupload $ext = array_pop($url['path']); $url['path'] = implode('', $url['path']); - $upload_ary['name'] = basename($url['path']) . (($ext) ? '.' . $ext : ''); + $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : ''); $filename = $url['path']; $filesize = 0; diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 3c265d56da..6c2ac0b521 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1168,8 +1168,8 @@ function mcp_fork_topic($topic_ids) 'in_message' => 0, 'is_orphan' => (int) $attach_row['is_orphan'], 'poster_id' => (int) $attach_row['poster_id'], - 'physical_filename' => (string) basename($attach_row['physical_filename']), - 'real_filename' => (string) basename($attach_row['real_filename']), + 'physical_filename' => (string) utf8_basename($attach_row['physical_filename']), + 'real_filename' => (string) utf8_basename($attach_row['real_filename']), 'download_count' => (int) $attach_row['download_count'], 'attach_comment' => (string) $attach_row['attach_comment'], 'extension' => (string) $attach_row['extension'], diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 8098176837..9ee87a5425 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -70,7 +70,7 @@ if (!extension_loaded('xml')) $pos = 0; $len = strlen($str); $ret = ''; - + while ($pos < $len) { $ord = ord($str[$pos]) & 0xF0; @@ -252,7 +252,7 @@ else if (is_null($offset)) { $ar = explode($needle, $str); - + if (sizeof($ar) > 1) { // Pop off the end of the string where the last match was made @@ -527,7 +527,7 @@ else $op = '^(?:' . $op . '.{' . $oy . '})'; } else - { + { // offset == 0; just anchor the pattern $op = '^'; } @@ -560,7 +560,7 @@ else $lx = (int) ($length / 65535); $ly = $length % 65535; - + // negative length requires a captured group // of length characters if ($lx) @@ -632,7 +632,7 @@ function utf8_str_split($str, $split_len = 1) { return array($str); } - + preg_match_all('/.{' . $split_len . '}|[^\x00]{1,' . $split_len . '}$/us', $str, $ar); return $ar[0]; } @@ -1917,4 +1917,32 @@ function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false) return implode($break, $new_lines); } +/** +* UTF8-safe basename() function +* +* basename() has some limitations and is dependent on the locale setting +* according to the PHP manual. Therefore we provide our own locale independant +* basename function. +* +* @param string $filename The filename basename() should be applied to +* @return string The basenamed filename +*/ +function utf8_basename($filename) +{ + // We always check for forward slash AND backward slash + // because they could be mixed or "sneaked" in. ;) + // You know, never trust user input... + if (strpos($filename, '/') !== false) + { + $filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1); + } + + if (strpos($filename, '\\') !== false) + { + $filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1); + } + + return $filename; +} + ?> \ No newline at end of file -- cgit v1.2.1 From 73a6f7263b02ed694d986967a162f2359f89f709 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 13:52:37 +0000 Subject: Adjust build_url() to not prepend $phpbb_root_path if path returned from redirect() is an URL. This fixes redirect issues with some installations and bridges. (Bug #47535) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9907 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 241bed408f..d147872c34 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2284,7 +2284,7 @@ function redirect($url, $return = false, $disable_cd_check = false) $url = str_replace('&', '&', $url); // Determine which type of redirect we need to handle... - $url_parts = parse_url($url); + $url_parts = @parse_url($url); if ($url_parts === false) { @@ -2497,6 +2497,18 @@ function build_url($strip_vars = false) $redirect .= ($query) ? '?' . $query : ''; } + // We need to be cautious here. + // On some situations, the redirect path is an absolute URL, sometimes a relative path + // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location, + // else we use the URL directly. + $url_parts = @parse_url($redirect); + + // URL + if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host'])) + { + return str_replace('&', '&', $redirect); + } + return $phpbb_root_path . str_replace('&', '&', $redirect); } @@ -3596,7 +3608,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; - + // PHP4 comptibility case E_DEPRECATED: return true; -- cgit v1.2.1 From b7a0ef7e7a5f758cfaf874c84f8fc32c098946ab Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 16:08:05 +0000 Subject: return errors if return_on_error is true for multi_insert (Patch by bantu) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9909 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/dbal.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index b530a572da..95cfc01b14 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -447,7 +447,7 @@ class dbal $ary[] = '(' . implode(', ', $values) . ')'; } - $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); + return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); } else { @@ -458,7 +458,12 @@ class dbal return false; } - $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); + $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); + + if (!$result) + { + return false; + } } } -- cgit v1.2.1 From d78703d73bd40a9d0d553cfb6d39bf5347f84927 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sat, 1 Aug 2009 16:28:02 +0000 Subject: Fix bug #1309 - Multiline [url] not Converted Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9910 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 2d7dfb6004..6e626eeee8 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -115,7 +115,7 @@ class bbcode_firstpass extends bbcode 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")), 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")), - 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), + 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\]((?s).*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), -- cgit v1.2.1 From 93536d87c98ff4dca1e7cdeb975168c446b5e738 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 17:09:43 +0000 Subject: forgot this in r9909 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9911 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/dbal.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 95cfc01b14..0e1d6cba33 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -435,8 +435,7 @@ class dbal // If by accident the sql array is only one-dimensional we build a normal insert statement if (!is_array($_sql_ary)) { - $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); - return true; + return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); } $values = array(); -- cgit v1.2.1 From c748d865b2665147453844980b8db3c98244dbf6 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Sun, 2 Aug 2009 16:44:45 +0000 Subject: #48965 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9914 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 6e626eeee8..72c101f7a3 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1317,7 +1317,7 @@ class parse_message extends bbcode_firstpass } // (assertion) - $match[] = '(?<=^|[\n .])' . preg_quote($row['code'], '#') . '(?![^<>]*>)'; + $match[] = preg_quote($row['code'], '#'); $replace[] = '' . $row['code'] . ''; } $db->sql_freeresult($result); @@ -1327,7 +1327,7 @@ class parse_message extends bbcode_firstpass { if ($max_smilies) { - $num_matches = preg_match_all('#' . implode('|', $match) . '#', $this->message, $matches); + $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#', $this->message, $matches); unset($matches); if ($num_matches !== false && $num_matches > $max_smilies) @@ -1338,7 +1338,7 @@ class parse_message extends bbcode_firstpass } // Make sure the delimiter # is added in front and at the end of every element within $match - $this->message = trim(preg_replace(explode(chr(0), '#' . implode('#' . chr(0) . '#', $match) . '#'), $replace, $this->message)); + $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); } } -- cgit v1.2.1 From 1f871950d8bbefe59e18c00ea3238591c0b73807 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 3 Aug 2009 15:46:56 +0000 Subject: #48985 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9916 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_profile.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index bbe36af9be..1b0ec4b5d5 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -369,6 +369,7 @@ class acp_profile 'field_show_profile'=> 0, 'field_no_view' => 0, 'field_show_on_reg' => 0, + 'field_show_on_vt' => 0, 'lang_name' => utf8_normalize_nfc(request_var('field_ident', '', true)), 'lang_explain' => '', 'lang_default_value'=> '') @@ -379,7 +380,7 @@ class acp_profile // $exclude contains the data we gather in each step $exclude = array( - 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'), + 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'), 2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'), 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') ); @@ -405,6 +406,7 @@ class acp_profile $visibility_ary = array( 'field_required', 'field_show_on_reg', + 'field_show_on_vt', 'field_show_profile', 'field_hide', ); @@ -721,6 +723,7 @@ class acp_profile 'S_STEP_ONE' => true, 'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false, 'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false, + 'S_SHOW_ON_VT' => ($cp->vars['field_show_on_vt']) ? true : false, 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, 'S_SHOW_PROFILE' => ($cp->vars['field_show_profile']) ? true : false, 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, @@ -1036,6 +1039,7 @@ class acp_profile 'field_validation' => $cp->vars['field_validation'], 'field_required' => $cp->vars['field_required'], 'field_show_on_reg' => $cp->vars['field_show_on_reg'], + 'field_show_on_vt' => $cp->vars['field_show_on_vt'], 'field_hide' => $cp->vars['field_hide'], 'field_show_profile' => $cp->vars['field_show_profile'], 'field_no_view' => $cp->vars['field_no_view'] -- cgit v1.2.1 From c8daec7c8239fab1cc45eb94829a1a99fd646d46 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Aug 2009 10:04:54 +0000 Subject: Fix Bug #49035 - Fix general error while registration, through undefined variable $config in validate_referer (Patch by wjvriend) Authorised by: bantu git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9917 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index a49716a8db..b4d817daf9 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1364,6 +1364,8 @@ class session */ function validate_referer($check_script_path = false) { + global $config; + // no referer - nothing to validate, user's fault for turning it off (we only check on POST; so meta can't be the reason) if (empty($this->referer) || empty($this->host)) { @@ -1373,7 +1375,7 @@ class session $host = htmlspecialchars($this->host); $ref = substr($this->referer, strpos($this->referer, '://') + 3); - if (!(stripos($ref, $host) === 0) && (!$config['force_server'] || !(stripos($ref, $config['server_name']) === 0))) + if (!(stripos($ref, $host) === 0) && (!$config['force_server_vars'] || !(stripos($ref, $config['server_name']) === 0))) { return false; } -- cgit v1.2.1 From 0e98a3aee813b4f83b1021d8204b38ba7fd319f0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 4 Aug 2009 13:08:26 +0000 Subject: Even if the recipient of a PM is now inactive (for whatever reason) still display the information in PM recipient lists and do not hide it git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9918 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 955b310335..f6dd29cd99 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1145,8 +1145,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false) { $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $u) . ' - AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + WHERE ' . $db->sql_in_set('user_id', $u); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From 6cd6a907c7d8503896a46f710bb75370f1abcf43 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 4 Aug 2009 14:15:13 +0000 Subject: Separate PM Reply and PM Reply to all in prosilver. Style changes by dhn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9919 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_compose.php | 12 ++++++++---- phpBB/includes/ucp/ucp_pm_viewmessage.php | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index cf82925e1d..2f7c289653 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -46,6 +46,9 @@ function compose_pm($id, $mode, $action) $draft_id = request_var('d', 0); $lastclick = request_var('lastclick', 0); + // Reply to all triggered (quote/reply) + $reply_to_all = request_var('reply_to_all', 0); + // Do NOT use request_var or specialchars here $address_list = isset($_REQUEST['address_list']) ? $_REQUEST['address_list'] : array(); @@ -84,7 +87,7 @@ function compose_pm($id, $mode, $action) } redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm')); } - + // Since viewtopic.php language entries are used in several modes, // we include the language file here $user->add_lang('viewtopic'); @@ -314,13 +317,14 @@ function compose_pm($id, $mode, $action) if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview) { - if ($action == 'quotepost') + // Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all" + if ($action == 'quotepost' || !$reply_to_all) { $address_list = array('u' => array($post['author_id'] => 'to')); } else { - // We try to include every previously listed member from the TO Header + // We try to include every previously listed member from the TO Header - Reply to all $address_list = rebuild_header(array('to' => $post['to_address'])); // Add the author (if he is already listed then this is no shame (it will be overwritten)) @@ -443,7 +447,7 @@ function compose_pm($id, $mode, $action) $max_recipients = (!$max_recipients) ? $config['pm_max_recipients'] : $max_recipients; // If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients - if (($action == 'reply' || $action == 'quote') && $max_recipients) + if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all) { // We try to include every previously listed member from the TO Header $list = rebuild_header(array('to' => $post['to_address'])); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index dd15f5ff37..0e51e268cf 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -169,6 +169,9 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); + // Number of "to" recipients + $num_recipients = (int) preg_match_all('/:?(u|g)_([0-9]+):?/', $message_row['to_address'], $match); + $template->assign_vars(array( 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), @@ -215,13 +218,17 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_QUOTE' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_EDIT' => (($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '', 'U_POST_REPLY_PM' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '', + 'U_POST_REPLY_ALL' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&reply_to_all=1&p=" . $message_row['msg_id'] : '', 'U_PREVIOUS_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=previous", 'U_NEXT_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=next", + 'U_PM_ACTION' => $url . '&mode=compose&f=' . $folder_id . '&p=' . $message_row['msg_id'], + 'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'], 'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false, 'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)), + 'S_PM_RECIPIENTS' => $num_recipients, 'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '', 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '') -- cgit v1.2.1 From ccbbaba91d0314144932c2916229818b0ac71c4e Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 4 Aug 2009 15:34:04 +0000 Subject: add the option to place image debugging information to the log git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9920 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d147872c34..6549ba9b0d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3465,8 +3465,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // remove complete path to installation, with the risk of changing backslashes meant to be there $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); - echo '[phpBB Debug] PHP Notice: in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; + + // we are writing an image - the user won't see the debug, so let's place it in the log + if (defined('IMAGE_OUTPUT')) + { + add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text); + } // echo '

BACKTRACE
' . get_backtrace() . '
' . "\n"; } -- cgit v1.2.1 From 81998a510462f87acf4dc1f93d99b85f1025580c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 4 Aug 2009 15:34:45 +0000 Subject: use new flag to place captcha errors in the error log (if debug is set) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9921 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index d24e554188..ceb9c4f9fb 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -66,6 +66,7 @@ class phpbb_default_captcha $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); $captcha = new captcha(); + define('IMAGE_OUTPUT', 1); $captcha->execute($this->code, $this->seed); } @@ -80,6 +81,7 @@ class phpbb_default_captcha } } $captcha = new captcha(); + define('IMAGE_OUTPUT', 1); $captcha->execute($this->code, $this->seed); } -- cgit v1.2.1 From b6690e51f9a125380cea86f23138ab95db7b51da Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 4 Aug 2009 15:57:38 +0000 Subject: and for pseudocron too (to conisder: log db errors to debug faulty cron jobs) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9923 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6549ba9b0d..13864848a8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3468,7 +3468,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo '[phpBB Debug] PHP Notice: in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; // we are writing an image - the user won't see the debug, so let's place it in the log - if (defined('IMAGE_OUTPUT')) + if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) { add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text); } @@ -3614,7 +3614,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; - // PHP4 comptibility + // PHP4 compatibility case E_DEPRECATED: return true; break; -- cgit v1.2.1 From 4e9ce7060edad3361db224996adb5a87bf083b69 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 5 Aug 2009 12:02:18 +0000 Subject: log general errors in cron, images and when debug is enabled git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9924 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 13864848a8..e797b279c9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3505,6 +3505,14 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; } } + + if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) + { + // let's avoid loops + $db->sql_return_on_error(true); + add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $msg_text); + $db->sql_return_on_error(false); + } garbage_collection(); -- cgit v1.2.1 From 914687075da7769583e2752701121deee61ff525 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Wed, 5 Aug 2009 12:51:48 +0000 Subject: Fix bug #15729 - Global announcements marked as read if all new topics in forum are viewed Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9926 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_display.php | 2 ++ phpBB/includes/functions_posting.php | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e797b279c9..23ed190bcd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1227,7 +1227,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Add 0 to forums array to mark global announcements correctly - $forum_id[] = 0; + // $forum_id[] = 0; if ($config['load_db_lastread'] && $user->data['is_registered']) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 57f416bee4..f9eb4ce4cd 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -251,6 +251,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else { + // Add 0 to forums array to mark global announcements correctly + $forum_ids[] = 0; markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 40df716ac9..61741ceb81 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2531,7 +2531,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', $data['forum_id'], $data['topic_id'], time()); + markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -2539,7 +2539,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $data['forum_id']; + AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); @@ -2552,14 +2552,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) { // Update forum info - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data['forum_id']; + if ($topic_type == POST_GLOBAL) + { + $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0'; + } + else + { + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $data['forum_id']; + } $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); - update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); + update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false); } // Send Notifications -- cgit v1.2.1 From f3a2c096e7f502e877ada6924d1fedffde59d431 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 5 Aug 2009 13:01:03 +0000 Subject: submit_post() now accepts force_approved_state key passed to $data to indicate new posts being approved (true) or unapproved (false). git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9927 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 61741ceb81..0991035c32 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1674,14 +1674,22 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval + // The variable name should be $post_approved, because it indicates if the post is approved or not $post_approval = 1; // Check the permissions for post approval. Moderators are not affected. if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) { + // Post not approved, but in queue $post_approval = 0; } + // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved + if ($data['force_approved_state']) + { + $post_approval = ($data['force_approved_state']) ? 1 : 0; + } + // Start the transaction here $db->sql_transaction('begin'); -- cgit v1.2.1 From 4e117116749ad47c1cfcc24cd2cb24c7271aad1c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 5 Aug 2009 13:05:55 +0000 Subject: Fix Bug #48955 - Correctly extract column default value when exporting PostgreSQL tables. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9928 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_database.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index bf02a58dce..b25518e1c4 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -1157,16 +1157,17 @@ class postgres_extractor extends base_extractor AND (c.oid = d.adrelid) AND d.adnum = " . $row['attnum']; $def_res = $db->sql_query($sql_get_default); + $def_row = $db->sql_fetchrow($def_res); + $db->sql_freeresult($def_res); - if (!$def_res) + if (empty($def_row)) { unset($row['rowdefault']); } else { - $row['rowdefault'] = $db->sql_fetchfield('rowdefault', false, $def_res); + $row['rowdefault'] = $def_row['rowdefault']; } - $db->sql_freeresult($def_res); if ($row['type'] == 'bpchar') { -- cgit v1.2.1 From 2c6e4d7e803d1fa7f1b585dd535f8c2c5fb6357d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 5 Aug 2009 13:11:27 +0000 Subject: fix r9927 - of course isset() git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9929 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 0991035c32..1385934c0e 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1685,7 +1685,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved - if ($data['force_approved_state']) + if (isset($data['force_approved_state'])) { $post_approval = ($data['force_approved_state']) ? 1 : 0; } -- cgit v1.2.1 From ee65d2147b7e672c6dfdcd695f0b6314c40e42d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 Aug 2009 15:28:46 +0000 Subject: fix r9713 for #36565 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9931 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/search/fulltext_mysql.php | 6 ++---- phpBB/includes/search/fulltext_native.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 456a11f24e..f9efa2bcb5 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -444,8 +444,7 @@ class fulltext_mysql extends search_backend if (sizeof($author_ary) && $author_name) { // first one matches post of registered users, second one guests and deleted users - $sql_author = ' AND (' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; - $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; } else if (sizeof($author_ary)) { @@ -553,8 +552,7 @@ class fulltext_mysql extends search_backend if ($author_name) { // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; - $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; } else { diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 513a16bc58..5af3929ccd 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -628,8 +628,7 @@ class fulltext_native extends search_backend if ($author_name) { // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; - $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; } else { @@ -840,8 +839,7 @@ class fulltext_native extends search_backend if ($author_name) { // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $db->sql_in_set('p.poster_id', $author_ary) . " AND p.post_username = ''"; - $sql_author .= ' OR p.poster_id = ' . ANONYMOUS . ' AND p.post_username ' . $author_name . ')'; + $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; } else { -- cgit v1.2.1 From d2c818ffb9ab1081ebbf74d9895156d1805c237a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 7 Aug 2009 13:02:14 +0000 Subject: add transactions to sync(); not one big one to avoid nesting. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9937 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 52 ++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 38388236eb..44675b9cc0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1330,6 +1330,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, switch ($mode) { case 'topic_moved': + $db->sql_transaction('begin'); switch ($db->sql_layer) { case 'mysql4': @@ -1363,12 +1364,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); - + break; } - break; + + $db->sql_transaction('commit'); + break; case 'topic_approved': + + $db->sql_transaction('begin'); switch ($db->sql_layer) { case 'mysql4': @@ -1404,11 +1409,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); break; } - break; + + $db->sql_transaction('commit'); + break; case 'post_reported': $post_ids = $post_reported = array(); - + + $db->sql_transaction('begin'); + $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql @@ -1459,7 +1468,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'topic_reported': if ($sync_extra) @@ -1469,6 +1480,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_reported = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; @@ -1501,11 +1514,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'post_attachment': $post_ids = $post_attachment = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql @@ -1556,7 +1573,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'topic_attachment': if ($sync_extra) @@ -1566,6 +1585,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_attachment = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_attachment = 1"; @@ -1598,10 +1619,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + + break; case 'forum': + $db->sql_transaction('begin'); + // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f @@ -1802,11 +1828,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); } } - break; + + $db->sql_transaction('commit'); + break; case 'topic': $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; @@ -2129,6 +2159,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } unset($topic_data); + $db->sql_transaction('commit'); + // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. @@ -2136,7 +2168,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { sync('forum', 'forum_id', array_values($resync_forums), true, true); } - break; + break; } return; -- cgit v1.2.1 From af6704700855e732dd811de4e8d6730d43a7c392 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 7 Aug 2009 13:53:17 +0000 Subject: Remove some left over code introduced in r9575, reverted in r9704. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9938 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 3a2ad6f89a..7bc94d685e 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -450,13 +450,6 @@ class acp_board continue; } - // If not set, then this is a valid entry and needs to be emptied (select_multiple, checkbox) - if (!isset($cfg_array[$config_name])) - { - $cfg_array[$config_name] = ''; - } - - // Erm, we spotted an array if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) { -- cgit v1.2.1 From 04263dfa312f7daab82ab629477d785253af896a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 7 Aug 2009 14:31:24 +0000 Subject: Coding guidelines: Tiny whitespace change for an unreleased file. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9939 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index ceb9c4f9fb..72f343d6b8 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -100,8 +100,8 @@ class phpbb_default_captcha $template->assign_vars(array( 'CONFIRM_IMAGE_LINK' => $link, - 'CONFIRM_IMAGE' => '', - 'CONFIRM_IMG' => '', + 'CONFIRM_IMAGE' => '', + 'CONFIRM_IMG' => '', 'CONFIRM_ID' => $this->confirm_id, 'S_CONFIRM_CODE' => true, 'S_TYPE' => $this->type, -- cgit v1.2.1 From bc8e507c64a576eef209c5a72cf2965d56d6016a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 7 Aug 2009 15:37:27 +0000 Subject: include vs include_once git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9940 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php | 2 +- phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php | 2 +- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index ce678b6d29..5021045785 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ if (!class_exists('captcha_abstract')) { - include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); + include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } /** diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php index 1fc859532a..ac30ed4297 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ if (!class_exists('phpbb_default_captcha')) { - include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); + include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } /** diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 3ad58851b4..b7b3ab07d3 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) if (!class_exists('phpbb_default_captcha')) { // we need the classic captcha code for tracking solutions and attempts - include_once($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); + include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } /** -- cgit v1.2.1 From d5c6d1d434555167f9d7adfdd3805e92e5bc266c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 10 Aug 2009 09:13:28 +0000 Subject: reverted all changes made to this code block, especially the one mentioned in r9704 with reference to wrong bug report "undoing change from #9575, as it broke the board disabled message". The board disabled message still works fine. If there are any problems with the code and settings within the ACP, please tell me and i will check them. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9941 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 7bc94d685e..ea0de2ef30 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -440,7 +440,7 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + if ($null === false || strpos($config_name, 'legend') !== false) { continue; } @@ -450,6 +450,12 @@ class acp_board continue; } + // If not set, then this is a valid entry and needs to be emptied (select_multiple, checkbox) + if (!isset($cfg_array[$config_name])) + { + $cfg_array[$config_name] = ''; + } + // Erm, we spotted an array if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) { -- cgit v1.2.1 From 2547955b619e009df9c9ee4b8be2cc7c6da14630 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 10 Aug 2009 09:46:38 +0000 Subject: class name git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9942 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index 5021045785..2f55d15efd 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) /** * Placeholder for autoload */ -if (!class_exists('captcha_abstract')) +if (!class_exists('phpbb_default_captcha')) { include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); } -- cgit v1.2.1 From d327154a5a5e9360b8ef5407da56e46a6629b26f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 10 Aug 2009 11:14:21 +0000 Subject: ok, r9704 was correct - i used a wrong code base within my tests. :/ git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9943 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index ea0de2ef30..7bc94d685e 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -440,7 +440,7 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if ($null === false || strpos($config_name, 'legend') !== false) + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } @@ -450,12 +450,6 @@ class acp_board continue; } - // If not set, then this is a valid entry and needs to be emptied (select_multiple, checkbox) - if (!isset($cfg_array[$config_name])) - { - $cfg_array[$config_name] = ''; - } - // Erm, we spotted an array if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) { -- cgit v1.2.1 From dea4eb6a0bbe04cc6fdf354a0564e449547064ff Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 10 Aug 2009 11:17:24 +0000 Subject: check for not set values in acp_board to correctly grab those input elements not populated if empty (checkboxes and multiple select fields) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9944 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 7bc94d685e..bd97c29f02 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -440,7 +440,7 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + if (strpos($config_name, 'legend') !== false) { continue; } @@ -450,6 +450,12 @@ class acp_board continue; } + // It could happen that the cfg array is not set. This happens within feed settings if unselecting all forums in the multiple select fields for example (it is the same as checkbox handling) + if (!isset($cfg_array[$config_name])) + { + $cfg_array[$config_name] = ''; + } + // Erm, we spotted an array if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) { -- cgit v1.2.1 From 3036fbc66fc57ce520c6c5db4f4195370f874e1f Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 10 Aug 2009 12:07:01 +0000 Subject: Fix bug #47705 - Out of range value for column 'topic_replies_real' Authorised by: Kellanved git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9946 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_queue.php | 121 ++++++++++++++------------------------- 1 file changed, 44 insertions(+), 77 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 6209a27bf7..9b318379f1 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -859,89 +859,63 @@ function disapprove_post($post_id_list, $id, $mode) if (confirm_box(true)) { + $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); + $topic_replies_real = $post_disapprove_list = array(); - // If Topic -> forum_topics_real -= 1 - // If Post -> topic_replies_real -= 1 - - $num_disapproved = 0; - $forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array(); - + // Build a list of posts to be unapproved and get the related topics real replies count foreach ($post_info as $post_id => $post_data) { - $topic_id_list[$post_data['topic_id']] = 1; - - if ($post_data['forum_id']) + $post_disapprove_list[$post_id] = $post_data['topic_id']; + if (!isset($topic_replies_real[$post_data['topic_id']])) { - $forum_id_list[$post_data['forum_id']] = 1; + $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; } + } - // Topic or Post. ;) - /** - * @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency? - */ - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) + // Now we build the log array + foreach ($post_disapprove_list as $post_id => $topic_id) + { + // If the count of disapproved posts for the topic is greater + // than topic's real replies count, the whole topic is disapproved/deleted + if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) { - if ($post_data['forum_id']) + // Don't write the log more than once for every topic + if (!isset($disapprove_log_topics[$topic_id])) { - if (!isset($forum_topics_real[$post_data['forum_id']])) - { - $forum_topics_real[$post_data['forum_id']] = 0; - } - $forum_topics_real[$post_data['forum_id']]++; - $num_disapproved++; + // Build disapproved topics log + $disapprove_log_topics[$topic_id] = array( + 'type' => 'topic', + 'post_subject' => $post_info[$post_id]['topic_title'], + 'forum_id' => $post_info[$post_id]['forum_id'], + 'topic_id' => 0, // useless to log a topic id, as it will be deleted + ); } - - $disapprove_log[] = array( - 'type' => 'topic', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => 0, // useless to log a topic id, as it will be deleted - ); } else { - if (!isset($topic_replies_real_sql[$post_data['topic_id']])) - { - $topic_replies_real_sql[$post_data['topic_id']] = 0; - } - $topic_replies_real_sql[$post_data['topic_id']]++; - - $disapprove_log[] = array( + // Build disapproved posts log + $disapprove_log_posts[] = array( 'type' => 'post', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } + 'post_subject' => $post_info[$post_id]['post_subject'], + 'forum_id' => $post_info[$post_id]['forum_id'], + 'topic_id' => $post_info[$post_id]['topic_id'], + ); - $post_disapprove_sql[] = $post_id; + } } - unset($post_data); + // Get disapproved posts/topics counts separately + $num_disapproved_topics = sizeof($disapprove_log_topics); + $num_disapproved_posts = sizeof($disapprove_log_posts); - if (sizeof($forum_topics_real)) - { - foreach ($forum_topics_real as $forum_id => $topics_real) - { - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_topics_real = forum_topics_real - $topics_real - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - } + // Build the whole log + $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); - if (sizeof($topic_replies_real_sql)) - { - foreach ($topic_replies_real_sql as $topic_id => $num_replies) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_replies_real = topic_replies_real - $num_replies - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } + // Unset unneeded arrays + unset($post_data, $disapprove_log_topics, $disapprove_log_posts); - if (sizeof($post_disapprove_sql)) + // Let's do the job - delete disapproved posts + if (sizeof($post_disapprove_list)) { if (!function_exists('delete_posts')) { @@ -949,22 +923,15 @@ function disapprove_post($post_id_list, $id, $mode) } // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts - delete_posts('post_id', $post_disapprove_sql); + // Note: function delete_posts triggers related forums/topics sync, + // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually + delete_posts('post_id', array_keys($post_disapprove_list)); foreach ($disapprove_log as $log_data) { add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason); } } - unset($post_disapprove_sql, $topic_replies_real_sql); - - update_post_information('topic', array_keys($topic_id_list)); - - if (sizeof($forum_id_list)) - { - update_post_information('forum', array_keys($forum_id_list)); - } - unset($topic_id_list, $forum_id_list); $messenger = new messenger(); @@ -1032,13 +999,13 @@ function disapprove_post($post_id_list, $id, $mode) $messenger->save_queue(); - if (sizeof($forum_topics_real)) + if ($num_disapproved_topics) { - $success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; + $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; } else { - $success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; + $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; } } else -- cgit v1.2.1 From 10cdf3506cbd7c8cfb9e7c5286c1bf18f9c94c3a Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 10 Aug 2009 12:09:18 +0000 Subject: Function approve_post adjustment (migrating to sync()) Authorised by: Kellanved git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9947 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_queue.php | 75 +++------------------------------------- 1 file changed, 5 insertions(+), 70 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 9b318379f1..896ff6d39f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -491,11 +491,9 @@ function approve_post($post_id_list, $id, $mode) // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 $total_topics = $total_posts = 0; - $forum_topics_posts = $topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); + $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); $user_posts_sql = $post_approved_list = array(); - $update_forum_information = false; - foreach ($post_info as $post_id => $post_data) { if ($post_data['post_approved']) @@ -523,16 +521,7 @@ function approve_post($post_id_list, $id, $mode) { if ($post_data['forum_id']) { - if (!isset($forum_topics_posts[$post_data['forum_id']])) - { - $forum_topics_posts[$post_data['forum_id']] = array( - 'forum_posts' => 0, - 'forum_topics' => 0 - ); - } - $total_topics++; - $forum_topics_posts[$post_data['forum_id']]['forum_topics']++; } $topic_approve_sql[] = $post_data['topic_id']; @@ -553,44 +542,19 @@ function approve_post($post_id_list, $id, $mode) ); } - if ($post_data['topic_replies_real'] > 0) - { - if (!isset($topic_replies_sql[$post_data['topic_id']])) - { - $topic_replies_sql[$post_data['topic_id']] = 0; - } - $topic_replies_sql[$post_data['topic_id']]++; - } - if ($post_data['forum_id']) { - if (!isset($forum_topics_posts[$post_data['forum_id']])) - { - $forum_topics_posts[$post_data['forum_id']] = array( - 'forum_posts' => 0, - 'forum_topics' => 0 - ); - } - $total_posts++; - $forum_topics_posts[$post_data['forum_id']]['forum_posts']++; // Increment by topic_replies if we approve a topic... // This works because we do not adjust the topic_replies when re-approving a topic after an edit. if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) { $total_posts += $post_data['topic_replies']; - $forum_topics_posts[$post_data['forum_id']]['forum_posts'] += $post_data['topic_replies']; } } $post_approve_sql[] = $post_id; - - // If the post is newer than the last post information stored we need to update the forum information - if ($post_data['post_time'] >= $post_data['forum_last_post_time']) - { - $update_forum_information = true; - } } $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) @@ -614,37 +578,13 @@ function approve_post($post_id_list, $id, $mode) $db->sql_query($sql); } + unset($topic_approve_sql, $post_approve_sql); + foreach ($approve_log as $log_data) { add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']); } - if (sizeof($topic_replies_sql)) - { - foreach ($topic_replies_sql as $topic_id => $num_replies) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_replies = topic_replies + $num_replies - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } - - if (sizeof($forum_topics_posts)) - { - foreach ($forum_topics_posts as $forum_id => $row) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET '; - $sql .= ($row['forum_topics']) ? "forum_topics = forum_topics + {$row['forum_topics']}" : ''; - $sql .= ($row['forum_topics'] && $row['forum_posts']) ? ', ' : ''; - $sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : ''; - $sql .= " WHERE forum_id = $forum_id"; - - $db->sql_query($sql); - } - } - if (sizeof($user_posts_sql)) { // Try to minimize the query count by merging users with the same post count additions @@ -673,14 +613,9 @@ function approve_post($post_id_list, $id, $mode) { set_config_count('num_posts', $total_posts, true); } - unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql); - - update_post_information('topic', array_keys($topic_id_list)); - if ($update_forum_information) - { - update_post_information('forum', array_keys($forum_id_list)); - } + sync('topic', 'topic_id', array_keys($topic_id_list), true); + sync('forum', 'forum_id', array_keys($forum_id_list), true, true); unset($topic_id_list, $forum_id_list); $messenger = new messenger(); -- cgit v1.2.1 From 5078b5e4ccaebcf6897e985cdf8c73a8172a2edf Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Mon, 10 Aug 2009 16:04:44 +0000 Subject: - filtered logs weren't correctly paginated git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9950 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 3 ++- phpBB/includes/mcp/mcp_logs.php | 3 ++- phpBB/includes/mcp/mcp_notes.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index d1e8b6d9c4..861df90777 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -106,6 +106,7 @@ class acp_logs $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $log_operation = request_var('log_operation', ''); + $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; $s_lang_keys = ''; switch ($mode) @@ -213,7 +214,7 @@ class acp_logs 'U_ACTION' => $this->u_action, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start, true), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index db22259ec4..a73227f158 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -165,6 +165,7 @@ class mcp_logs $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $log_operation = request_var('log_operation', ''); + $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; $s_lang_keys = ''; if ($topic_id) @@ -223,7 +224,7 @@ class mcp_logs $template->assign_vars(array( 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param", $log_count, $config['topics_per_page'], $start), 'L_TITLE' => $user->lang['MCP_LOGS'], diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index d07874524a..bc4c1df42f 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -194,6 +194,7 @@ class mcp_notes $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); $log_operation = request_var('log_operation', ''); + $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; $s_lang_keys = ''; $sql = "SELECT DISTINCT log_operation @@ -243,7 +244,7 @@ class mcp_notes 'L_TITLE' => $user->lang['MCP_NOTES_USER'], 'PAGE_NUMBER' => on_page($log_count, $config['posts_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&st=$st&sk=$sk&sd=$sd", $log_count, $config['posts_per_page'], $start), + 'PAGINATION' => generate_pagination($this->u_action . "&st=$st&sk=$sk&sd=$sd$log_operation_param", $log_count, $config['posts_per_page'], $start), 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count), 'RANK_TITLE' => $rank_title, -- cgit v1.2.1 From be963ed93892659005f892767548ee4597e73fcb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 11 Aug 2009 16:24:18 +0000 Subject: allow custom template path for email files git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9957 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 2255b3dcb5..212ae720cb 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -173,7 +173,7 @@ class messenger /** * Set email template to use */ - function template($template_file, $template_lang = '') + function template($template_file, $template_lang = '', $template_path = '') { global $config, $phpbb_root_path, $user; @@ -193,8 +193,11 @@ class messenger $this->tpl_msg[$template_lang . $template_file] = new template(); $tpl = &$this->tpl_msg[$template_lang . $template_file]; - $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $template_path .= $template_lang . '/email'; + if (!$template_path) + { + $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; + $template_path .= $template_lang . '/email'; + } $tpl->set_custom_template($template_path, $template_lang . '_email'); -- cgit v1.2.1 From dedddfabedf357cda8606a6bc6c49ac48028bc07 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 09:19:47 +0000 Subject: change item to item_id; related to #49485 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9958 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 23ed190bcd..6c651b2b86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3692,7 +3692,7 @@ function obtain_users_online($item_id = 0, $item = 'forum') global $db, $config, $user; $reading_sql = ''; - if ($item !== 0) + if ($item_id !== 0) { $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } -- cgit v1.2.1 From 5dd85e232355432f87156270236901df33232721 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Aug 2009 09:22:04 +0000 Subject: Fix r9955 for Bug #49435 (Since $update_message was true in submit_post() the non-parsed text had been entered into the db [because $update_message was false before]) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9959 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 1385934c0e..4cf6b7010d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1621,8 +1621,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) /** * Submit Post +* @todo Split up and create lightweight, simple API for this. */ -function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true) +function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path; @@ -2487,7 +2488,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Index message contents - if ($update_message && $data['enable_indexing']) + if ($update_search_index && $data['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised $search_type = basename($config['search_type']); -- cgit v1.2.1 From 2d0d35db48b0c3aae9952e1cf805beebe222958c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 10:30:37 +0000 Subject: populate who is online only where required git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9961 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6c651b2b86..4f88ee9625 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3861,7 +3861,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' /** * Generate page header */ -function page_header($page_title = '', $display_online_list = true) +function page_header($page_title = '', $display_online_list = true, $forum_id = 0) { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; @@ -3917,10 +3917,18 @@ function page_header($page_title = '', $display_online_list = true) * } * */ - - $item_id = max(request_var('f', 0), 0); + + if ($forum_id) + { + $item_id = max($forum_id, 0); + } + else + { + $item_id = 0; + } + + // workaround legacy code $item = 'forum'; - $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); -- cgit v1.2.1 From 09ad10a734c0993f9465e6ac3463951251602fc6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Aug 2009 15:00:47 +0000 Subject: ok, i am very sorry, but this needs to be fixed. Generally, our config table is not really suited for holding large datasets. Because feed settings for the forums to enable news feeds and excluded forums rely on the forums itself we have decided to introduce a forum_options table where custom options can be stored. Additionally, for this to work across all DBMS we support, we added a new method to the DBAL for the bitwise AND operator. Also moved the forum/topic feed template variable to the location where they belong to (forum and topic view) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9965 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 82 +++++++++++++++++++++++--------------- phpBB/includes/constants.php | 4 ++ phpBB/includes/db/dbal.php | 18 +++++++++ phpBB/includes/db/firebird.php | 5 +++ phpBB/includes/db/oracle.php | 5 +++ phpBB/includes/functions.php | 57 +++++++++++++++++++++++--- phpBB/includes/functions_admin.php | 36 ++++++++--------- 7 files changed, 150 insertions(+), 57 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index bd97c29f02..78ba5092a0 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -272,8 +272,8 @@ class acp_board 'feed_overall_topics_limit' => array('lang' => 'ACP_FEED_OVERALL_TOPIC_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => false), 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_news_forums', 'explain' => true ), - 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'select_multiple', 'method' => 'select_exclude_forums', 'explain' => true), + 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true), + 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true), ) ); break; @@ -440,35 +440,16 @@ class acp_board // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { - if (strpos($config_name, 'legend') !== false) + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } - if ($config_name == 'auth_method') + if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') { continue; } - // It could happen that the cfg array is not set. This happens within feed settings if unselecting all forums in the multiple select fields for example (it is the same as checkbox handling) - if (!isset($cfg_array[$config_name])) - { - $cfg_array[$config_name] = ''; - } - - // Erm, we spotted an array - if ($null['type'] == 'select_multiple' && $submit && isset($_REQUEST['config'][$config_name])) - { - // Get config *array* - $cfg_ = utf8_normalize_nfc(request_var('config', array('' => array('')), true)); - - // Check if the variable is set and an array - if (isset($cfg_[$config_name]) && is_array($cfg_[$config_name])) - { - $cfg_array[$config_name] = trim(serialize($cfg_[$config_name])); - } - } - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($config_name == 'email_function_name') @@ -484,6 +465,13 @@ class acp_board } } + // Store news and exclude ids + if ($mode == 'feed' && $submit) + { + $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id'); + $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id'); + } + if ($mode == 'auth') { // Retrieve a list of auth plugins and check their config values @@ -902,17 +890,17 @@ class acp_board { global $user, $config; - // Determine ids to be selected - $select_ids = (sizeof($value)) ? $value : false; - - $forum_list = make_forum_select($select_ids, false, true, true, true, false, true); + $forum_list = make_forum_select(false, false, true, true, true, false, true); // Build forum options - $s_forum_options = ''; + $s_forum_options = ''; return $s_forum_options; } @@ -921,20 +909,48 @@ class acp_board { global $user, $config; - // Determine ids to be selected - $select_ids = (sizeof($value)) ? $value : false; - - $forum_list = make_forum_select($select_ids, false, true, false, false, false, true); + $forum_list = make_forum_select(false, false, true, false, false, false, true); // Build forum options - $s_forum_options = ''; + $s_forum_options = ''; return $s_forum_options; } + + function store_feed_forums($option, $key) + { + global $db, $cache; + + // Get key + $values = request_var($key, array(0 => 0)); + + // Empty option bit for all forums + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_options = forum_options - ' . (1 << $option) . ' + WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0'); + $db->sql_query($sql); + + // Already emptied for all... + if (sizeof($values)) + { + // Set for selected forums + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_options = forum_options + ' . (1 << $option) . ' + WHERE ' . $db->sql_in_set('forum_id', $values); + $db->sql_query($sql); + } + + // Empty sql cache for forums table because options changed + $cache->destroy('sql', FORUMS_TABLE); + } + } ?> \ No newline at end of file diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 2173f2ee68..98abf18b6f 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -93,6 +93,10 @@ define('FORUM_FLAG_ACTIVE_TOPICS', 16); define('FORUM_FLAG_POST_REVIEW', 32); define('FORUM_FLAG_QUICK_REPLY', 64); +// Forum Options... sequential order. Modifications should begin at number 10 (number 29 is maximum) +define('FORUM_OPTION_FEED_NEWS', 1); +define('FORUM_OPTION_FEED_EXCLUDE', 2); + // Optional text flags define('OPTION_FLAG_BBCODE', 1); define('OPTION_FLAG_SMILIES', 2); diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 0e1d6cba33..5418ed394b 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -411,6 +411,24 @@ class dbal } } + /** + * Run binary AND operator on DB column. + * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_and($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_and')) + { + return $this->_sql_bit_and($column_name, $bit, $compare); + } + + return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + /** * Run more than one insert statement. * diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 3b31942a8b..f5e8595382 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -446,6 +446,11 @@ class dbal_firebird extends dbal return $data; } + function _sql_bit_and($column_name, $bit, $compare = '') + { + return 'BIN_AND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); + } + /** * return sql error array * @access private diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index a140c4b676..10f4a1a7a7 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -568,6 +568,11 @@ class dbal_oracle extends dbal return $data; } + function _sql_bit_and($column_name, $bit, $compare = '') + { + return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); + } + /** * return sql error array * @access private diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4f88ee9625..49e9f41704 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3505,7 +3505,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; } } - + if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) { // let's avoid loops @@ -3857,6 +3857,40 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' ); } +/** +* Get option bitfield from custom data +* +* @param int $bit The bit/value to get +* @param int $data Current bitfield to check +* @return bool Returns true if value of constant is set in bitfield, else false +*/ +function phpbb_optionget($bit, $data) +{ + return ($data & 1 << (int) $bit) ? true : false; +} + +/** +* Set option bitfield +* +* @param int $bit The bit/value to set/unset +* @param bool $set True if option should be set, false if option should be unset. +* @param int $data Current bitfield to change +* +* @return int The new bitfield +*/ +function phpbb_optionset($bit, $set, $data) +{ + if ($set && !($data & 1 << $bit)) + { + $data += 1 << $bit; + } + else if (!$set && ($data & 1 << $bit)) + { + $data -= 1 << $bit; + } + + return $data; +} /** * Generate page header @@ -3917,7 +3951,7 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = * } * */ - + if ($forum_id) { $item_id = max($forum_id, 0); @@ -3926,7 +3960,7 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = { $item_id = 0; } - + // workaround legacy code $item = 'forum'; $online_users = obtain_users_online($item_id, $item); @@ -4005,6 +4039,19 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); + $s_feed_news = false; + + // Get option for news + if ($config['feed_enable']) + { + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); + $result = $db->sql_query_limit($sql, 1, 0, 600); + $s_feed_news = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + } + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -4082,11 +4129,9 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = 'S_TOPIC_ID' => $topic_id, 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, - 'S_ENABLE_FEEDS_NEWS' => ($config['feed_news_id'] != '') ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, - 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_id && strpos($user->page['page_name'], 'viewforum') !== false) ? true : false, - 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && $topic_id && strpos($user->page['page_name'], 'viewtopic') !== false) ? true : false, + 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 44675b9cc0..1931ae3dfa 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -69,7 +69,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel')); // This query is identical to the jumpbox one - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id + $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); @@ -1364,15 +1364,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); - + break; } - + $db->sql_transaction('commit'); break; case 'topic_approved': - + $db->sql_transaction('begin'); switch ($db->sql_layer) { @@ -1409,15 +1409,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); break; } - + $db->sql_transaction('commit'); break; case 'post_reported': $post_ids = $post_reported = array(); - + $db->sql_transaction('begin'); - + $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql @@ -1468,7 +1468,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1481,7 +1481,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_reported = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; @@ -1514,7 +1514,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1522,7 +1522,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $post_ids = $post_attachment = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql @@ -1573,7 +1573,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1619,15 +1619,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); - + break; case 'forum': $db->sql_transaction('begin'); - + // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f @@ -1828,7 +1828,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); } } - + $db->sql_transaction('commit'); break; @@ -1836,7 +1836,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; @@ -2160,7 +2160,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($topic_data); $db->sql_transaction('commit'); - + // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. -- cgit v1.2.1 From af213166f36f3e71e4f3387827629fea5d190711 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 19:57:34 +0000 Subject: some fixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9967 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 76e5a3163c..9b05f25dd3 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -121,7 +121,7 @@ class phpbb_captcha_qa // load language file for pretty display in the ACP dropdown $user->add_lang('captcha_qa'); - if (!self::is_installed()) + if (!phpbb_captcha_qa::is_installed()) { return false; } @@ -273,7 +273,7 @@ class phpbb_captcha_qa 'strict' => array('BOOL', 0), 'lang_id' => array('UINT', 0), 'lang_iso' => array('VCHAR:30', 0), - 'question_text' => array('TEXT', 0), + 'question_text' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'question_id', 'KEYS' => array( @@ -283,7 +283,7 @@ class phpbb_captcha_qa ANSWERS_TABLE => array ( 'COLUMNS' => array( 'question_id' => array('UINT', 0), - 'answer_text' => array('TEXT', 0), + 'answer_text' => array('STEXT_UNI', ''), ), 'KEYS' => array( 'question_id' => array('INDEX', 'question_id'), -- cgit v1.2.1 From 929fd29ce13ad42235b58f327b694a00780ebe5e Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 22:03:14 +0000 Subject: some fixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9968 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 9b05f25dd3..cdbb7ea864 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -272,7 +272,7 @@ class phpbb_captcha_qa 'question_id' => array('UINT', Null, 'auto_increment'), 'strict' => array('BOOL', 0), 'lang_id' => array('UINT', 0), - 'lang_iso' => array('VCHAR:30', 0), + 'lang_iso' => array('VCHAR:30', ''), 'question_text' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'question_id', @@ -293,7 +293,7 @@ class phpbb_captcha_qa 'COLUMNS' => array( 'session_id' => array('CHAR:32', ''), 'confirm_id' => array('CHAR:32', ''), - 'lang_iso' => array('VCHAR:30', 0), + 'lang_iso' => array('VCHAR:30', ''), 'question_id' => array('UINT', 0), 'attempts' => array('UINT', 0), 'confirm_type' => array('USINT', 0), -- cgit v1.2.1 From 4525d1cb733e893762e87a4f597f8489a9917191 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 13 Aug 2009 14:51:47 +0000 Subject: - links to send statistics after install and update - link back to ACP main from send statistics - improved language / better explanation (incl. Bug #48555) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9969 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_send_statistics.php | 3 ++- phpBB/includes/questionnaire/questionnaire.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index 6784d29262..b3baf54983 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -27,7 +27,7 @@ class acp_send_statistics function main($id, $mode) { - global $config, $template; + global $config, $template, $phpbb_admin_path, $phpEx; $collect_url = "http://www.phpbb.com/stats/receive_stats.php"; @@ -55,6 +55,7 @@ class acp_send_statistics $template->assign_vars(array( 'U_COLLECT_STATS' => $collect_url, 'RAW_DATA' => $collector->get_data_for_form(), + 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), )); $raw = $collector->get_data_raw(); diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 88873efdc5..16bd79742d 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -440,7 +440,7 @@ class phpbb_questionnaire_phpbb_data_provider { if (isset($this->config[$name])) { - $result['config.' . $name] = $this->config[$name]; + $result['config_' . $name] = $this->config[$name]; } } -- cgit v1.2.1 From b4baa6a0941aa32db06ddabc56612616fe75605f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 13 Aug 2009 15:25:20 +0000 Subject: Lifted minimum requirement for Firebird DBMS from 2.0+ to 2.1+. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9970 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/firebird.php | 4 ++-- phpBB/includes/functions_install.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index f5e8595382..fb1ef44c55 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -20,7 +20,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); /** * Firebird/Interbase Database Abstraction Layer -* Minimum Requirement is Firebird 2.0 +* Minimum Requirement is Firebird 2.1 * @package dbal */ class dbal_firebird extends dbal @@ -72,7 +72,7 @@ class dbal_firebird extends dbal return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION); } - return ($raw) ? '2.0' : 'Firebird/Interbase'; + return ($raw) ? '2.1' : 'Firebird/Interbase'; } /** diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 7fa299548d..a5889224a1 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -181,7 +181,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 function dbms_select($default = '', $only_20x_options = false) { global $lang; - + $available_dbms = get_available_dbms(false, false, $only_20x_options); $dbms_options = ''; foreach ($available_dbms as $dbms_name => $details) @@ -402,10 +402,10 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } else { - $sql = "SELECT FIRST 0 char_length('') - FROM RDB\$DATABASE"; + $sql = 'SELECT 1 FROM RDB$DATABASE + WHERE BIN_AND(10, 1) = 0'; $result = $db->sql_query($sql); - if (!$result) // This can only fail if char_length is not defined + if (!$result) // This can only fail if BIN_AND is not defined { $error[] = $lang['INST_ERR_DB_NO_FIREBIRD']; } @@ -446,7 +446,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, unset($final); } break; - + case 'oracle': if ($unicode_check) { @@ -468,7 +468,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } } break; - + case 'postgres': if ($unicode_check) { -- cgit v1.2.1 From 63cbd43b5ec139025afe2ba01020d2447e72adc1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 14 Aug 2009 08:49:46 +0000 Subject: That's not supported by php4 and part of the full 3.1 system anyway git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9973 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/captcha_plugin.php | 99 ------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 phpBB/includes/captcha/captcha_plugin.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/captcha_plugin.php b/phpBB/includes/captcha/captcha_plugin.php deleted file mode 100644 index 7c601caa93..0000000000 --- a/phpBB/includes/captcha/captcha_plugin.php +++ /dev/null @@ -1,99 +0,0 @@ - \ No newline at end of file -- cgit v1.2.1 From 918e66758795f744092fce2d423f6d43bb00b7c0 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 14 Aug 2009 10:00:30 +0000 Subject: #49675 #49655 - ATTENTION: small captcha API change git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9975 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_captcha.php | 2 +- .../includes/captcha/plugins/captcha_abstract.php | 8 +++ .../captcha/plugins/phpbb_captcha_gd_plugin.php | 8 +++ .../captcha/plugins/phpbb_captcha_qa_plugin.php | 66 +++++++++++++--------- .../captcha/plugins/phpbb_recaptcha_plugin.php | 8 +++ 5 files changed, 63 insertions(+), 29 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index c3588ceb9e..6e86f412fb 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -67,7 +67,6 @@ class acp_captcha if ($submit && check_form_key($form_key)) { - $config_vars = array_keys($config_vars); foreach ($config_vars as $config_var => $options) { set_config($config_var, request_var($config_var, $options['default'])); @@ -122,6 +121,7 @@ class acp_captcha $template->assign_vars(array( 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), + 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 'CAPTCHA_SELECT' => $captcha_select, )); } diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 72f343d6b8..08ca0a91e4 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -362,6 +362,14 @@ class phpbb_default_captcha return (bool) $this->solved; } + /** + * API function + */ + function has_config() + { + return false; + } + } ?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index ab71da10d7..863d31a45d 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -73,6 +73,14 @@ class phpbb_captcha_gd extends phpbb_default_captcha return can_load_dll('gd'); } + /** + * API function + */ + function has_config() + { + return true; + } + function get_name() { return 'CAPTCHA_GD'; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index cdbb7ea864..84730a738c 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -17,9 +17,9 @@ if (!defined('IN_PHPBB')) } global $table_prefix; -define('QUESTIONS_TABLE', $table_prefix . 'captcha_questions'); -define('ANSWERS_TABLE', $table_prefix . 'captcha_answers'); -define('QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm'); +define('CAPTCHA_QUESTIONS_TABLE', $table_prefix . 'captcha_questions'); +define('CAPTCHA_ANSWERS_TABLE', $table_prefix . 'captcha_answers'); +define('CAPTCHA_QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm'); @@ -59,7 +59,7 @@ class phpbb_captcha_qa $this->question_lang = $user->data['user_lang']; // we need all defined questions - shouldn't be too many, so we can just grab them // try the user's lang first - $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\''; + $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\''; $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) { @@ -70,7 +70,7 @@ class phpbb_captcha_qa if (!sizeof($this->question_ids)) { $this->question_lang = $config['default_lang']; - $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; $result = $db->sql_query($sql, 7200); while ($row = $db->sql_fetchrow($result)) { @@ -108,7 +108,7 @@ class phpbb_captcha_qa include("$phpbb_root_path/includes/db/db_tools.$phpEx"); } $db_tool = new phpbb_db_tools($db); - return $db_tool->sql_table_exists(QUESTIONS_TABLE); + return $db_tool->sql_table_exists(CAPTCHA_QUESTIONS_TABLE); } /** @@ -125,13 +125,23 @@ class phpbb_captcha_qa { return false; } - $sql = 'SELECT COUNT(question_id) as count FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + $sql = 'SELECT COUNT(question_id) as count FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); return ((bool) $row['count']); } + + /** + * API function + */ + function has_config() + { + return true; + } + + /** * API function */ @@ -219,7 +229,7 @@ class phpbb_captcha_qa global $db, $config; $sql = 'SELECT DISTINCT c.session_id - FROM ' . QA_CONFIRM_TABLE . ' c + FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' c LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) WHERE s.session_id IS NULL' . ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); @@ -236,7 +246,7 @@ class phpbb_captcha_qa if (sizeof($sql_in)) { - $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . ' + $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' WHERE ' . $db->sql_in_set('session_id', $sql_in); $db->sql_query($sql); } @@ -264,10 +274,10 @@ class phpbb_captcha_qa include("$phpbb_root_path/includes/db/db_tools.$phpEx"); } $db_tool = new phpbb_db_tools($db); - $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE, QA_CONFIRM_TABLE); + $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE, CAPTCHA_QA_CONFIRM_TABLE); $schemas = array( - QUESTIONS_TABLE => array ( + CAPTCHA_QUESTIONS_TABLE => array ( 'COLUMNS' => array( 'question_id' => array('UINT', Null, 'auto_increment'), 'strict' => array('BOOL', 0), @@ -280,7 +290,7 @@ class phpbb_captcha_qa 'lang_iso' => array('INDEX', 'lang_iso'), ), ), - ANSWERS_TABLE => array ( + CAPTCHA_ANSWERS_TABLE => array ( 'COLUMNS' => array( 'question_id' => array('UINT', 0), 'answer_text' => array('STEXT_UNI', ''), @@ -289,7 +299,7 @@ class phpbb_captcha_qa 'question_id' => array('INDEX', 'question_id'), ), ), - QA_CONFIRM_TABLE => array ( + CAPTCHA_QA_CONFIRM_TABLE => array ( 'COLUMNS' => array( 'session_id' => array('CHAR:32', ''), 'confirm_id' => array('CHAR:32', ''), @@ -363,7 +373,7 @@ class phpbb_captcha_qa $this->confirm_id = md5(unique_id($user->ip)); $this->question = (int) array_rand($this->question_ids); - $sql = 'INSERT INTO ' . QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( + $sql = 'INSERT INTO ' . CAPTCHA_QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'confirm_id' => (string) $this->confirm_id, 'session_id' => (string) $user->session_id, 'lang_iso' => (string) $this->question_lang, @@ -386,7 +396,7 @@ class phpbb_captcha_qa $this->solved = 0; // compute $seed % 0x7fffffff - $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( 'question' => (int) $this->question,)) . ' WHERE confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' @@ -407,7 +417,7 @@ class phpbb_captcha_qa $this->solved = 0; // compute $seed % 0x7fffffff - $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( 'question_id' => (int) $this->question)) . ', attempts = attempts + 1 WHERE @@ -425,7 +435,7 @@ class phpbb_captcha_qa global $db, $user; $sql = 'SELECT con.question_id, attempts, question_text, strict - FROM ' . QA_CONFIRM_TABLE . ' con, ' . QUESTIONS_TABLE . " qes + FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' @@ -457,7 +467,7 @@ class phpbb_captcha_qa $answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true)); $sql = 'SELECT answer_text - FROM ' . ANSWERS_TABLE . ' + FROM ' . CAPTCHA_ANSWERS_TABLE . ' WHERE question_id = ' . (int) $this->question; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -480,7 +490,7 @@ class phpbb_captcha_qa { global $db, $user; - $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . " + $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . $this->type; @@ -502,7 +512,7 @@ class phpbb_captcha_qa { global $db, $user; - $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . " + $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . " WHERE session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . (int) $this->type; $db->sql_query($sql); @@ -666,7 +676,7 @@ class phpbb_captcha_qa { global $db, $template; - $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE 1'; + $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE 1'; $result = $db->sql_query($sql); $template->assign_vars(array( 'S_LIST' => true, @@ -697,7 +707,7 @@ class phpbb_captcha_qa if ($question_id) { - $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id; + $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { @@ -709,7 +719,7 @@ class phpbb_captcha_qa return false; } $question['answers'] = array(); - $sql = 'SELECT * FROM ' . ANSWERS_TABLE . ' WHERE question_id = ' . $question_id; + $sql = 'SELECT * FROM ' . CAPTCHA_ANSWERS_TABLE . ' WHERE question_id = ' . $question_id; $result = $db->sql_query($sql); while($row = $db->sql_fetchrow($result)) { @@ -748,13 +758,13 @@ class phpbb_captcha_qa global $db; // easier to delete all answers than to figure out which to update - $sql = "DELETE FROM " . ANSWERS_TABLE . " WHERE question_id = $question_id"; + $sql = "DELETE FROM " . CAPTCHA_ANSWERS_TABLE . " WHERE question_id = $question_id"; $db->sql_query($sql); $langs = $this->get_languages(); $question_ary = $data; $question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id']; unset($question_ary['answers']); - $sql = "UPDATE " . QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . " + $sql = "UPDATE " . CAPTCHA_QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . " WHERE question_id = $question_id"; $db->sql_query($sql); $this->acp_insert_answers($data, $question_id); @@ -773,7 +783,7 @@ class phpbb_captcha_qa $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); - $sql = "INSERT INTO " . QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); + $sql = "INSERT INTO " . CAPTCHA_QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); $db->sql_query($sql); $question_id = $db->sql_nextid(); $this->acp_insert_answers($data, $question_id); @@ -793,7 +803,7 @@ class phpbb_captcha_qa 'question_id' => $question_id, 'answer_text' => $answer, ); - $sql = "INSERT INTO " . ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); + $sql = "INSERT INTO " . CAPTCHA_ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); $db->sql_query($sql); } } @@ -806,7 +816,7 @@ class phpbb_captcha_qa { global $db; - $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE); + $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE); foreach($tables as $table) { $sql = "DELETE FROM $table WHERE question_id = $question_id"; diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index b7b3ab07d3..3634869a06 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,6 +54,14 @@ class phpbb_recaptcha extends phpbb_default_captcha $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } + + /** + * API function + */ + function has_config() + { + return true; + } function get_name() { -- cgit v1.2.1 From 7c6229784bd2f451f3addcac211507289fa5b712 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 14 Aug 2009 10:11:34 +0000 Subject: add back links git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9976 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php | 1 + phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 1 + 2 files changed, 2 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index 863d31a45d..a85566deff 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -140,6 +140,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), + 'U_ACTION' => $module->u_action, )); } } diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 3634869a06..bd965fb10e 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -117,6 +117,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $template->assign_vars(array( 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), + 'U_ACTION' => $module->u_action, )); } -- cgit v1.2.1 From 412bb22acbe3c5cbb0d86d941f98bb8cae909f56 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Aug 2009 10:19:37 +0000 Subject: fix #49685 introduced in r9896 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9977 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7977654c0a..b2e04083fe 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -189,6 +189,7 @@ class acp_forums if (!sizeof($errors)) { $forum_perm_from = request_var('forum_perm_from', 0); + $cache->destroy('sql', FORUMS_TABLE); // Copy permissions? if (!empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id'] && @@ -205,7 +206,6 @@ class acp_forums $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; -- cgit v1.2.1 From 1683559e19c42effff71d21e2210a5a876241c64 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Aug 2009 10:43:31 +0000 Subject: More r9896 cleanup. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9978 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index b2e04083fe..5f56bfb84d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -74,9 +74,9 @@ class acp_forums { trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } - + case 'copy_perm': - + if (!(($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) { trigger_error($user->lang['NO_PERMISSION_COPY'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); @@ -204,7 +204,6 @@ class acp_forums return; } - $auth->acl_clear_prefetch(); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; @@ -722,14 +721,10 @@ class acp_forums $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); } - // redirect directly to permission settings screen if authed - if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth')) - { - meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); - } - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } + + break; } // Default management page @@ -1919,7 +1914,10 @@ class acp_forums adm_page_footer(); } - + + /** + * Display copy permission page + */ function copy_permission_page($forum_data) { global $phpEx, $phpbb_admin_path, $template, $user; @@ -1927,11 +1925,8 @@ class acp_forums $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); - $l_acl = sprintf($user->lang['COPY_TO_ACL'], '', ''); - - $this->tpl_name = 'acp_forums_copy_perm'; $template->assign_vars(array( -- cgit v1.2.1 From a6bf9b4e4aa71da9e0c01e892281d55d661db341 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Aug 2009 11:15:44 +0000 Subject: Some things I missed in r9887. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9979 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 1931ae3dfa..2f8670a147 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,12 +338,13 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forums exists + // Check if source forum exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -357,6 +358,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); + $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; -- cgit v1.2.1 From 079244a39ded84c78b9ca2f2a1fcd0dc178beea7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 15 Aug 2009 10:45:32 +0000 Subject: Fix Bug #49725 introduced in r9814 Authorised by: ToonArmy git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9989 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_front.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 3f73bde7d8..23dbb12a50 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -34,7 +34,7 @@ function mcp_front_view($id, $mode, $action) $forum_id = request_var('f', 0); $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false); - + if (!empty($forum_list)) { $sql = 'SELECT COUNT(post_id) AS total @@ -249,6 +249,7 @@ function mcp_front_view($id, $mode, $action) if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report')) { $template->assign_var('S_SHOW_PM_REPORTS', true); + $user->add_lang(array('ucp')); $sql = 'SELECT COUNT(r.report_id) AS total FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p @@ -262,7 +263,6 @@ function mcp_front_view($id, $mode, $action) if ($total) { include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - $user->add_lang(array('ucp')); $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id', @@ -300,7 +300,7 @@ function mcp_front_view($id, $mode, $action) $template->assign_block_vars('pm_report', array( 'U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"), - + 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), -- cgit v1.2.1 From 74ee1405f3e13064040ef86867cff61199de978d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 15 Aug 2009 10:49:01 +0000 Subject: Fix Bug #49615 - Unapproved topic icon has incorrect forum (introduced in r9635 fixing #46865) Authorised by: ToonArmy git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9990 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f9eb4ce4cd..4bf5c24e0d 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -155,7 +155,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } // Count the difference of real to public topics, so we can display an information to moderators - $row['forum_topics_unapproved'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] - $row['forum_topics'] : 0; + $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] - $row['forum_topics'])) ? $forum_id : 0; $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; // Display active topics from this forum? @@ -214,7 +214,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; } - $forum_rows[$parent_id]['forum_topics_unapproved'] += $row['forum_topics_unapproved']; + if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) + { + $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; + } + $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; // Do not list redirects in LINK Forums as Posts. @@ -456,7 +460,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_FORUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, - 'U_UNAPPROVED_TOPICS' => ($row['forum_topics_unapproved'] > 0) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id']) : '', + 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url) -- cgit v1.2.1 From ee1ae00e033e376b717756d152c461b014da053a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 15 Aug 2009 14:18:19 +0000 Subject: r9961 - also set item name in page_header parameter for better implementation of #31975 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9991 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 49e9f41704..2f8a3ddda6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3895,7 +3895,7 @@ function phpbb_optionset($bit, $set, $data) /** * Generate page header */ -function page_header($page_title = '', $display_online_list = true, $forum_id = 0) +function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; @@ -3937,32 +3937,10 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = { /** * Load online data: - * For obtaining another session column use the following code, whereby the column is session_{$item}_id. - * Put the code directly after $item = 'forum'; - * - * - * $my_item_id = request_var('my_item_id', 0); - * - * if ($my_item_id > 0) - * { - * // would revolve to the column session_myitem_id in the SESSIONS_TABLE - * $item = 'myitem'; - * $item_id = $my_item_id; - * } - * + * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ + $item_id = max($item_id, 0); - if ($forum_id) - { - $item_id = max($forum_id, 0); - } - else - { - $item_id = 0; - } - - // workaround legacy code - $item = 'forum'; $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); -- cgit v1.2.1 From bc57fdc01ce6c1a9275f16a0791c60dbc0b449b7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sat, 15 Aug 2009 16:10:13 +0000 Subject: #49755 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9992 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 84730a738c..7dd5233045 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -676,7 +676,7 @@ class phpbb_captcha_qa { global $db, $template; - $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE 1'; + $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE; $result = $db->sql_query($sql); $template->assign_vars(array( 'S_LIST' => true, @@ -857,7 +857,7 @@ class phpbb_captcha_qa global $db; $langs = array(); - $sql = 'SELECT * FROM ' . LANG_TABLE . ' WHERE 1'; + $sql = 'SELECT * FROM ' . LANG_TABLE; $result = $db->sql_query($sql); while($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From 0393a6232b5aa2b8764c50b40e2cb8b7b0803302 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 15 Aug 2009 19:56:45 +0000 Subject: - #49775 - Some coding guidelines fixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9993 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 101 +++++++++++++-------- 1 file changed, 65 insertions(+), 36 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 7dd5233045..adc0811a57 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -676,15 +676,17 @@ class phpbb_captcha_qa { global $db, $template; - $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE; + $sql = 'SELECT * + FROM ' . CAPTCHA_QUESTIONS_TABLE; $result = $db->sql_query($sql); + $template->assign_vars(array( - 'S_LIST' => true, + 'S_LIST' => true, )); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_class_name() . "&"; + $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_class_name() . '&'; $template->assign_block_vars('questions', array( 'QUESTION_TEXT' => $row['question_text'], @@ -704,31 +706,35 @@ class phpbb_captcha_qa { global $db; - if ($question_id) { - $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id; + $sql = 'SELECT * + FROM ' . CAPTCHA_QUESTIONS_TABLE . ' + WHERE question_id = ' . $question_id; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) - { - $question = $row; - } - else + $question = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$question) { - $db->sql_freeresult($result); return false; } + $question['answers'] = array(); - $sql = 'SELECT * FROM ' . CAPTCHA_ANSWERS_TABLE . ' WHERE question_id = ' . $question_id; + + $sql = 'SELECT * + FROM ' . CAPTCHA_ANSWERS_TABLE . ' + WHERE question_id = ' . $question_id; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + + while ($row = $db->sql_fetchrow($result)) { $question['answers'][] = $row['answer_text']; } $db->sql_freeresult($result); + return $question; } - } @@ -737,15 +743,13 @@ class phpbb_captcha_qa */ function acp_get_question_input() { - global $db; - $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), 'answers' => explode("\n", request_var('answers', '', true)), ); - + return $question; } @@ -755,19 +759,25 @@ class phpbb_captcha_qa */ function acp_update_question($data, $question_id) { - global $db; + global $db, $cache; // easier to delete all answers than to figure out which to update - $sql = "DELETE FROM " . CAPTCHA_ANSWERS_TABLE . " WHERE question_id = $question_id"; + $sql = 'DELETE FROM ' . CAPTCHA_ANSWERS_TABLE . " WHERE question_id = $question_id"; $db->sql_query($sql); + $langs = $this->get_languages(); $question_ary = $data; $question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id']; unset($question_ary['answers']); - $sql = "UPDATE " . CAPTCHA_QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . " - WHERE question_id = $question_id"; + + $sql = 'UPDATE ' . CAPTCHA_QUESTIONS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $question_ary) . " + WHERE question_id = $question_id"; $db->sql_query($sql); + $this->acp_insert_answers($data, $question_id); + + $cache->destroy('sql', CAPTCHA_QUESTIONS_TABLE); } /** @@ -776,17 +786,22 @@ class phpbb_captcha_qa */ function acp_add_question($data) { - global $db; + global $db, $cache; $langs = $this->get_languages(); $question_ary = $data; $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); - $sql = "INSERT INTO " . CAPTCHA_QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); + + $sql = 'INSERT INTO ' . CAPTCHA_QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); $db->sql_query($sql); + $question_id = $db->sql_nextid(); + $this->acp_insert_answers($data, $question_id); + + $cache->destroy('sql', CAPTCHA_QUESTIONS_TABLE); } /** @@ -795,17 +810,20 @@ class phpbb_captcha_qa */ function acp_insert_answers($data, $question_id) { - global $db; + global $db, $cache; - foreach($data['answers'] as $answer) + foreach ($data['answers'] as $answer) { $answer_ary = array( 'question_id' => $question_id, 'answer_text' => $answer, ); - $sql = "INSERT INTO " . CAPTCHA_ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); + + $sql = 'INSERT INTO ' . CAPTCHA_ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); $db->sql_query($sql); } + + $cache->destroy('sql', CAPTCHA_ANSWERS_TABLE); } @@ -814,14 +832,18 @@ class phpbb_captcha_qa */ function acp_delete_question($question_id) { - global $db; - + global $db, $cache; + $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE); - foreach($tables as $table) + + foreach ($tables as $table) { - $sql = "DELETE FROM $table WHERE question_id = $question_id"; + $sql = "DELETE FROM $table + WHERE question_id = $question_id"; $db->sql_query($sql); } + + $cache->destroy('sql', $tables); } @@ -832,6 +854,7 @@ class phpbb_captcha_qa function validate_input($question_data) { $langs = $this->get_languages(); + if (!isset($question_data['lang_iso']) || !isset($question_data['question_text']) || !isset($question_data['strict']) || @@ -839,13 +862,14 @@ class phpbb_captcha_qa { return false; } + if (!isset($langs[$question_data['lang_iso']]) || !$question_data['question_text'] || !sizeof($question_data['answers'])) { return false; } - + return true; } @@ -855,18 +879,23 @@ class phpbb_captcha_qa function get_languages() { global $db; - + $langs = array(); - $sql = 'SELECT * FROM ' . LANG_TABLE; + + $sql = 'SELECT * + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + + while ($row = $db->sql_fetchrow($result)) { $langs[$row['lang_iso']] = array( 'name' => $row['lang_local_name'], - 'id' => $row['lang_id'], + 'id' => (int) $row['lang_id'], ); } $db->sql_freeresult($result); + return $langs; } -- cgit v1.2.1 From 389663872784bd4c411e9b3a813107ec51e70b11 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 16 Aug 2009 20:49:22 +0000 Subject: append_sid git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9996 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/captcha_abstract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index 08ca0a91e4..e5a4e299bd 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -95,7 +95,7 @@ class phpbb_default_captcha } else { - $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); + $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; $template->assign_vars(array( @@ -129,7 +129,7 @@ class phpbb_default_captcha // acp_captcha has a delivery function; let's use it $template->assign_vars(array( - 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx . '?captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()) . $variables, + 'CONFIRM_IMAGE' => append_sid($phpbb_admin_path . 'index.' . $phpEx, 'captcha_demo=1&mode=visual&i=' . $id . '&select_captcha=' . $this->get_class_name()) . $variables, 'CONFIRM_ID' => $this->confirm_id, )); -- cgit v1.2.1 From 6cc55a3436ea81482d0d2462b400e2b66274660d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 16 Aug 2009 21:07:11 +0000 Subject: don't pick a new question without an explicit reset call git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9997 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index adc0811a57..35f42848b3 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -354,7 +354,8 @@ class phpbb_captcha_qa if (strlen($error)) { // okay, incorrect answer. Let's ask a new question. - $this->new_attempt(); + // $this->new_attempt(); + $this->solved = false; return $error; } else @@ -433,7 +434,7 @@ class phpbb_captcha_qa function load_answer() { global $db, $user; - + $sql = 'SELECT con.question_id, attempts, question_text, strict FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id -- cgit v1.2.1 From ba3e0831ea90cdf2fa740088162e57221107748c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 16 Aug 2009 21:11:17 +0000 Subject: erm, on the contrary; can that reset call git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9998 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 35f42848b3..511706bb93 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -354,7 +354,7 @@ class phpbb_captcha_qa if (strlen($error)) { // okay, incorrect answer. Let's ask a new question. - // $this->new_attempt(); + $this->new_attempt(); $this->solved = false; return $error; } -- cgit v1.2.1 From f0ebe145e1d31d11c753bdc404803c3d1be94343 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Aug 2009 09:45:22 +0000 Subject: Fix r9961 - populate who is online only where required Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10000 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2f8a3ddda6..d1883907dd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2706,7 +2706,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo } else { - page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]); + page_header(((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]), false); } $template->set_filenames(array( @@ -3028,7 +3028,7 @@ function login_forum_box($forum_data) $template->assign_var('LOGIN_ERROR', $user->lang['WRONG_PASSWORD']); } - page_header($user->lang['LOGIN']); + page_header($user->lang['LOGIN'], false); $template->assign_vars(array( 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) @@ -3592,7 +3592,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } else { - page_header($msg_title); + page_header($msg_title, false); } } -- cgit v1.2.1 From d42e5a71d23093a4cce4b1a56b7482670258476d Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 17 Aug 2009 13:09:54 +0000 Subject: Fix bug #49625 - Performing actions in Main MCP tab does not return correctly Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10002 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_front.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 23dbb12a50..0ee3eb2466 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -119,7 +119,12 @@ function mcp_front_view($id, $mode, $action) $db->sql_freeresult($result); } + $s_hidden_fields = build_hidden_fields(array( + 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main') + )); + $template->assign_vars(array( + 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"), )); -- cgit v1.2.1 From 300f6868afc4ee53d97d289f85a0383b88ba377e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 13:21:44 +0000 Subject: i am very very sorry for this hackish approach... (ability to skip add_log calls) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10003 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ phpBB/includes/functions_user.php | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d1883907dd..02bd24b246 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3150,6 +3150,14 @@ function add_log() { global $db, $user; + // In phpBB 3.1.x i want to have logging in a class to be able to control it + // For now, we need a quite hakish approach to circumvent logging for some actions + // @todo implement cleanly + if (!empty($GLOBALS['skip_add_log'])) + { + return false; + } + $args = func_get_args(); $mode = array_shift($args); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index ca6aae2540..c562ac666f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -290,6 +290,9 @@ function user_add($user_row, $cp_data = false) if ($add_group_id) { + // Because these actions only fill the log unneccessarily we skip the add_log() entry with a little hack. :/ + $GLOBALS['skip_add_log'] = true; + // Add user to "newly registered users" group and set to default group if admin specified so. if ($config['new_member_group_default']) { @@ -299,6 +302,8 @@ function user_add($user_row, $cp_data = false) { group_user_add($add_group_id, $user_id); } + + unset($GLOBALS['skip_add_log']); } } @@ -3519,12 +3524,12 @@ function remove_newly_registered($user_id, $user_data = false) $user_data = $user_row; } } - + if (empty($user_data['user_new'])) { return false; } - + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'NEWLY_REGISTERED' -- cgit v1.2.1 From 45f570038426f36d547dcdc23ef631bd48a7dc6e Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 17 Aug 2009 13:28:28 +0000 Subject: Add unread posts search support for cookie-based tracking Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10005 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 59 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 02bd24b246..8f263f08e4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1646,7 +1646,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis /** * Get list of unread topics -* only for registered users and non-cookie tracking * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement @@ -1664,7 +1663,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = array(); + $tracked_forums_list = $mark_time = array(); if ($config['load_db_lastread'] && $user->data['is_registered']) { @@ -1748,8 +1747,60 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - // We do not implement unread topics list for cookie based tracking - // because it would require expensive database queries + global $tracking_topics; + + if (!isset($tracking_topics) || !sizeof($tracking_topics)) + { + $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); + } + + if (!$user->data['is_registered']) + { + $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; + } + else + { + $user_lastmark = $user->data['user_lastmark']; + } + + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . $user_lastmark . " + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + + $result = $db->sql_query_limit($sql, 1000); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_id = (int) $row['forum_id']; + $topic_id = (int) $row['topic_id']; + $topic_id36 = base_convert($topic_id, 10, 36); + + if (isset($tracking_topics['t'][$topic_id36])) + { + $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; + if ($row['topic_last_post_time'] > $last_read[$topic_id]) + { + $unread_topics_list[$topic_id] = $last_read[$topic_id]; + } + } + else if (isset($tracking_topics['f'][$forum_id])) + { + $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; + if ($row['topic_last_post_time'] > $mark_time[$forum_id]) + { + $unread_topics_list[$topic_id] = $mark_time[$forum_id]; + } + } + else + { + $unread_topics_list[$topic_id] = $user_lastmark; + } + + } + $db->sql_freeresult($result); } return $unread_topics_list; -- cgit v1.2.1 From f7009291e20969421f90ab81eed1347a4d977501 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 14:45:14 +0000 Subject: Ability to define constant PHPBB_USE_BOARD_URL_PATH to use board url for images/avatars/ranks/imageset... This feature does not change anything for those not using the constant and this feature is also quite in-flux. We need to test this with some applications and bridges and there may be other locations able to benefit from it. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10008 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 44 +++++++++++++++++++++++++----------- phpBB/includes/functions_content.php | 3 ++- phpBB/includes/functions_posting.php | 4 +++- phpBB/includes/session.php | 5 +++- 4 files changed, 40 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8f263f08e4..00af5146cf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4089,6 +4089,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $db->sql_freeresult($result); } + // Determine board url - we may need it later + $board_url = generate_board_url() . '/'; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -4112,6 +4116,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, + 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], @@ -4170,21 +4175,34 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, - 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', - 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', - 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', - 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', - 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : "{$phpbb_root_path}style.$phpEx?sid=$user->session_id&id=" . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], + 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', + 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', + 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', + 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', + 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], + 'T_IMAGES_PATH' => "{$web_path}images/", + 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", + 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", + 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", + 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", + 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", + 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", + 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], + 'T_THEME_NAME' => $user->theme['theme_path'], + 'T_TEMPLATE_NAME' => $user->theme['template_path'], + 'T_SUPER_TEMPLATE_NAME' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? $user->theme['template_inherit_path'] : $user->theme['template_path'], + 'T_IMAGESET_NAME' => $user->theme['imageset_path'], + 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], + 'T_IMAGES' => 'images', + 'T_SMILIES' => $config['smilies_path'], + 'T_AVATAR' => $config['avatar_path'], + 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], + 'T_ICONS' => $config['icons_path'], + 'T_RANKS' => $config['ranks_path'], + 'T_UPLOAD' => $config['upload_path'], + 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c4ac48e8e8..7a30f0069e 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -733,7 +733,8 @@ function smiley_text($text, $force_option = false) } else { - return preg_replace('#', $text); + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + return preg_replace('#', $text); } } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4cf6b7010d..069740ebda 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -112,12 +112,14 @@ function generate_smilies($mode, $forum_id) if (sizeof($smilies)) { + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + foreach ($smilies as $row) { $template->assign_block_vars('smiley', array( 'SMILEY_CODE' => $row['code'], 'A_SMILEY_CODE' => addslashes($row['code']), - 'SMILEY_IMG' => $phpbb_root_path . $config['smilies_path'] . '/' . $row['smiley_url'], + 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $row['smiley_url'], 'SMILEY_WIDTH' => $row['smiley_width'], 'SMILEY_HEIGHT' => $row['smiley_height'], 'SMILEY_DESC' => $row['emotion']) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index b4d817daf9..d0b4c8c285 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2196,7 +2196,10 @@ class user extends session return $img_data; } - $img_data['src'] = $phpbb_root_path . 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; + // Use URL if told so + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + + $img_data['src'] = $root_path . 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; $img_data['width'] = $this->img_array[$img]['image_width']; $img_data['height'] = $this->img_array[$img]['image_height']; } -- cgit v1.2.1 From 2c02367dc05b048fe52329e5fd400b7c51ae1b1b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 15:45:07 +0000 Subject: no need to call generate_board_url() twice - r10008 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10009 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 00af5146cf..172b6a7467 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1796,7 +1796,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } else { - $unread_topics_list[$topic_id] = $user_lastmark; + $unread_topics_list[$topic_id] = $user_lastmark; } } @@ -4091,7 +4091,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url . '/' : $phpbb_root_path; // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( -- cgit v1.2.1 From bfee2c4c67e942d54e1560cd3f099fe7e19b7a59 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 15:47:07 +0000 Subject: i know, i know, no need to hrm me. :P - r10009 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10010 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 172b6a7467..12272b152c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4091,7 +4091,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url . '/' : $phpbb_root_path; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( -- cgit v1.2.1 From 20bf778b93a4057814503dd759d94b50868f6d42 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 18 Aug 2009 01:43:51 +0000 Subject: Per RFC2047 section 5 do not use quoted strings for encoded recipient names git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10011 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 212ae720cb..9b9c013a02 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -455,7 +455,7 @@ class messenger foreach ($address_ary as $which_ary) { - $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name'], $encode_eol) . '" <' . $which_ary['email'] . '>' : $which_ary['email']); + $$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']); } } -- cgit v1.2.1 From 977ba9a68a90a5b926888f616ca7fb05d77576e3 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 18 Aug 2009 01:45:31 +0000 Subject: A little precaution git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10012 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 896ff6d39f..f72007acf5 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -895,7 +895,7 @@ function disapprove_post($post_id_list, $id, $mode) { // Load up the language pack $lang = array(); - @include($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx); + @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); // If we find the reason in this language pack use it if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang])) -- cgit v1.2.1 From 9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Aug 2009 09:59:24 +0000 Subject: Fix email problems on servers with PHP installations not accepting RFC-compliant subject string passed to the the mail()-function. (Bug #46725) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10014 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 43 +++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 9b9c013a02..ecd9709f00 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -390,7 +390,7 @@ class messenger $headers[] = 'X-Priority: ' . $this->mail_priority; $headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High')); - $headers[] = 'X-Mailer: PhpBB3'; + $headers[] = 'X-Mailer: phpBB3'; $headers[] = 'X-MimeOLE: phpBB3'; $headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()); @@ -474,13 +474,7 @@ class messenger } else { - // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... - // Reference: http://bugs.php.net/bug.php?id=15841 - $headers = implode($this->eol, $headers); - - ob_start(); - $result = $config['email_function_name']($mail_to, mail_encode($this->subject, $this->eol), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers); - $err_msg = ob_get_clean(); + $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg); } if (!$result) @@ -723,9 +717,7 @@ class queue } else { - ob_start(); - $result = $config['email_function_name']($to, mail_encode($subject, $this->eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode($this->eol, $headers)); - $err_msg = ob_get_clean(); + $result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg); } if (!$result) @@ -1522,4 +1514,33 @@ function mail_encode($str, $eol = "\r\n") return substr($str, 0, -strlen($delimiter)); } +/** +* Wrapper for sending out emails with the PHP's mail function +*/ +function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) +{ + global $config; + + // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... + // Reference: http://bugs.php.net/bug.php?id=15841 + $headers = implode($eol, $headers); + + ob_start(); + $result = $config['email_function_name']($to, mail_encode($subject, $eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); + $err_msg = ob_get_clean(); + + // Try again... + // On some PHP Versions mail() *may* fail if there are newlines within the subject. + // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. + if (!$result) + { + // Use nothing as delimiter (results in SPACE used) + ob_start(); + $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); + $err_msg = ob_get_clean(); + } + + return $result; +} + ?> \ No newline at end of file -- cgit v1.2.1 From 92a17752944b527c3212ed3d477a5804450be93e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Aug 2009 13:24:45 +0000 Subject: we will use the non-compliant way for mail() until we further inspected PHP's source. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10015 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ecd9709f00..847b2e0c46 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1526,19 +1526,11 @@ function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) $headers = implode($eol, $headers); ob_start(); - $result = $config['email_function_name']($to, mail_encode($subject, $eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); - $err_msg = ob_get_clean(); - - // Try again... // On some PHP Versions mail() *may* fail if there are newlines within the subject. // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. - if (!$result) - { - // Use nothing as delimiter (results in SPACE used) - ob_start(); - $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); - $err_msg = ob_get_clean(); - } + // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used) + $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); + $err_msg = ob_get_clean(); return $result; } -- cgit v1.2.1 From 54362bbe2bd3155262f3a8c7dd3034facc97b06c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 18 Aug 2009 14:37:49 +0000 Subject: Adjustment to r9887: Only use one language variable. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10017 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_permissions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 6bbe550e4f..e9f0af5071 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -1209,7 +1209,7 @@ class acp_permissions $s_hidden_fields = build_hidden_fields($s_hidden_fields); - confirm_box(false, $user->lang['CONFIRM_OPERATION'] . ' ' . $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); + confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); } } -- cgit v1.2.1 From d2d5ecef8d5fba02747b57e58bb89360100ea021 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 18 Aug 2009 14:51:08 +0000 Subject: Better tracking of global announcements Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10018 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 12 ++++++------ phpBB/includes/functions_display.php | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 12272b152c..6750772ebb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1730,13 +1730,13 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " $sql_extra - ORDER BY topic_last_post_time DESC"; + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 4bf5c24e0d..569e1e6400 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -102,6 +102,19 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; + + // Check for unread global announcements + // For index page only we do it + $ga_unread = false; + if ($root_data['forum_id'] == 0) + { + $unread_ga_list = get_unread_topics_list($user->data['user_id'], 'AND t.forum_id = 0'); + if (sizeof($unread_ga_list)) + { + $ga_unread = true; + } + } + while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; @@ -309,6 +322,12 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; + // Mark the first visible forum on index as unread if there's any unread global announcement + if (($forum_id == $forum_ids_moderator[0]) && ($root_data['forum_id'] == 0) && $ga_unread) + { + $forum_unread = true; + } + $folder_image = $folder_alt = $l_subforums = ''; $subforums_list = array(); -- cgit v1.2.1 From bec4b11b64fa8372d430add94f0eee30ee9d0762 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 08:37:06 +0000 Subject: Because we store forwarded_for if the check is activated we need a better check git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10019 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index d0b4c8c285..8d41616123 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -213,7 +213,7 @@ class session $this->update_session_page = $update_session_page; $this->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; $this->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; - $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; + $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? htmlspecialchars((string) $_SERVER['HTTP_X_FORWARDED_FOR']) : ''; $this->host = $this->extract_current_hostname(); $this->page = $this->extract_current_page($phpbb_root_path); @@ -221,10 +221,10 @@ class session // if the forwarded for header shall be checked we have to validate its contents if ($config['forwarded_for_check']) { - $this->forwarded_for = preg_replace('#, +#', ', ', $this->forwarded_for); + $this->forwarded_for = preg_replace('#[ ]{2,}#', ' ', str_replace(array(',', ' '), ' ', $this->forwarded_for)); // split the list of IPs - $ips = explode(', ', $this->forwarded_for); + $ips = explode(' ', $this->forwarded_for); foreach ($ips as $ip) { // check IPv4 first, the IPv6 is hopefully only going to be used very seldomly @@ -267,7 +267,7 @@ class session // Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests // it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip. - $this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; + $this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars((string) $_SERVER['REMOTE_ADDR']) : ''; $this->load = false; // Load limit check (if applicable) @@ -606,7 +606,7 @@ class session } else { - $ips = explode(', ', $this->forwarded_for); + $ips = explode(' ', $this->forwarded_for); $ips[] = $this->ip; $this->check_ban($this->data['user_id'], $ips); } -- cgit v1.2.1 From d8a76b14428d9a5cc955dd0341f032e43f53c7d9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 08:43:10 +0000 Subject: Add some very basic checks to the users ip - related to bug #48995 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10020 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 8d41616123..112cf4e2fd 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -268,6 +268,27 @@ class session // Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests // it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip. $this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars((string) $_SERVER['REMOTE_ADDR']) : ''; + $this->ip = preg_replace('#[ ]{2,}#', ' ', str_replace(array(',', ' '), ' ', $this->ip)); + + // split the list of IPs + $ips = explode(' ', $this->ip); + + // Default IP if REMOTE_ADDR is invalid + $this->ip = '127.0.0.1'; + + foreach ($ips as $ip) + { + // check IPv4 first, the IPv6 is hopefully only going to be used very seldomly + if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) + { + // Just break + break; + } + + // Use the last in chain + $this->ip = $ip; + } + $this->load = false; // Load limit check (if applicable) -- cgit v1.2.1 From 4fb22c972ff64559bc064c3017fbc1c6fd29e523 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 11:40:36 +0000 Subject: fix sql error due to us using STRICT db mode. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10024 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 5f56bfb84d..5a44af836f 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -125,6 +125,7 @@ class acp_forums 'type_action' => request_var('type_action', ''), 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), 'forum_parents' => '', + 'forum_options' => 0, 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), 'forum_link' => request_var('forum_link', ''), 'forum_link_track' => request_var('forum_link_track', false), @@ -443,6 +444,7 @@ class acp_forums 'prune_viewed' => 7, 'prune_freq' => 1, 'forum_flags' => FORUM_FLAG_POST_REVIEW, + 'forum_options' => 0, 'forum_password' => '', 'forum_password_confirm'=> '', ); @@ -699,8 +701,8 @@ class acp_forums return; break; - - case 'copy_perm': + + case 'copy_perm': $forum_perm_from = request_var('forum_perm_from', 0); // Copy permissions? @@ -1921,7 +1923,7 @@ class acp_forums function copy_permission_page($forum_data) { global $phpEx, $phpbb_admin_path, $template, $user; - + $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); -- cgit v1.2.1 From 6d763f7d1e549e6e2e13bef30cb5c39f2c38b07f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 12:04:55 +0000 Subject: add feed switch to forumrow, so forums can be styled correctly (with an rss icon for example) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10026 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 569e1e6400..225603a8b3 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -456,6 +456,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false, 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, 'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false, + 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options'])) ? true : false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], -- cgit v1.2.1 From 38fcaaf1d2781d78aab5c3c25f212ac757c277f4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 12:19:48 +0000 Subject: instead of only enabling forum feeds in viewforum we set it on every location where forums are shown git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10029 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 225603a8b3..2f385ff5ba 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -545,7 +545,7 @@ function generate_forum_rules(&$forum_data) */ function generate_forum_nav(&$forum_data) { - global $db, $user, $template, $auth; + global $db, $user, $template, $auth, $config; global $phpEx, $phpbb_root_path; if (!$auth->acl_get('f_list', $forum_data['forum_id'])) @@ -592,8 +592,10 @@ function generate_forum_nav(&$forum_data) $template->assign_vars(array( 'FORUM_ID' => $forum_data['forum_id'], 'FORUM_NAME' => $forum_data['forum_name'], - 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'])) - ); + 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']), + + 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false, + )); return; } -- cgit v1.2.1 From 20ace274d6b6d370fde9aad6d85cc57740fcfbf1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 20 Aug 2009 14:42:38 +0000 Subject: #50025 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10034 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index bd965fb10e..89d44826d8 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -168,7 +168,7 @@ class phpbb_recaptcha extends phpbb_default_captcha // this is required for posting.php - otherwise we would forget about the captcha being already solved if ($this->solved) { - $hidden_fields['confirm_code'] = $this->confirm_code; + $hidden_fields['confirm_code'] = $this->code; } $hidden_fields['confirm_id'] = $this->confirm_id; return $hidden_fields; -- cgit v1.2.1 From 74879efcb5c8af253c1d4bdbe97c8065681a1778 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 14:50:40 +0000 Subject: Sort private messages by message time and not message id. (Bug #50015) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10035 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewfolder.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index f947518ba8..11e7f5e7e8 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -386,12 +386,12 @@ function get_pm_from($folder_id, $folder, $user_id) if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { $sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('t' => 'p.msg_id', 's' => 'p.message_subject'); + $sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); } else { $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.msg_id', 's' => 'p.message_subject'); + $sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); } $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; @@ -462,16 +462,26 @@ function get_pm_from($folder_id, $folder, $user_id) } // Select the sort order - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); + $directioin = ($sort_dir == 'd') ? 'ASC' : 'DESC'; $sql_start = max(0, $pm_count - $sql_limit - $start); } else { // Select the sort order - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; $sql_start = $start; } + // Sql sort order + if (is_array($sort_by_sql[$sort_key])) + { + $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; + } + else + { + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; + } + $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u WHERE t.user_id = $user_id -- cgit v1.2.1 From edc5061f1df0fd3ce6f307b91f309a52e037cf73 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 14:53:25 +0000 Subject: Check for valid $template_path in includes/template.php - Bug #50055 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10036 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index fece30e4cd..80434aca4c 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -94,6 +94,12 @@ class template { global $phpbb_root_path, $user; + // Make sure $template_path has no ending slash + if (substr($template_path, -1) == '/') + { + $template_path = substr($template_path, 0, -1); + } + $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; $user->theme['template_storedb'] = false; -- cgit v1.2.1 From 3928e6195266f89017158445ae6cc43da43e975e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 15:06:16 +0000 Subject: Fix r10035 [ Sort private messages by message time and not message id. (Bug #50015) ] git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10037 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewfolder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 11e7f5e7e8..43b12a59e6 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -462,7 +462,7 @@ function get_pm_from($folder_id, $folder, $user_id) } // Select the sort order - $directioin = ($sort_dir == 'd') ? 'ASC' : 'DESC'; + $direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; $sql_start = max(0, $pm_count - $sql_limit - $start); } else -- cgit v1.2.1 From 5d2e4e88ab3266b44101714a101d337e0053361e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Aug 2009 09:44:55 +0000 Subject: Allow "0" as censor word and replacement. Only obtain word censor list if text is not empty. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10039 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_words.php | 12 +++++++----- phpBB/includes/functions_content.php | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_words.php b/phpBB/includes/acp/acp_words.php index 596c2fc743..1cb9545967 100644 --- a/phpBB/includes/acp/acp_words.php +++ b/phpBB/includes/acp/acp_words.php @@ -23,7 +23,7 @@ if (!defined('IN_PHPBB')) class acp_words { var $u_action; - + function main($id, $mode) { global $db, $user, $auth, $template, $cache; @@ -47,8 +47,9 @@ class acp_words switch ($action) { case 'edit': + $word_id = request_var('id', 0); - + if (!$word_id) { trigger_error($user->lang['NO_WORD'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -73,7 +74,7 @@ class acp_words 'REPLACEMENT' => (isset($word_info['replacement'])) ? $word_info['replacement'] : '', 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); - + return; break; @@ -84,11 +85,12 @@ class acp_words { trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); } + $word_id = request_var('id', 0); $word = utf8_normalize_nfc(request_var('word', '', true)); $replacement = utf8_normalize_nfc(request_var('replacement', '', true)); - - if (!$word || !$replacement) + + if ($word === '' || $replacement === '') { trigger_error($user->lang['ENTER_WORD'] . adm_back_link($this->u_action), E_USER_WARNING); } diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 7a30f0069e..c265d0ae41 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -685,6 +685,12 @@ function censor_text($text) { static $censors; + // Nothing to do? + if ($text === '') + { + return ''; + } + // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once if (!isset($censors) || !is_array($censors)) { -- cgit v1.2.1 From a3c00e88d919a7b352635d869d068e163288b143 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Aug 2009 10:46:58 +0000 Subject: Use comparison instead of arithmetic. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10040 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 2f385ff5ba..328c4b1274 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -168,7 +168,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } // Count the difference of real to public topics, so we can display an information to moderators - $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] - $row['forum_topics'])) ? $forum_id : 0; + $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0; $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics']; // Display active topics from this forum? -- cgit v1.2.1 From 69aa05376bd6cd04e23b6edcfe0d44e9e5f5f7e2 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Fri, 21 Aug 2009 21:47:19 +0000 Subject: - replaced the drop down menu log filter thing with log searching git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10041 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 88 +++----------------------------------- phpBB/includes/db/dbal.php | 4 +- phpBB/includes/functions_admin.php | 42 ++++++++++++++---- phpBB/includes/mcp/mcp_logs.php | 58 +++---------------------- phpBB/includes/mcp/mcp_notes.php | 26 +++-------- phpBB/includes/utf/utf_tools.php | 47 ++++++++++++++++++++ 6 files changed, 98 insertions(+), 167 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 861df90777..35f2a3bf6b 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -105,87 +105,8 @@ class acp_logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $log_operation = request_var('log_operation', ''); - $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; - $s_lang_keys = ''; - - switch ($mode) - { - case 'admin': - $log_type = LOG_ADMIN; - $sql_forum = ''; - break; - - case 'mod': - $log_type = LOG_MOD; - - if ($topic_id) - { - $sql_forum = 'AND topic_id = ' . intval($topic_id); - } - else if (is_array($forum_id)) - { - $sql_forum = 'AND ' . $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - } - else - { - $sql_forum = ($forum_id) ? 'AND forum_id = ' . intval($forum_id) : ''; - } - break; - - case 'user': - $log_type = LOG_USERS; - $sql_forum = 'AND reportee_id = ' . (int) $user_id; - break; - - case 'users': - $log_type = LOG_USERS; - $sql_forum = ''; - break; - - case 'critical': - $log_type = LOG_CRITICAL; - $sql_forum = ''; - break; - - default: - return; - } - - $sql = "SELECT DISTINCT log_operation - FROM " . LOG_TABLE . " - WHERE log_type = $log_type - " . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . - $sql_forum; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($row['log_operation'])) - { - continue; - } - - $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - - if (isset($user->lang[$row['log_operation']])) - { - $text = htmlspecialchars(strip_tags(str_replace('
', ' ', $user->lang[$row['log_operation']])), ENT_COMPAT, 'UTF-8'); - - // Fill in sprintf placeholders with translated placeholder text - if (substr_count($text, '%')) - { - $text = vsprintf($text, array_fill(0, substr_count($text, '%'), $user->lang['LOGS_PLACEHOLDER'])); - } - } - else - { - $text = ucfirst(str_replace('_', ' ', strtolower($row['log_operation']))); - } - - $s_lang_keys .= ''; - } - $db->sql_freeresult($result); + $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); + $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; $l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS']; $l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN']; @@ -206,7 +127,7 @@ class acp_logs // Grab log data $log_data = array(); $log_count = 0; - view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $log_operation); + view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords); $template->assign_vars(array( 'L_TITLE' => $l_title, @@ -214,13 +135,14 @@ class acp_logs 'U_ACTION' => $this->u_action, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param", $log_count, $config['topics_per_page'], $start, true), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_LANG_KEYS' => $s_lang_keys, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), + 'S_KEYWORDS' => $keywords, ) ); diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 5418ed394b..a962696bb8 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -235,8 +235,8 @@ class dbal */ function sql_like_expression($expression) { - $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); + $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); + $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 2f8670a147..d84216701a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,13 +338,12 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forum exists + // Check if source forums exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -358,7 +357,6 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); - $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; @@ -2497,7 +2495,7 @@ function cache_moderators() /** * View log */ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $log_operation = '') +function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') { global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; @@ -2548,12 +2546,40 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id return; } + $keywords = preg_split('#[\s+\-|*()]+#u', utf8_strtolower(preg_quote($keywords, '#')), 0, PREG_SPLIT_NO_EMPTY); + $sql_keywords = ''; + + if (!empty($keywords)) + { + $keywords_pattern = '#' . implode('|', $keywords) . '#ui'; + for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) + { + $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); + } + + $operations = array(); + foreach ($user->lang as $key=>$value) + { + if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) + { + $operations[] = $key; + } + } + + $sql_keywords = 'AND ('; + if (!empty($operations)) + { + $sql_keywords.= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + } + $sql_keywords.= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + } + $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . - (!empty($log_operation) ? " AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " + $sql_keywords $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); @@ -2718,8 +2744,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql = 'SELECT COUNT(l.log_id) AS total_entries FROM ' . LOG_TABLE . " l WHERE l.log_type = $log_type - AND l.log_time >= $limit_days " . - (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + AND l.log_time >= $limit_days + $sql_keywords $sql_forum"; $result = $db->sql_query($sql); $log_count = (int) $db->sql_fetchfield('total_entries'); diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index a73227f158..11b5f23c12 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -164,67 +164,18 @@ class mcp_logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $log_operation = request_var('log_operation', ''); - $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; - $s_lang_keys = ''; - - if ($topic_id) - { - $sql_forum = 'AND topic_id = ' . intval($topic_id); - } - else if (is_array($forum_id)) - { - $sql_forum = 'AND ' . $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - } - else - { - $sql_forum = ($forum_id) ? 'AND forum_id = ' . intval($forum_id) : ''; - } - - $sql = "SELECT DISTINCT log_operation - FROM " . LOG_TABLE . ' - WHERE log_type = ' . LOG_MOD . ' - ' . (($limit_days) ? "AND log_time >= $sql_where " : ' ') . - $sql_forum; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($row['log_operation'])) - { - continue; - } - - $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - - if (isset($user->lang[$row['log_operation']])) - { - $text = htmlspecialchars(strip_tags(str_replace('
', ' ', $user->lang[$row['log_operation']])), ENT_COMPAT, 'UTF-8'); - - // Fill in sprintf placeholders with translated placeholder text - if (substr_count($text, '%')) - { - $text = vsprintf($text, array_fill(0, substr_count($text, '%'), $user->lang['LOGS_PLACEHOLDER'])); - } - } - else - { - $text = ucfirst(str_replace('_', ' ', strtolower($row['log_operation']))); - } - - $s_lang_keys .= ''; - } - $db->sql_freeresult($result); + $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); + $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; // Grab log data $log_data = array(); $log_count = 0; - view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $log_operation); + view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); $template->assign_vars(array( 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param", $log_count, $config['topics_per_page'], $start), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), 'L_TITLE' => $user->lang['MCP_LOGS'], @@ -235,6 +186,7 @@ class mcp_logs 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LANG_KEYS' => $s_lang_keys, 'S_LOGS' => ($log_count > 0), + 'S_KEYWORDS' => $keywords, ) ); diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index bc4c1df42f..7706ea6a99 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -193,29 +193,12 @@ class mcp_notes $sql_where = ($st) ? (time() - ($st * 86400)) : 0; $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); - $log_operation = request_var('log_operation', ''); - $log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : ''; - $s_lang_keys = ''; - - $sql = "SELECT DISTINCT log_operation - FROM " . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . - (($limit_days) ? " AND log_time >= $sql_where" : ''); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (empty($row['log_operation'])) - { - continue; - } - $selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : ''; - $s_lang_keys .= ''; - } - $db->sql_freeresult($result); + $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); + $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; $log_data = array(); $log_count = 0; - view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $log_operation); + view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords); if ($log_count) { @@ -240,11 +223,12 @@ class mcp_notes 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LANG_KEYS' => $s_lang_keys, + 'S_KEYWORDS' => $keywords, 'L_TITLE' => $user->lang['MCP_NOTES_USER'], 'PAGE_NUMBER' => on_page($log_count, $config['posts_per_page'], $start), - 'PAGINATION' => generate_pagination($this->u_action . "&st=$st&sk=$sk&sd=$sd$log_operation_param", $log_count, $config['posts_per_page'], $start), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count), 'RANK_TITLE' => $rank_title, diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 9ee87a5425..6f3ac93305 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1945,4 +1945,51 @@ function utf8_basename($filename) return $filename; } +/** +* UTF8-safe str_replace() function +* +* @param string $search The value to search for +* @param string $replace The replacement string +* @param string $subject The target string +* @return string The resultant string +*/ +function utf8_str_replace($search, $replace, $subject) +{ + if (!is_array($search)) + { + $search = array($search); + if (is_array($replace)) + { + $replace = (string) $replace; + trigger_error('Array to string conversion', E_USER_NOTICE); + } + } + + $length = sizeof($search); + + if (!is_array($replace)) + { + $replace = array_fill(0, $length, $replace); + } + else + { + $replace = array_pad($replace, $length, ''); + } + + for ($i = 0; $i < $length; $i++) + { + $search_length = utf8_strlen($search[$i]); + $replace_length = utf8_strlen($replace[$i]); + + $offset = 0; + while (($start = utf8_strpos($subject, $search[$i], $offset)) !== false) + { + $subject = utf8_substr($subject, 0, $start) . $replace[$i] . utf8_substr($subject, $start + $search_length); + $offset = $start + $replace_length; + } + } + + return $subject; +} + ?> \ No newline at end of file -- cgit v1.2.1 From 70c4e48b3973df360ec075b89011cb2841c1abb7 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 22 Aug 2009 02:56:05 +0000 Subject: - accidentally undid changes introduced in r9979 - removed a few lines from the old log filtering system git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10042 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_logs.php | 1 - phpBB/includes/functions_admin.php | 4 +++- phpBB/includes/mcp/mcp_logs.php | 1 - phpBB/includes/mcp/mcp_notes.php | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 35f2a3bf6b..0f4f78fcdd 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -140,7 +140,6 @@ class acp_logs 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, - 'S_LANG_KEYS' => $s_lang_keys, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), 'S_KEYWORDS' => $keywords, ) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d84216701a..a021717f57 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,12 +338,13 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forums exists + // Check if source forum exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -357,6 +358,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); + $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index 11b5f23c12..782fba7a50 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -184,7 +184,6 @@ class mcp_logs 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_LANG_KEYS' => $s_lang_keys, 'S_LOGS' => ($log_count > 0), 'S_KEYWORDS' => $keywords, ) diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 7706ea6a99..757860e1af 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -222,7 +222,6 @@ class mcp_notes 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_LANG_KEYS' => $s_lang_keys, 'S_KEYWORDS' => $keywords, 'L_TITLE' => $user->lang['MCP_NOTES_USER'], -- cgit v1.2.1 From fffb25ace4893498b6f6fc87c51ec58341828cd9 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sun, 23 Aug 2009 11:12:22 +0000 Subject: More unread posts search adjustment. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10045 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 108 +++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 50 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6750772ebb..820a03fe64 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1649,11 +1649,12 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement +* @param string $sql_limit Limits the size of unread topics list * * @return array[int][int] Topic ids as keys, mark_time of topic as value * @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '') +function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = 1001) { global $config, $db, $user; @@ -1667,32 +1668,18 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') if ($config['load_db_lastread'] && $user->data['is_registered']) { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - // Get list of the unread topics - on topics tracking as the first step $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id - AND t.topic_last_post_time >= tt.mark_time AND tt.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { - if ($row['topic_last_post_time'] == $row['mark_time']) + if ($row['topic_last_post_time'] <= $row['mark_time']) { // Check if there're read topics for the forums having unread ones $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; @@ -1704,46 +1691,67 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } $db->sql_freeresult($result); - // Get the full list of the tracked topics + // Get the full list of the tracked topics and unread topics count $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + $unread_list_count = sizeof($unread_topics_list); + + if ($unread_list_count < $sql_limit) + { + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); + // Refresh the full list of the tracked topics and unread topics count + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + $unread_list_count = sizeof($unread_topics_list); - // Refresh the full list of the tracked topics - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + if ($unread_list_count < $sql_limit) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query_limit($sql, 1000); + while ($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } } - $db->sql_freeresult($result); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { -- cgit v1.2.1 From 03568fd176501c6a6c629590ab701eadef5841aa Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 24 Aug 2009 15:12:40 +0000 Subject: Add INC (working name) to template syntax git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10051 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 1d3a4d74f8..23b09a87f7 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -191,6 +191,10 @@ class template_compile $compile_blocks[] = 'compile_tag_define($block_val[2], false) . ' ?>'; break; + case 'INC': + $compile_blocks[] = 'compile_tag_counter($block_val[2], true) . ' ?>'; + break; + case 'INCLUDE': $temp = array_shift($include_blocks); @@ -626,6 +630,22 @@ class template_compile return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; } + + /** + * Compile INC tags + * @access private + */ + function compile_tag_counter($tag_args) + { + preg_match('#^\$(?=[A-Z])([A-Z0-9_\-]*)$#', $tag_args, $match); + if (empty($match[1])) + { + return ''; + } + + return 'echo $this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[1] . '\']++'; + } + /** * Compile INCLUDE tag * @access private -- cgit v1.2.1 From 19bae65f4c79c7f50d71fd57bfff6ff1033ed84b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 09:04:38 +0000 Subject: Fix possible wrong encodings in email template files in messenger. Related to bug #46725 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10052 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 847b2e0c46..0fcf33f999 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -268,6 +268,9 @@ class messenger // Parse message through template $this->msg = trim($this->tpl_obj->assign_display('body')); + // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding + $this->msg = str_replace("\r\n", "\n", $this->msg); + // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable $drop_header = ''; -- cgit v1.2.1 From 17f40511bf4df9dd46cd13cbd2c7802c49575783 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 09:07:26 +0000 Subject: Make sure only logs for existing users are displayed and user-specific logs removed on user deletion. (Bug #49855) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10053 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 3 ++- phpBB/includes/functions_user.php | 11 +++++++++++ phpBB/includes/mcp/mcp_queue.php | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a021717f57..205d7046c7 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2744,8 +2744,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id } $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . LOG_TABLE . " l + FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u WHERE l.log_type = $log_type + AND l.user_id = u.user_id AND l.log_time >= $limit_days $sql_keywords $sql_forum"; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c562ac666f..cb3306745e 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -538,6 +538,17 @@ function user_delete($mode, $user_id, $post_username = false) $cache->destroy('sql', MODERATOR_CACHE_TABLE); + // Delete user log entries about this user + $sql = 'DELETE FROM ' . LOG_TABLE . ' + WHERE reportee_id = ' . $user_id; + $db->sql_query($sql); + + // Change user_id to anonymous for this users triggered events + $sql = 'UPDATE ' . LOG_TABLE . ' + SET user_id = ' . ANONYMOUS . ' + WHERE user_id = ' . $user_id; + $db->sql_query($sql); + // Delete the user_id from the zebra table $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $user_id . ' diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index f72007acf5..3783aadab5 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -556,6 +556,7 @@ function approve_post($post_id_list, $id, $mode) $post_approve_sql[] = $post_id; } + $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) { @@ -834,7 +835,7 @@ function disapprove_post($post_id_list, $id, $mode) 'post_subject' => $post_info[$post_id]['post_subject'], 'forum_id' => $post_info[$post_id]['forum_id'], 'topic_id' => $post_info[$post_id]['topic_id'], - ); + ); } } -- cgit v1.2.1 From b47b35a07d47435ecb35aa386783c42721bb4764 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 09:48:44 +0000 Subject: This is an enhancement for revision r10051 (INC template variable) Within the mentioned revision INC was only able to be applied to defined template variables. I extended it now to work on all supported variables (template vars, defines, loops, defines in loops) I also added a DEC template variable to logically complete this. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10054 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 23b09a87f7..f22a48bddb 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -192,9 +192,13 @@ class template_compile break; case 'INC': - $compile_blocks[] = 'compile_tag_counter($block_val[2], true) . ' ?>'; + $compile_blocks[] = 'compile_tag_counter($block_val[2], '++') . ' ?>'; break; - + + case 'DEC': + $compile_blocks[] = 'compile_tag_counter($block_val[2], '--') . ' ?>'; + break; + case 'INCLUDE': $temp = array_shift($include_blocks); @@ -632,20 +636,26 @@ class template_compile /** - * Compile INC tags + * Compile INC/DEC tags + * INC/DEC tags support defined template variables as well as normal template variables * @access private */ - function compile_tag_counter($tag_args) + function compile_tag_counter($tag_args, $operation = '++') { - preg_match('#^\$(?=[A-Z])([A-Z0-9_\-]*)$#', $tag_args, $match); - if (empty($match[1])) + preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Z])([A-Z0-9\-_]+)#s', $tag_args, $varrefs); + + if (empty($varrefs[0])) { return ''; } - - return 'echo $this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[1] . '\']++'; + + // Build token + $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); + + // Increase or decrease token ;) + return "echo {$token}{$operation};"; } - + /** * Compile INCLUDE tag * @access private -- cgit v1.2.1 From 48b54bb29e12ec0dc052a688ccc5c18856675d97 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 10:02:24 +0000 Subject: Adjustement for r10050, related to Bug #50185 Use internal S_TAB_INDEX instead of DEFINE git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10055 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 820a03fe64..79ea8978ee 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4120,6 +4120,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], + 'S_TAB_INDEX' => 1, + 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, -- cgit v1.2.1 From fa754d1576466f7ca8a483e72b5b1e1d47a4b1ad Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 25 Aug 2009 13:52:35 +0000 Subject: One more unread posts search adjustment. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10057 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 79ea8978ee..f5e494ae4c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1649,12 +1649,13 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement -* @param string $sql_limit Limits the size of unread topics list +* @param string $sql_sort ORDER BY SQL sorting statement +* @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query * * @return array[int][int] Topic ids as keys, mark_time of topic as value * @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = 1001) +function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) { global $config, $db, $user; @@ -1663,6 +1664,11 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = $user_id = (int) $user->data['user_id']; } + if (empty($sql_sort)) + { + $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; + } + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); $tracked_forums_list = $mark_time = array(); @@ -1674,7 +1680,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = WHERE t.topic_id = tt.topic_id AND tt.user_id = $user_id $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) @@ -1706,7 +1712,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " AND ft.user_id = $user_id $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); while ($row = $db->sql_fetchrow($result)) @@ -1742,7 +1748,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); while ($row = $db->sql_fetchrow($result)) @@ -1776,9 +1782,9 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; - $result = $db->sql_query_limit($sql, 1000); + $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From f1bd295ce6c92e219d20ac684835cd7aa4ce803b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 27 Aug 2009 09:10:28 +0000 Subject: Change of r10055, which itself was: Adjustement for r10050, related to Bug #50185 Instead of S_TAB_INDEX we now use a method suggested by nickvergessen - we simply DEFINE the tabindex for the captcha depending on where it is included. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10058 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f5e494ae4c..e23278a0f2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4126,8 +4126,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], - 'S_TAB_INDEX' => 1, - 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, -- cgit v1.2.1 From c52f05b3329c9c79ecbc3184bd65cdbe4644ebcd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Aug 2009 09:26:43 +0000 Subject: Fix Bug #49195 - Queries on un-indexed column user_email Added function to generate email-hash. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10060 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/functions.php | 8 ++++++++ phpBB/includes/functions_user.php | 4 ++-- phpBB/includes/ucp/ucp_profile.php | 2 +- phpBB/includes/ucp/ucp_remind.php | 2 +- phpBB/includes/ucp/ucp_resend.php | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 7921b6df67..71720f45b4 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -847,7 +847,7 @@ class acp_users { $sql_ary += array( 'user_email' => $update_email, - 'user_email_hash' => crc32($update_email) . strlen($update_email) + 'user_email_hash' => phpbb_email_hash($update_email), ); add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e23278a0f2..17fb351630 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -551,6 +551,14 @@ function _hash_crypt_private($password, $setting, &$itoa64) return $output; } +/** +* Hash email +*/ +function phpbb_email_hash($email) +{ + return crc32(strtolower($email)) . strlen($email); +} + /** * Global function for chmodding directories and files for internal use * diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index cb3306745e..11b134cd85 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -171,7 +171,7 @@ function user_add($user_row, $cp_data = false) 'user_password' => (isset($user_row['user_password'])) ? $user_row['user_password'] : '', 'user_pass_convert' => 0, 'user_email' => strtolower($user_row['user_email']), - 'user_email_hash' => crc32(strtolower($user_row['user_email'])) . strlen($user_row['user_email']), + 'user_email_hash' => phpbb_email_hash($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type'], ); @@ -1727,7 +1727,7 @@ function validate_email($email, $allowed_email = false) { $sql = 'SELECT user_email_hash FROM ' . USERS_TABLE . " - WHERE user_email_hash = " . (crc32($email) . strlen($email)); + WHERE user_email_hash = " . $db->sql_escape(phpbb_email_hash($email)); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a7785e7163..e24acd89fc 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -110,7 +110,7 @@ class ucp_profile 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'], 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'], 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'], - 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? crc32($data['email']) . strlen($data['email']) : $user->data['user_email_hash'], + 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'], 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0, ); diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index 6325bf89b6..df6733d038 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -38,7 +38,7 @@ class ucp_remind { $sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason FROM ' . USERS_TABLE . " - WHERE user_email = '" . $db->sql_escape($email) . "' + WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php index cad494541b..39e9be24a1 100644 --- a/phpBB/includes/ucp/ucp_resend.php +++ b/phpBB/includes/ucp/ucp_resend.php @@ -45,7 +45,7 @@ class ucp_resend $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " - WHERE user_email = '" . $db->sql_escape($email) . "' + WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); -- cgit v1.2.1 From f26b9e42c0f56a75950283d47f3ab356399f6639 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 28 Aug 2009 11:39:45 +0000 Subject: Send service unavailable response code for E_USER_ERROR git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10061 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 17fb351630..d6ca262ab8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3595,6 +3595,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $db->sql_return_on_error(false); } + // Do not send 200 OK, but service unavailable on errors + header('HTTP/1.1 503 Service Unavailable'); + garbage_collection(); // Try to not call the adm page data... -- cgit v1.2.1 From fd24241044338f9210319398ae10bc6ad02983ea Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 11:15:24 +0000 Subject: Revert INC/DEC feature. It is not consistent with the other template variables - bad idea. ;) We will get to it though... but not now. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10064 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_template.php | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index f22a48bddb..1d3a4d74f8 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -191,14 +191,6 @@ class template_compile $compile_blocks[] = 'compile_tag_define($block_val[2], false) . ' ?>'; break; - case 'INC': - $compile_blocks[] = 'compile_tag_counter($block_val[2], '++') . ' ?>'; - break; - - case 'DEC': - $compile_blocks[] = 'compile_tag_counter($block_val[2], '--') . ' ?>'; - break; - case 'INCLUDE': $temp = array_shift($include_blocks); @@ -634,28 +626,6 @@ class template_compile return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; } - - /** - * Compile INC/DEC tags - * INC/DEC tags support defined template variables as well as normal template variables - * @access private - */ - function compile_tag_counter($tag_args, $operation = '++') - { - preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Z])([A-Z0-9\-_]+)#s', $tag_args, $varrefs); - - if (empty($varrefs[0])) - { - return ''; - } - - // Build token - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); - - // Increase or decrease token ;) - return "echo {$token}{$operation};"; - } - /** * Compile INCLUDE tag * @access private -- cgit v1.2.1 From 5e2e08b05dc11992c3c56c45cc93e6d12ff6ae7d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 17:13:28 +0000 Subject: Simplified login_box() and redirection after login. S_LOGIN_ACTION can now be used on every page. (Bug #50285) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10067 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d6ca262ab8..c6a6d354ce 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2978,28 +2978,18 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa } } - if (!$redirect) - { - // We just use what the session code determined... - // If we are not within the admin directory we use the page dir... - $redirect = ''; - - if (!$admin) - { - $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : ''; - } - - $redirect .= $user->page['page_name'] . (($user->page['query_string']) ? '?' . htmlspecialchars($user->page['query_string']) : ''); - } - // Assign credential for username/password pair $credential = ($admin) ? md5(unique_id()) : false; $s_hidden_fields = array( - 'redirect' => $redirect, 'sid' => $user->session_id, ); + if ($redirect) + { + $s_hidden_fields['redirect'] = $redirect; + } + if ($admin) { $s_hidden_fields['credential'] = $credential; @@ -3017,7 +3007,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_LOGIN_ACTION' => (!$admin) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, @@ -4195,6 +4184,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, + 'S_LOGIN_ACTION' => (!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())) : append_sid("index.$phpEx", false, true, $user->session_id) . '&redirect=' . urlencode(str_replace('&', '&', build_url())), + 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, -- cgit v1.2.1 From 3f22f755a3a3da4f711454e25772f13c42014ecc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 17:22:21 +0000 Subject: correct mode is send_statistics, else installs will differ from updates. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10068 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/info/acp_send_statistics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/info/acp_send_statistics.php b/phpBB/includes/acp/info/acp_send_statistics.php index 33e66ecd26..de5dcdb8ad 100644 --- a/phpBB/includes/acp/info/acp_send_statistics.php +++ b/phpBB/includes/acp/info/acp_send_statistics.php @@ -20,7 +20,7 @@ class acp_send_statistics_info 'title' => 'ACP_SEND_STATISTICS', 'version' => '1.0.0', 'modes' => array( - 'questionnaire' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), + 'send_statistics' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), ), ); } -- cgit v1.2.1 From bf1621c05dc8ea61dfeb3bfd6003640232ab0b3a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 17:50:11 +0000 Subject: Style authors are now able to define the default submit button used for form submission on ENTER keypress on forms using more than one. Prosilver uses this for the posting page(s) and registration screen. (we further test this at phpbb.com) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10069 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_compose.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 2f7c289653..1d428ce92e 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1163,8 +1163,14 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove global $refresh, $submit, $preview; - $refresh = $preview = true; + $refresh = true; $submit = false; + + // Preview is only true if there was also a message entered + if (request_var('message', '')) + { + $preview = true; + } } // Add User/Group [TO] -- cgit v1.2.1 From c492016ace472b5a8e432fbf2bf8f391d690b642 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 31 Aug 2009 09:31:30 +0000 Subject: Addition to r10060: Add function documentation. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10071 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c6a6d354ce..6d67f87096 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -552,7 +552,11 @@ function _hash_crypt_private($password, $setting, &$itoa64) } /** -* Hash email +* Hashes an email address to a big integer +* +* @param string $email Email address +* +* @return string Big Integer */ function phpbb_email_hash($email) { -- cgit v1.2.1 From bef4eb231fdd5184e2895bb8fbfdb43c129c7768 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Aug 2009 11:18:06 +0000 Subject: Redirect to group list if confirm box canceled - Bug #50105 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10073 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_groups.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 8aba34c733..ea57246527 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -966,6 +966,9 @@ class ucp_groups ); } + // redirect to last screen + redirect($this->u_action . '&action=list&g=' . $group_id); + break; case 'deleteusers': @@ -1012,6 +1015,9 @@ class ucp_groups ); } + // redirect to last screen + redirect($this->u_action . '&action=list&g=' . $group_id); + break; case 'addusers': -- cgit v1.2.1 From fe6cb1489c4517de0f9902dabdad9bb870a67521 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Aug 2009 11:25:28 +0000 Subject: Fix wrong error message for non-writable template file in acp_styles.php - Bug #50045 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10074 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_styles.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 166ad11d3e..fbf3eadcb2 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -747,7 +747,8 @@ parse_css_file = {PARSE_CSS_FILE} { if (!($fp = @fopen($file, 'wb'))) { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); + // File exists and is writeable, but still not able to be written to + trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); } fwrite($fp, $template_data); fclose($fp); -- cgit v1.2.1 From 58b8e85c3d6ce59c0b7dbac854d71dd6e993996e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Aug 2009 12:07:18 +0000 Subject: correct method comment git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10075 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/search/fulltext_mysql.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index f9efa2bcb5..d1c1ff00d1 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -508,10 +508,23 @@ class fulltext_mysql extends search_backend /** * Performs a search on an author's posts without caring about message contents. Depends on display specific params * - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return total number of results + * @param string $type contains either posts or topics depending on what should be searched for + * @param boolean $firstpost_only if true, only topic starting posts will be considered + * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query + * @param string $sort_key is the key of $sort_by_sql for the selected sorting + * @param string $sort_dir is either a or d representing ASC and DESC + * @param string $sort_days specifies the maximum amount of days a post may be old + * @param array $ex_fid_ary specifies an array of forum ids which should not be searched + * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched + * @param array $author_ary an array of author ids + * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match + * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered + * @param int $start indicates the first index of the page + * @param int $per_page number of ids each page is supposed to contain + * @return boolean|int total number of results + * + * @access public */ function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { -- cgit v1.2.1 From d7925595dc46c1d913dd722b2121d4552c20cb47 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 31 Aug 2009 13:50:40 +0000 Subject: Fix Bug #50035 - Fix handling of bookmarks and subscriptions on "split topcis", "merge topics" and "merge posts" Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10079 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_forum.php | 3 ++ phpBB/includes/mcp/mcp_topic.php | 87 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index b70601b479..acb7aa4ac0 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -416,11 +416,14 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) // If the topic no longer exist, we will update the topic watch table. // To not let it error out on users watching both topics, we just return on an error... + // Same for Bookmarks $db->sql_return_on_error(true); $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); + $db->sql_query('UPDATE ' . BOOKMARKS_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); $db->sql_return_on_error(false); $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); + $db->sql_query('DELETE FROM ' . BOOKMARKS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); // Link to the new topic $return_link .= (($return_link) ? '

' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 576d20b466..cdb4cac7d6 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -503,6 +503,45 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) // Update forum statistics set_config_count('num_topics', 1, true); + // Add new topic to bookmarks + $bookmarks = array(); + $sql = 'SELECT user_id + FROM ' . BOOKMARKS_TABLE . ' + WHERE topic_id = ' . $topic_id; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $bookmarks[] = array( + 'user_id' => (int) $row['user_id'], + 'topic_id' => $to_topic_id, + ); + } + $db->sql_freeresult($result); + if (sizeof($bookmarks)) + { + $db->sql_multi_insert(BOOKMARKS_TABLE, $bookmarks); + } + + // Add new topic to watch-list + $notifications = array(); + $sql = 'SELECT user_id, notify_status + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . $topic_id; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $notifications[] = array( + 'user_id' => (int) $row['user_id'], + 'topic_id' => $to_topic_id, + 'notify_status' => (int) $row['notify_status'], + ); + } + $db->sql_freeresult($result); + if (sizeof($notifications)) + { + $db->sql_multi_insert(TOPICS_WATCH_TABLE, $notifications); + } + // Link back to both topics $return_link = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); } @@ -596,17 +635,65 @@ function merge_posts($topic_id, $to_topic_id) if ($row) { + // Add new topic to bookmarks + $bookmarks = array(); + $sql = 'SELECT user_id + FROM ' . BOOKMARKS_TABLE . ' + WHERE topic_id = ' . (int) $topic_id; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $bookmarks[] = array( + 'user_id' => (int) $row['user_id'], + 'topic_id' => (int) $to_topic_id, + ); + } + $db->sql_freeresult($result); + if (sizeof($bookmarks)) + { + // To not let it error out on users, who already bookmarked the topic, we just return on an error... + $db->sql_return_on_error(true); + $db->sql_multi_insert(BOOKMARKS_TABLE, $bookmarks); + $db->sql_return_on_error(false); + } + + // Add new topic to notifications + $notifications = array(); + $sql = 'SELECT user_id, notify_status + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . (int) $topic_id; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $notifications[] = array( + 'user_id' => (int) $row['user_id'], + 'topic_id' => (int) $to_topic_id, + 'notify_status' => (int) $row['notify_status'], + ); + } + $db->sql_freeresult($result); + if (sizeof($notifications)) + { + // To not let it error out on users, who already watch the topic, we just return on an error... + $db->sql_return_on_error(true); + $db->sql_multi_insert(TOPICS_WATCH_TABLE, $notifications); + $db->sql_return_on_error(false); + } + $return_link .= sprintf($user->lang['RETURN_TOPIC'], '', ''); } else { // If the topic no longer exist, we will update the topic watch table. // To not let it error out on users watching both topics, we just return on an error... + // Same for bookmarks $db->sql_return_on_error(true); $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id); + $db->sql_query('UPDATE ' . BOOKMARKS_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id); $db->sql_return_on_error(false); $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id); + $db->sql_query('DELETE FROM ' . BOOKMARKS_TABLE . ' WHERE topic_id = ' . (int) $topic_id); } // Link to the new topic -- cgit v1.2.1 From 139f1d35302fc675b5e972e55c62d36cbc42af5c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 31 Aug 2009 14:57:04 +0000 Subject: fix r10076 for #48615 - Ability to specify amount of time user is able to delete his last post in topic. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10080 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 78ba5092a0..9f0bcf210f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -177,6 +177,7 @@ class acp_board 'legend2' => 'POSTING', 'bump_type' => false, 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), + 'delete_time' => array('lang' => 'DELETE_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true), -- cgit v1.2.1 From d65ccbde11efe8dba2b4cdf838903938399cd045 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 11:21:42 +0000 Subject: adjust inactive users list on ACP index to act like the new inactive users list from r9845 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10081 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_main.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 815a55b5a9..cd83c52e01 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -540,6 +540,8 @@ class acp_main if ($auth->acl_get('a_user')) { + $user->add_lang('memberlist'); + $inactive = array(); $inactive_count = 0; @@ -549,13 +551,24 @@ class acp_main { $template->assign_block_vars('inactive', array( 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), + 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), + 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], - 'USERNAME' => $row['username'], - 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) - ); + 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, + 'REMINDED' => $row['user_reminded'], + + 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), + + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), + 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), + 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), + + 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), + 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', + )); } $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); -- cgit v1.2.1 From 714aa8b09a62994ad4777d30064b72c90e84b442 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 11:39:59 +0000 Subject: Only embed cron.php if there is no cron lock present to reduce overhead. (Bug #45725 - Patch by TerryE) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10082 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6d67f87096..f18514096f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4284,7 +4284,26 @@ function page_footer($run_cron = true) ); // Call cron-type script + $call_cron = false; if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) + { + $call_cron = true; + + // Any old lock present? + if (!empty($config['cron_lock'])) + { + $cron_time = explode(' ', $config['cron_lock']); + + // If 1 hour lock is present we do not call cron.php + if ($cron_time[0] + 3600 >= time()) + { + $call_cron = false; + } + } + } + + // Call cron job? + if ($call_cron) { $cron_type = ''; -- cgit v1.2.1 From 604696f9a8abd2c743336e3d20ab85746f094637 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 15:08:04 +0000 Subject: Correctly assign board administrator email for L_CONFIRM_EXPLAIN in captcha plugins. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10085 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../includes/captcha/plugins/captcha_abstract.php | 24 +++++++++++----------- .../captcha/plugins/phpbb_recaptcha_plugin.php | 5 ++++- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index e5a4e299bd..db4b7649c7 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -88,7 +88,7 @@ class phpbb_default_captcha function get_template() { global $config, $user, $template, $phpEx, $phpbb_root_path; - + if ($this->is_solved()) { return false; @@ -96,8 +96,8 @@ class phpbb_default_captcha else { $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; - + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + $template->assign_vars(array( 'CONFIRM_IMAGE_LINK' => $link, 'CONFIRM_IMAGE' => '', @@ -118,7 +118,7 @@ class phpbb_default_captcha global $config, $user, $template, $phpbb_admin_path, $phpEx; $variables = ''; - + if (is_array($this->captcha_vars)) { foreach ($this->captcha_vars as $captcha_var => $template_var) @@ -192,7 +192,7 @@ class phpbb_default_captcha function validate() { global $config, $db, $user; - + $error = ''; if (!$this->confirm_id) { @@ -264,7 +264,7 @@ class phpbb_default_captcha 'code' => (string) $this->code, 'seed' => (int) $this->seed)) . ' WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } @@ -285,13 +285,13 @@ class phpbb_default_captcha $sql = 'UPDATE ' . CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( 'code' => (string) $this->code, 'seed' => (int) $this->seed)) . ' - , attempts = attempts + 1 + , attempts = attempts + 1 WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' + confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; $db->sql_query($sql); } - + /** * Look up everything we need for painting&checking. */ @@ -352,7 +352,7 @@ class phpbb_default_captcha // we leave the class usable by generating a new question $this->generate_code(); } - + function is_solved() { if (request_var('confirm_code', false) && $this->solved === 0) @@ -361,7 +361,7 @@ class phpbb_default_captcha } return (bool) $this->solved; } - + /** * API function */ @@ -369,7 +369,7 @@ class phpbb_default_captcha { return false; } - + } ?> \ No newline at end of file diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 89d44826d8..2d37b13a4f 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,7 +54,7 @@ class phpbb_recaptcha extends phpbb_default_captcha $user->add_lang('captcha_recaptcha'); return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey'])); } - + /** * API function */ @@ -143,6 +143,8 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '', ''); + $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', @@ -150,6 +152,7 @@ class phpbb_recaptcha extends phpbb_default_captcha 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), 'S_CONFIRM_CODE' => true, 'S_TYPE' => $this->type, + 'L_CONFIRM_EXPLAIN' => $explain, )); return 'captcha_recaptcha.html'; -- cgit v1.2.1 From 6134b641e395f1abd0a4fc71c50470ab93dea07e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 1 Sep 2009 18:37:51 +0000 Subject: Save some calls here, since page_footer(true) gets called quite often. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10087 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f18514096f..96ecf739ed 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4288,6 +4288,7 @@ function page_footer($run_cron = true) if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) { $call_cron = true; + $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); // Any old lock present? if (!empty($config['cron_lock'])) @@ -4295,7 +4296,7 @@ function page_footer($run_cron = true) $cron_time = explode(' ', $config['cron_lock']); // If 1 hour lock is present we do not call cron.php - if ($cron_time[0] + 3600 >= time()) + if ($cron_time[0] + 3600 >= $time_now) { $call_cron = false; } @@ -4307,31 +4308,31 @@ function page_footer($run_cron = true) { $cron_type = ''; - if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) + if ($time_now - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) { // Process email queue $cron_type = 'queue'; } - else if (method_exists($cache, 'tidy') && time() - $config['cache_gc'] > $config['cache_last_gc']) + else if (method_exists($cache, 'tidy') && $time_now - $config['cache_gc'] > $config['cache_last_gc']) { // Tidy the cache $cron_type = 'tidy_cache'; } - else if ($config['warnings_expire_days'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) + else if ($config['warnings_expire_days'] && ($time_now - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } - else if (time() - $config['database_gc'] > $config['database_last_gc']) + else if ($time_now - $config['database_gc'] > $config['database_last_gc']) { // Tidy the database $cron_type = 'tidy_database'; } - else if (time() - $config['search_gc'] > $config['search_last_gc']) + else if ($time_now - $config['search_gc'] > $config['search_last_gc']) { // Tidy the search $cron_type = 'tidy_search'; } - else if (time() - $config['session_gc'] > $config['session_last_gc']) + else if ($time_now - $config['session_gc'] > $config['session_last_gc']) { $cron_type = 'tidy_sessions'; } -- cgit v1.2.1 From 73baf42558b70acf7b2e194a84172778374a1c6e Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Wed, 2 Sep 2009 05:12:23 +0000 Subject: Fixed bugs #43145, #44375, #44415 and #43045 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10088 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_ban.php | 6 ++++-- phpBB/includes/acp/acp_icons.php | 23 +++++++++++++++++++++++ phpBB/includes/acp/acp_users.php | 25 +++++++++++++++++++++++++ phpBB/includes/functions.php | 2 +- 4 files changed, 53 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php index 542ed47f3b..3198376584 100644 --- a/phpBB/includes/acp/acp_ban.php +++ b/phpBB/includes/acp/acp_ban.php @@ -156,7 +156,8 @@ class acp_ban FROM ' . BANLIST_TABLE . ' WHERE (ban_end >= ' . time() . " OR ban_end = 0) - AND ban_ip <> ''"; + AND ban_ip <> '' + ORDER BY ban_ip"; break; case 'email': @@ -168,7 +169,8 @@ class acp_ban FROM ' . BANLIST_TABLE . ' WHERE (ban_end >= ' . time() . " OR ban_end = 0) - AND ban_email <> ''"; + AND ban_email <> '' + ORDER BY ban_email"; break; } $result = $db->sql_query($sql); diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index fa1e324cc6..8213c55ccb 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -89,6 +89,18 @@ class acp_icons continue; } + // adjust the width and height to be lower than 128px while perserving the aspect ratio + if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) + { + $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); + $img_size[0] = 127; + } + else if ($img_size[1] > 127) + { + $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); + $img_size[1] = 127; + } + $_images[$path . $img]['file'] = $path . $img; $_images[$path . $img]['width'] = $img_size[0]; $_images[$path . $img]['height'] = $img_size[1]; @@ -388,6 +400,17 @@ class acp_icons $image_height[$image] = $img_size[1]; } + if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image]) + { + $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image])); + $image_width[$image] = 127; + } + else if ($image_height[$image] > 127) + { + $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image])); + $image_height[$image] = 127; + } + $img_sql = array( $fields . '_url' => $image, $fields . '_width' => $image_width[$image], diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 71720f45b4..98a0cfebd5 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -385,6 +385,31 @@ class acp_users user_active_flip('flip', $user_id); + if ($user_row['user_type'] == USER_INACTIVE) + { + if ($config['require_activation'] == USER_ACTIVATION_ADMIN) + { + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + + $messenger = new messenger(false); + + $messenger->template('admin_welcome_activated', $user_row['user_lang']); + + $messenger->to($user_row['user_email'], $user_row['username']); + + $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); + $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); + $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); + $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); + + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($user_row['username'])) + ); + + $messenger->send(NOTIFY_EMAIL); + } + } + $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 96ecf739ed..8957633ec7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3006,7 +3006,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', - 'U_RESEND_ACTIVATION' => ($config['require_activation'] != USER_ACTIVATION_NONE && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', + 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), -- cgit v1.2.1 From 46e66c04011288a79ffb6232e4ccecb20240f2ce Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 3 Sep 2009 12:45:46 +0000 Subject: Some cleanup. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10091 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 175 ++++++++++++--------- 1 file changed, 97 insertions(+), 78 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 511706bb93..d71a781ae7 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -17,12 +17,11 @@ if (!defined('IN_PHPBB')) } global $table_prefix; + define('CAPTCHA_QUESTIONS_TABLE', $table_prefix . 'captcha_questions'); define('CAPTCHA_ANSWERS_TABLE', $table_prefix . 'captcha_answers'); define('CAPTCHA_QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm'); - - /** * And now to something completely different. Let's make a captcha without extending the abstract class. * QA CAPTCHA sample implementation @@ -51,27 +50,37 @@ class phpbb_captcha_qa // load our language file $user->add_lang('captcha_qa'); + // read input $this->confirm_id = request_var('qa_confirm_id', ''); $this->answer = request_var('qa_answer', '', true); $this->type = (int) $type; $this->question_lang = $user->data['user_lang']; + // we need all defined questions - shouldn't be too many, so we can just grab them // try the user's lang first - $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\''; + $sql = 'SELECT question_id + FROM ' . CAPTCHA_QUESTIONS_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql, 3600); + while ($row = $db->sql_fetchrow($result)) { $this->question_ids[$row['question_id']] = $row['question_id']; } $db->sql_freeresult($result); + // fallback to the board default lang if (!sizeof($this->question_ids)) { $this->question_lang = $config['default_lang']; - $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + + $sql = 'SELECT question_id + FROM ' . CAPTCHA_QUESTIONS_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql, 7200); + while ($row = $db->sql_fetchrow($result)) { $this->question_ids[$row['question_id']] = $row['question_id']; @@ -93,6 +102,7 @@ class phpbb_captcha_qa function &get_instance() { $instance =& new phpbb_captcha_qa(); + return $instance; } @@ -108,31 +118,35 @@ class phpbb_captcha_qa include("$phpbb_root_path/includes/db/db_tools.$phpEx"); } $db_tool = new phpbb_db_tools($db); + return $db_tool->sql_table_exists(CAPTCHA_QUESTIONS_TABLE); } - + /** * API function - for the captcha to be available, it must have installed itself and there has to be at least one question in the board's default lang */ function is_available() { global $config, $db, $phpbb_root_path, $phpEx, $user; - + // load language file for pretty display in the ACP dropdown $user->add_lang('captcha_qa'); - + if (!phpbb_captcha_qa::is_installed()) { return false; } - $sql = 'SELECT COUNT(question_id) as count FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\''; + + $sql = 'SELECT COUNT(question_id) as count + FROM ' . CAPTCHA_QUESTIONS_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); + return ((bool) $row['count']); } - /** * API function */ @@ -141,7 +155,6 @@ class phpbb_captcha_qa return true; } - /** * API function */ @@ -158,7 +171,6 @@ class phpbb_captcha_qa return 'phpbb_captcha_qa'; } - /** * API function - not needed as we don't display an image */ @@ -179,7 +191,7 @@ class phpbb_captcha_qa function get_template() { global $template; - + if ($this->is_solved()) { return false; @@ -218,6 +230,7 @@ class phpbb_captcha_qa $hidden_fields['qa_answer'] = $this->answer; } $hidden_fields['qa_confirm_id'] = $this->confirm_id; + return $hidden_fields; } @@ -230,7 +243,8 @@ class phpbb_captcha_qa $sql = 'SELECT DISTINCT c.session_id FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' c - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) + LEFT JOIN ' . SESSIONS_TABLE . ' s + ON (c.session_id = s.session_id) WHERE s.session_id IS NULL' . ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); $result = $db->sql_query($sql); @@ -238,6 +252,7 @@ class phpbb_captcha_qa if ($row = $db->sql_fetchrow($result)) { $sql_in = array(); + do { $sql_in[] = (string) $row['session_id']; @@ -274,8 +289,9 @@ class phpbb_captcha_qa include("$phpbb_root_path/includes/db/db_tools.$phpEx"); } $db_tool = new phpbb_db_tools($db); + $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE, CAPTCHA_QA_CONFIRM_TABLE); - + $schemas = array( CAPTCHA_QUESTIONS_TABLE => array ( 'COLUMNS' => array( @@ -315,7 +331,7 @@ class phpbb_captcha_qa 'PRIMARY_KEY' => 'confirm_id', ), ); - + foreach($schemas as $table => $schema) { if (!$db_tool->sql_table_exists($table)) @@ -325,15 +341,15 @@ class phpbb_captcha_qa } } - /** * API function - see what has to be done to validate */ function validate() { global $config, $db, $user; - + $error = ''; + if (!$this->confirm_id) { $error = $user->lang['CONFIRM_QUESTION_WRONG']; @@ -356,6 +372,7 @@ class phpbb_captcha_qa // okay, incorrect answer. Let's ask a new question. $this->new_attempt(); $this->solved = false; + return $error; } else @@ -373,17 +390,17 @@ class phpbb_captcha_qa $this->confirm_id = md5(unique_id($user->ip)); $this->question = (int) array_rand($this->question_ids); - + $sql = 'INSERT INTO ' . CAPTCHA_QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $this->confirm_id, - 'session_id' => (string) $user->session_id, - 'lang_iso' => (string) $this->question_lang, - 'confirm_type' => (int) $this->type, - 'question_id' => (int) $this->question, + 'confirm_id' => (string) $this->confirm_id, + 'session_id' => (string) $user->session_id, + 'lang_iso' => (string) $this->question_lang, + 'confirm_type' => (int) $this->type, + 'question_id' => (int) $this->question, )); $db->sql_query($sql); - $this->load_answer(); + $this->load_answer(); } /** @@ -395,14 +412,13 @@ class phpbb_captcha_qa $this->question = (int) array_rand($this->question_ids); $this->solved = 0; - // compute $seed % 0x7fffffff - $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( - 'question' => (int) $this->question,)) . ' - WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' - AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; + $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' + SET question_id = ' . (int) $this->question . " + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); + $this->load_answer(); } @@ -416,15 +432,14 @@ class phpbb_captcha_qa // yah, I would prefer a stronger rand, but this should work $this->question = (int) array_rand($this->question_ids); $this->solved = 0; - // compute $seed % 0x7fffffff - - $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( - 'question_id' => (int) $this->question)) . ', - attempts = attempts + 1 - WHERE - confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\' - AND session_id = \'' . $db->sql_escape($user->session_id) . '\''; + + $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' + SET question_id = ' . (int) $this->question . ", + attempts = attempts + 1 + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); + $this->load_answer(); } @@ -434,7 +449,7 @@ class phpbb_captcha_qa function load_answer() { global $db, $user; - + $sql = 'SELECT con.question_id, attempts, question_text, strict FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id @@ -453,8 +468,10 @@ class phpbb_captcha_qa $this->attempts = $row['attempts']; $this->question_strict = $row['strict']; $this->question_text = $row['question_text']; + return true; } + return false; } @@ -464,23 +481,27 @@ class phpbb_captcha_qa function check_answer() { global $db; - + $answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true)); - + $sql = 'SELECT answer_text - FROM ' . CAPTCHA_ANSWERS_TABLE . ' - WHERE question_id = ' . (int) $this->question; + FROM ' . CAPTCHA_ANSWERS_TABLE . ' + WHERE question_id = ' . (int) $this->question; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $solution = ($this->question_strict) ? $row['answer_text'] : utf8_clean_string($row['answer_text'] ); + $solution = ($this->question_strict) ? $row['answer_text'] : utf8_clean_string($row['answer_text']); + if ($solution === $answer) { $this->solved = true; + break; } } $db->sql_freeresult($result); + return $this->solved; } @@ -531,10 +552,10 @@ class phpbb_captcha_qa { $this->validate(); } + return (bool) $this->solved; } - - + /** * API function - The ACP backend, this marks the end of the easy methods */ @@ -550,6 +571,7 @@ class phpbb_captcha_qa { $this->install(); } + $module->tpl_name = 'captcha_qa_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; @@ -558,14 +580,14 @@ class phpbb_captcha_qa $submit = request_var('submit', false); $question_id = request_var('question_id', 0); $action = request_var('action', ''); - + // we have two pages, so users might want to navigate from one to the other $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_class_name(); - + $template->assign_vars(array( - 'U_ACTION' => $module->u_action, - 'QUESTION_ID' => $question_id , - 'CLASS' => $this->get_class_name(), + 'U_ACTION' => $module->u_action, + 'QUESTION_ID' => $question_id , + 'CLASS' => $this->get_class_name(), )); // show the list? @@ -578,6 +600,7 @@ class phpbb_captcha_qa if (confirm_box(true)) { $this->acp_delete_question($question_id); + trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); } else @@ -600,6 +623,7 @@ class phpbb_captcha_qa $input_lang = request_var('lang_iso', '', true); $input_strict = request_var('strict', false); $langs = $this->get_languages(); + foreach ($langs as $lang => $entry) { $template->assign_block_vars('langs', array( @@ -607,15 +631,17 @@ class phpbb_captcha_qa 'NAME' => $entry['name'], )); } - + $template->assign_vars(array( - 'U_LIST' => $list_url, + 'U_LIST' => $list_url, )); + if ($question_id) { if ($question = $this->acp_get_question_data($question_id)) { $answers = (isset($input_answers[$lang])) ? $input_answers[$lang] : implode("\n", $question['answers']); + $template->assign_vars(array( 'QUESTION_TEXT' => ($input_question) ? $input_question : $question['question_text'], 'LANG_ISO' => ($input_lang) ? $input_lang : $question['lang_iso'], @@ -630,18 +656,18 @@ class phpbb_captcha_qa } else { - $template->assign_vars(array( - 'QUESTION_TEXT' => $input_question, - 'LANG_ISO' => $input_lang, - 'STRICT' => $input_strict, - 'ANSWERS' => $input_answers, + 'QUESTION_TEXT' => $input_question, + 'LANG_ISO' => $input_lang, + 'STRICT' => $input_strict, + 'ANSWERS' => $input_answers, )); } - + if ($submit && check_form_key($form_key)) { $data = $this->acp_get_question_input(); + if (!$this->validate_input($data)) { $template->assign_vars(array( @@ -658,7 +684,7 @@ class phpbb_captcha_qa { $this->acp_add_question($data); } - + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url)); } } @@ -668,7 +694,6 @@ class phpbb_captcha_qa } } } - /** * This handles the list overview @@ -676,7 +701,7 @@ class phpbb_captcha_qa function acp_question_list(&$module) { global $db, $template; - + $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE; $result = $db->sql_query($sql); @@ -688,7 +713,7 @@ class phpbb_captcha_qa while ($row = $db->sql_fetchrow($result)) { $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_class_name() . '&'; - + $template->assign_block_vars('questions', array( 'QUESTION_TEXT' => $row['question_text'], 'QUESTION_ID' => $row['question_id'], @@ -737,8 +762,7 @@ class phpbb_captcha_qa return $question; } } - - + /** * Grab a question from input and bring it into a format the editor understands */ @@ -780,7 +804,7 @@ class phpbb_captcha_qa $cache->destroy('sql', CAPTCHA_QUESTIONS_TABLE); } - + /** * Insert a question. * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data @@ -795,7 +819,7 @@ class phpbb_captcha_qa $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); - $sql = 'INSERT INTO ' . CAPTCHA_QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary); + $sql = 'INSERT INTO ' . CAPTCHA_QUESTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $question_ary); $db->sql_query($sql); $question_id = $db->sql_nextid(); @@ -804,7 +828,7 @@ class phpbb_captcha_qa $cache->destroy('sql', CAPTCHA_QUESTIONS_TABLE); } - + /** * Insert the answers. * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data @@ -812,7 +836,7 @@ class phpbb_captcha_qa function acp_insert_answers($data, $question_id) { global $db, $cache; - + foreach ($data['answers'] as $answer) { $answer_ary = array( @@ -820,13 +844,12 @@ class phpbb_captcha_qa 'answer_text' => $answer, ); - $sql = 'INSERT INTO ' . CAPTCHA_ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary); + $sql = 'INSERT INTO ' . CAPTCHA_ANSWERS_TABLE . ' ' . $db->sql_build_array('INSERT', $answer_ary); $db->sql_query($sql); } $cache->destroy('sql', CAPTCHA_ANSWERS_TABLE); } - /** * Delete a question. @@ -846,8 +869,7 @@ class phpbb_captcha_qa $cache->destroy('sql', $tables); } - - + /** * Check if the entered data can be inserted/used * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data @@ -873,7 +895,7 @@ class phpbb_captcha_qa return true; } - + /** * List the installed language packs */ @@ -881,13 +903,11 @@ class phpbb_captcha_qa { global $db; - $langs = array(); - $sql = 'SELECT * FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); + $langs = array(); while ($row = $db->sql_fetchrow($result)) { $langs[$row['lang_iso']] = array( @@ -899,7 +919,6 @@ class phpbb_captcha_qa return $langs; } - } ?> \ No newline at end of file -- cgit v1.2.1 From 57ed7fd0886f66b9cb465f7acd60be7ee1024fed Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 3 Sep 2009 13:44:16 +0000 Subject: Bug #39505, r9677 - Add integer casting and allow array to be empty. Unset array when no longer needed. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10092 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_privmsgs.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index f6dd29cd99..848218ca83 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1707,8 +1707,8 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $recipients = array(); while ($row = $db->sql_fetchrow($result)) { - $recipients[] = $row['user_id']; - $recipients[] = $row['author_id']; + $recipients[] = (int) $row['user_id']; + $recipients[] = (int) $row['author_id']; } $db->sql_freeresult($result); $recipients = array_unique($recipients); @@ -1719,9 +1719,12 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode WHERE t.msg_id = p.msg_id AND p.author_id = u.user_id AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND ' . $db->sql_in_set('t.author_id', $recipients) . " + AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . " AND t.user_id = $user_id"; + // We no longer need those. + unset($recipients); + if (!$message_row['root_level']) { $sql .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))"; -- cgit v1.2.1 From 19086ba57289be4101131095aeeb615de2bc5639 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 3 Sep 2009 13:56:03 +0000 Subject: Some rewording, some typo fixes, some whitespace changes. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10093 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index d71a781ae7..15ad18ba87 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -95,7 +95,7 @@ class phpbb_captcha_qa $this->select_question(); } } - + /** * API function */ @@ -442,7 +442,7 @@ class phpbb_captcha_qa $this->load_answer(); } - + /** * Look up everything we need and populate the instance variables. */ @@ -812,7 +812,7 @@ class phpbb_captcha_qa function acp_add_question($data) { global $db, $cache; - + $langs = $this->get_languages(); $question_ary = $data; -- cgit v1.2.1 From 4c6360f5b5766900c5d86e5522be1a622f15b345 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 3 Sep 2009 13:59:31 +0000 Subject: #50675 ; also don't reset the captcha on login git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10094 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8957633ec7..69d764b7aa 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2082,7 +2082,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add } $on_page = floor($start_item / $per_page) + 1; - $url_delim = (strpos($base_url, '?') === false) ? '?' : '&'; + $url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); $page_string = ($on_page == 1) ? '1' : '1'; @@ -2949,7 +2949,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); - $captcha->reset(); + // $captcha->reset(); $template->assign_vars(array( 'CAPTCHA_TEMPLATE' => $captcha->get_template(), -- cgit v1.2.1 From 3cfde658f98debff71b29e2dbc2dd1da0c8851d2 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 3 Sep 2009 20:06:57 +0000 Subject: #50485 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10095 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_register.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index babedd4f12..8359c223e0 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -68,6 +68,7 @@ class ucp_register $user->lang_name = $user_lang = $use_lang; $user->lang = array(); + $user->data['user_lang'] = $user->lang_name; $user->add_lang(array('common', 'ucp')); } else -- cgit v1.2.1 From f17e49d11b3d8e7f5dd96afcc54a1cc172087651 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Sep 2009 10:20:47 +0000 Subject: only whitespace changes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10097 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_users.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 98a0cfebd5..1afec6183a 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -551,11 +551,11 @@ class acp_users delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']); - + $lang = 'EMPTIED'; } $db->sql_freeresult($result); - + trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); } else @@ -725,7 +725,7 @@ class acp_users trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; - + case 'leave_nr': if (confirm_box(true)) -- cgit v1.2.1 From c35cdff24195ed38ae6df98a59c27324a5c72d1c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 4 Sep 2009 12:04:30 +0000 Subject: Also update newest user data if someone is creating a founder with user_add(). git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10099 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 11b134cd85..7255d138ab 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -308,7 +308,7 @@ function user_add($user_row, $cp_data = false) } // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent - if ($user_row['user_type'] == USER_NORMAL) + if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) { set_config('newest_user_id', $user_id, true); set_config('newest_username', $user_row['username'], true); -- cgit v1.2.1 From 186abf0798463d2bb9e37117ec7d451efd37b7a1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Sep 2009 14:50:05 +0000 Subject: phpBB updater now skips sole whitespace changes. This reduces the chance of conflicts tremendously. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10102 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/engine.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index eb0dcce395..e9f0e41b75 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -49,6 +49,8 @@ if (!defined('IN_PHPBB')) */ class diff_engine { + var $skip_whitespace_changes = true; + function diff(&$from_lines, &$to_lines, $preserve_cr = true) { // Remove empty lines... @@ -176,6 +178,20 @@ class diff_engine $add[] = $to_lines[$yi++]; } + // Here we are a bit naughty. Naughty Boy... Naughty Boy... + // We check if delete and add is filled and only consist of one item + if ($this->skip_whitespace_changes && sizeof($delete) == 1 && sizeof($add) == 1) + { + // Now we simply trim the string and see if the lines are identical + // If they are identical we do not need to take them into account for the merge (less conflicts in phpBB) + if (trim($delete[0]) === trim($add[0])) + { + // This line ensures the line found here is correctly copied later (remember: we naughty boys like loops) + $xi--; $yi--; $this->xchanged[$xi] = $this->ychanged[$yi] = false; + $delete = $add = array(); + } + } + if ($delete && $add) { $edits[] = new diff_op_change($delete, $add); -- cgit v1.2.1 From 295fb5373ae0a37bfbc36a4461dc3ed2c3cbf9cb Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Fri, 4 Sep 2009 14:53:35 +0000 Subject: - fixed bug #44975 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10103 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 112cf4e2fd..dcfde14159 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1361,6 +1361,20 @@ class session WHERE user_id = ' . (int) $user_id; $db->sql_query($sql); + // Update last visit info first before deleting sessions + $sql = 'SELECT session_time, session_page + FROM ' . SESSIONS_TABLE . ' + WHERE session_user_id = ' . (int) $user_id . ' + ORDER BY session_time DESC'; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_lastvisit = ' . (int) $row['session_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' + WHERE user_id = " . (int) $user_id; + $db->sql_query($sql); + // Let's also clear any current sessions for the specified user_id // If it's the current user then we'll leave this session intact $sql_where = 'session_user_id = ' . (int) $user_id; -- cgit v1.2.1 From 31856352be0f29fd7423cfe87bdfd791b03fb938 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Sep 2009 15:19:26 +0000 Subject: Change version numbers to 3.0.6 and 3.0.6-RC1 for a final internal test run git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10105 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 98abf18b6f..a526b9bf71 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.0.5'); +define('PHPBB_VERSION', '3.0.6-RC1'); // QA-related // define('PHPBB_QA', 1); -- cgit v1.2.1 From 239438a6c9e3404035ab983e806f235f12a937b0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 5 Sep 2009 12:06:12 +0000 Subject: Fix r10041 - Bug #50765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10109 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_logs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index 782fba7a50..429e19b668 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -175,7 +175,7 @@ class mcp_logs $template->assign_vars(array( 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true), 'L_TITLE' => $user->lang['MCP_LOGS'], @@ -192,7 +192,7 @@ class mcp_logs foreach ($log_data as $row) { $data = array(); - + $checks = array('viewtopic', 'viewforum'); foreach ($checks as $check) { -- cgit v1.2.1 From df86a1b27c14f81915d11038072eba2df5ecdd93 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 6 Sep 2009 23:59:35 +0000 Subject: Some smaller changes to r10041. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10112 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 205d7046c7..d42a81fa35 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2517,15 +2517,15 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id if ($topic_id) { - $sql_forum = 'AND l.topic_id = ' . intval($topic_id); + $sql_forum = 'AND l.topic_id = ' . (int) $topic_id; } else if (is_array($forum_id)) { $sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); } - else + else if ($forum_id) { - $sql_forum = ($forum_id) ? 'AND l.forum_id = ' . intval($forum_id) : ''; + $sql_forum = 'AND l.forum_id = ' . (int) $forum_id; } break; @@ -2560,7 +2560,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id } $operations = array(); - foreach ($user->lang as $key=>$value) + foreach ($user->lang as $key => $value) { if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) { @@ -2571,9 +2571,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql_keywords = 'AND ('; if (!empty($operations)) { - $sql_keywords.= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_keywords.= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; } $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour -- cgit v1.2.1 From 1d37a633cdd1047d19d760e637a2d0221daa6264 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 7 Sep 2009 00:38:20 +0000 Subject: Adjustments to r10005: Use request_var() to get cookie data. Some more adjustments to get_unread_topics_list() Related to report: #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10113 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 69d764b7aa..be1208fb2e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1671,10 +1671,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { global $config, $db, $user; - if ($user_id === false) - { - $user_id = (int) $user->data['user_id']; - } + $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; if (empty($sql_sort)) { @@ -1697,14 +1694,16 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { + $topic_id = (int) $row['topic_id']; + if ($row['topic_last_post_time'] <= $row['mark_time']) { // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $read_topics_list[$topic_id] = (int) $row['mark_time']; } else { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $unread_topics_list[$topic_id] = (int) $row['mark_time']; } } $db->sql_freeresult($result); @@ -1729,7 +1728,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $unread_topics_list[(int) $row['topic_id']] = (int) $row['mark_time']; } $db->sql_freeresult($result); @@ -1765,7 +1764,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + $unread_topics_list[(int) $row['topic_id']] = (int) $user->data['user_lastmark']; } $db->sql_freeresult($result); } @@ -1775,9 +1774,9 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { global $tracking_topics; - if (!isset($tracking_topics) || !sizeof($tracking_topics)) + if (empty($tracking_topics)) { - $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = request_var($config['cookie_name'] . '_track', '', false, true); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); } @@ -1787,7 +1786,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' } else { - $user_lastmark = $user->data['user_lastmark']; + $user_lastmark = (int) $user->data['user_lastmark']; } $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time @@ -1795,7 +1794,6 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) @@ -1824,7 +1822,6 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { $unread_topics_list[$topic_id] = $user_lastmark; } - } $db->sql_freeresult($result); } -- cgit v1.2.1 From 58a3d87744d8463664f93d4425d4821d99a6911b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 7 Sep 2009 11:42:30 +0000 Subject: Fix Bug #50845 (missing info icon in subsilver2) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10114 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_topic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index cdb4cac7d6..e73cccce1e 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -301,8 +301,9 @@ function mcp_topic_view($id, $mode, $action) 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED', false, true), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED', false, true), + 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), + 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), + 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", 'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), -- cgit v1.2.1 From 02b2cced5ae562145288a0dbe2bd534bf4f41b7f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 7 Sep 2009 11:57:58 +0000 Subject: beautify q&a captcha a bit (only slightly) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10116 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 88 +++++++++++----------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 15ad18ba87..6f53e8c5ad 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -48,7 +48,7 @@ class phpbb_captcha_qa { global $config, $db, $user; - // load our language file + // load our language file $user->add_lang('captcha_qa'); // read input @@ -62,7 +62,7 @@ class phpbb_captcha_qa // try the user's lang first $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; + WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) @@ -78,7 +78,7 @@ class phpbb_captcha_qa $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql, 7200); while ($row = $db->sql_fetchrow($result)) @@ -139,7 +139,7 @@ class phpbb_captcha_qa $sql = 'SELECT COUNT(question_id) as count FROM ' . CAPTCHA_QUESTIONS_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -283,7 +283,7 @@ class phpbb_captcha_qa function install() { global $db, $phpbb_root_path, $phpEx; - + if (!class_exists('phpbb_db_tools')) { include("$phpbb_root_path/includes/db/db_tools.$phpEx"); @@ -294,41 +294,41 @@ class phpbb_captcha_qa $schemas = array( CAPTCHA_QUESTIONS_TABLE => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', Null, 'auto_increment'), - 'strict' => array('BOOL', 0), - 'lang_id' => array('UINT', 0), - 'lang_iso' => array('VCHAR:30', ''), - 'question_text' => array('TEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'question_id', - 'KEYS' => array( - 'lang_iso' => array('INDEX', 'lang_iso'), - ), + 'COLUMNS' => array( + 'question_id' => array('UINT', Null, 'auto_increment'), + 'strict' => array('BOOL', 0), + 'lang_id' => array('UINT', 0), + 'lang_iso' => array('VCHAR:30', ''), + 'question_text' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'question_id', + 'KEYS' => array( + 'lang_iso' => array('INDEX', 'lang_iso'), + ), ), CAPTCHA_ANSWERS_TABLE => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', 0), - 'answer_text' => array('STEXT_UNI', ''), - ), - 'KEYS' => array( - 'question_id' => array('INDEX', 'question_id'), - ), + 'COLUMNS' => array( + 'question_id' => array('UINT', 0), + 'answer_text' => array('STEXT_UNI', ''), + ), + 'KEYS' => array( + 'question_id' => array('INDEX', 'question_id'), + ), ), CAPTCHA_QA_CONFIRM_TABLE => array ( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'confirm_id' => array('CHAR:32', ''), - 'lang_iso' => array('VCHAR:30', ''), - 'question_id' => array('UINT', 0), - 'attempts' => array('UINT', 0), - 'confirm_type' => array('USINT', 0), - ), - 'KEYS' => array( - 'session_id' => array('INDEX', 'session_id'), - 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), - ), - 'PRIMARY_KEY' => 'confirm_id', + 'COLUMNS' => array( + 'session_id' => array('CHAR:32', ''), + 'confirm_id' => array('CHAR:32', ''), + 'lang_iso' => array('VCHAR:30', ''), + 'question_id' => array('UINT', 0), + 'attempts' => array('UINT', 0), + 'confirm_type' => array('USINT', 0), + ), + 'KEYS' => array( + 'session_id' => array('INDEX', 'session_id'), + 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), + ), + 'PRIMARY_KEY' => 'confirm_id', ), ); @@ -415,7 +415,7 @@ class phpbb_captcha_qa $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . " - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); @@ -436,7 +436,7 @@ class phpbb_captcha_qa $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . ", attempts = attempts + 1 - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' + WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); @@ -451,7 +451,7 @@ class phpbb_captcha_qa global $db, $user; $sql = 'SELECT con.question_id, attempts, question_text, strict - FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes + FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' @@ -520,7 +520,7 @@ class phpbb_captcha_qa } /** - * API function + * API function */ function get_attempt_count() { @@ -528,7 +528,7 @@ class phpbb_captcha_qa } /** - * API function + * API function */ function reset() { @@ -544,7 +544,7 @@ class phpbb_captcha_qa } /** - * API function + * API function */ function is_solved() { @@ -815,7 +815,7 @@ class phpbb_captcha_qa $langs = $this->get_languages(); $question_ary = $data; - + $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); @@ -862,7 +862,7 @@ class phpbb_captcha_qa foreach ($tables as $table) { - $sql = "DELETE FROM $table + $sql = "DELETE FROM $table WHERE question_id = $question_id"; $db->sql_query($sql); } -- cgit v1.2.1 From bb8e42fa5f1c524ec17d20b4925d0f71494f202f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 7 Sep 2009 15:48:15 +0000 Subject: Fix retrieval of unread topics list. The old queries were too heavy, using temporary and filesort and actually only based on topics being retrieved before. Instead now use one query which is also a lot faster and yields the same results. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10118 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 104 +++++++++++-------------------------------- 1 file changed, 25 insertions(+), 79 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index be1208fb2e..3a5a018a86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1683,92 +1683,38 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' if ($config['load_db_lastread'] && $user->data['is_registered']) { - // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt - WHERE t.topic_id = tt.topic_id - AND tt.user_id = $user_id - $sql_extra - $sql_sort"; + // Get list of the unread topics + $sql_array = array( + 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', + + 'FROM' => array(TOPICS_TABLE => 't'), + + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), + 'ON' => 't.topic_id = tt.topic_id AND t.topic_last_post_time > tt.mark_time AND tt.user_id = ' . $user_id, + ), + array( + 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), + 'ON' => 't.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ft.user_id = ' . $user_id, + ), + ), + + 'WHERE' => "((tt.topic_id OR ft.forum_id) + OR t.topic_last_post_time > {$user->data['user_lastmark']}) + $sql_extra + $sql_sort", + ); + + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - - if ($row['topic_last_post_time'] <= $row['mark_time']) - { - // Check if there're read topics for the forums having unread ones - $read_topics_list[$topic_id] = (int) $row['mark_time']; - } - else - { - $unread_topics_list[$topic_id] = (int) $row['mark_time']; - } + $unread_topics_list[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; } $db->sql_freeresult($result); - - // Get the full list of the tracked topics and unread topics count - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - $unread_list_count = sizeof($unread_topics_list); - - if ($unread_list_count < $sql_limit) - { - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[(int) $row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); - - // Refresh the full list of the tracked topics and unread topics count - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - $unread_list_count = sizeof($unread_topics_list); - - if ($unread_list_count < $sql_limit) - { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[(int) $row['topic_id']] = (int) $user->data['user_lastmark']; - } - $db->sql_freeresult($result); - } - } } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { -- cgit v1.2.1 From d85493ab16658387d603ca0d949e65bc3ea1533c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 8 Sep 2009 08:53:01 +0000 Subject: Rename get_unread_topics_list() to get_unread_topics(). Cleanup: Remove some stuff we no longer need. Related to report #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10120 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 30 ++++++++++++++++-------------- phpBB/includes/functions_display.php | 6 +++--- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3a5a018a86..21d4963aa7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1665,22 +1665,21 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query * * @return array[int][int] Topic ids as keys, mark_time of topic as value -* @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) +function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) { global $config, $db, $user; $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; + // Data array we're going to return + $unread_topics = array(); + if (empty($sql_sort)) { $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; } - $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = $mark_time = array(); - if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics @@ -1712,7 +1711,8 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - $unread_topics_list[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; + + $unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; } $db->sql_freeresult($result); } @@ -1750,29 +1750,31 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' if (isset($tracking_topics['t'][$topic_id36])) { - $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - if ($row['topic_last_post_time'] > $last_read[$topic_id]) + $last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; + + if ($row['topic_last_post_time'] > $last_read) { - $unread_topics_list[$topic_id] = $last_read[$topic_id]; + $unread_topics[$topic_id] = $last_read; } } else if (isset($tracking_topics['f'][$forum_id])) { - $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - if ($row['topic_last_post_time'] > $mark_time[$forum_id]) + $mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; + + if ($row['topic_last_post_time'] > $mark_time) { - $unread_topics_list[$topic_id] = $mark_time[$forum_id]; + $unread_topics[$topic_id] = $mark_time; } } else { - $unread_topics_list[$topic_id] = $user_lastmark; + $unread_topics[$topic_id] = $user_lastmark; } } $db->sql_freeresult($result); } - return $unread_topics_list; + return $unread_topics; } /** diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 328c4b1274..5caccc81d9 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -103,12 +103,12 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; - // Check for unread global announcements - // For index page only we do it + // Check for unread global announcements (index page only) $ga_unread = false; if ($root_data['forum_id'] == 0) { - $unread_ga_list = get_unread_topics_list($user->data['user_id'], 'AND t.forum_id = 0'); + $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0'); + if (sizeof($unread_ga_list)) { $ga_unread = true; -- cgit v1.2.1 From 5537393f76cf56d21f39b863425f3ddb5c500808 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 8 Sep 2009 10:36:22 +0000 Subject: Further adjust unread tracking query, should work now for user last mark times less than forum/topic mark times. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10121 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 ++++++++++++++------ phpBB/includes/functions_display.php | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 21d4963aa7..24dd58c116 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1683,6 +1683,8 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics + $last_mark = $user->data['user_lastmark']; + $sql_array = array( 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', @@ -1691,16 +1693,23 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s 'LEFT_JOIN' => array( array( 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => 't.topic_id = tt.topic_id AND t.topic_last_post_time > tt.mark_time AND tt.user_id = ' . $user_id, + 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id AND tt.mark_time > $last_mark", ), array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 't.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ft.user_id = ' . $user_id, + 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id AND ft.mark_time > $last_mark", ), ), - 'WHERE' => "((tt.topic_id OR ft.forum_id) - OR t.topic_last_post_time > {$user->data['user_lastmark']}) + 'WHERE' => " + ( + (tt.mark_time AND t.topic_last_post_time > tt.mark_time) OR + (tt.mark_time IS NULL AND ft.mark_time AND t.topic_last_post_time > ft.mark_time) OR + ( + ((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark)) + AND t.topic_last_post_time > $last_mark + ) + ) $sql_extra $sql_sort", ); @@ -1711,8 +1720,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - - $unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; + $unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark); } $db->sql_freeresult($result); } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 5caccc81d9..cec1becb6e 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -107,9 +107,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $ga_unread = false; if ($root_data['forum_id'] == 0) { - $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0'); + $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); - if (sizeof($unread_ga_list)) + if (!empty($unread_ga_list)) { $ga_unread = true; } -- cgit v1.2.1 From a5e4ca259aa98bc3d5abc03dcf4504c2afe91e92 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 8 Sep 2009 14:02:40 +0000 Subject: Always remove temporary filename (Bug #50965) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10122 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_upload.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 40ff4de2d1..a7abb06674 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -313,12 +313,9 @@ class filespec if (!@move_uploaded_file($this->filename, $this->destination_file)) { $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; } } - @unlink($this->filename); - break; case 'move': @@ -328,12 +325,9 @@ class filespec if (!@copy($this->filename, $this->destination_file)) { $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; } } - @unlink($this->filename); - break; case 'local': @@ -341,14 +335,21 @@ class filespec if (!@copy($this->filename, $this->destination_file)) { $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; } - @unlink($this->filename); break; } + // Remove temporary filename + @unlink($this->filename); + + if (sizeof($this->error)) + { + return false; + } + phpbb_chmod($this->destination_file, $chmod); + return true; } // Try to get real filesize from destination folder -- cgit v1.2.1 From dc4619c889c3ac3449555f63445828168055b033 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 9 Sep 2009 08:07:01 +0000 Subject: define $data array at the correct location. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10123 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewfolder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 43b12a59e6..6493b54e1f 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -118,8 +118,6 @@ function view_folder($id, $mode, $folder_id, $folder) $address_list = get_recipient_strings($folder_info['rowset']); } - $data = array(); - foreach ($folder_info['pm_list'] as $message_id) { $row = &$folder_info['rowset'][$message_id]; @@ -196,7 +194,8 @@ function view_folder($id, $mode, $folder_id, $folder) else { // Build Recipient List if in outbox/sentbox - $address = array(); + $address = $data = array(); + if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { foreach ($folder_info['rowset'] as $message_id => $row) -- cgit v1.2.1 From 30d402c24b3fa0af4285926784c97fde099254b7 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 9 Sep 2009 09:08:24 +0000 Subject: Send emails for manual user activation if admin activation is enabled not through queue in ACP (Bug #50925) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10124 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_inactive.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index e41e8f661d..3d0c0a2780 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -113,7 +113,7 @@ class acp_inactive { include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(); + $messenger = new messenger(false); foreach ($inactive_users as $row) { -- cgit v1.2.1 From 8c3d390c61d692ff9501e3ccdaa0f39716c5fab4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 9 Sep 2009 21:41:51 +0000 Subject: Related to r9830: Change REPORT_POST to REPORT_PM. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10126 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 0e51e268cf..26968e1382 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -193,7 +193,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['SEND_EMAIL']), 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']), 'REPLY_IMG' => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']), - 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), + 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_PM'), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']), 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), -- cgit v1.2.1 From ab971c59be9eefe86bd53bad5858c6427ccc57eb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Sep 2009 08:44:34 +0000 Subject: Fix bug #51075 introduced in r10121. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10129 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 24dd58c116..092a5d5d86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1703,8 +1703,8 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s 'WHERE' => " ( - (tt.mark_time AND t.topic_last_post_time > tt.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time AND t.topic_last_post_time > ft.mark_time) OR + (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR + (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR ( ((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark)) AND t.topic_last_post_time > $last_mark -- cgit v1.2.1 From 94373fd1f85f79dae1674313c27ebb1735991c9a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 10 Sep 2009 13:30:47 +0000 Subject: also collect admins user agent vendor and version (send_statistics) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10131 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/questionnaire/questionnaire.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 16bd79742d..1d015576a7 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -179,7 +179,7 @@ class phpbb_questionnaire_system_data_provider // - 10.0.0.0/8 // - 172.16.0.0/12 // - 192.168.0.0/16 - 'ip' => $ip_address_ary[0] . '.' . $ip_address_ary[1] . '.XXX.YYY', + 'ip' => $ip_address_ary[0] . '.' . $ip_address_ary[1] . '.XXX.YYY', ); } } @@ -233,7 +233,7 @@ class phpbb_questionnaire_phpbb_data_provider { global $phpbb_root_path, $phpEx; include("{$phpbb_root_path}config.$phpEx"); - + // Only send certain config vars $config_vars = array( 'active_sessions' => true, @@ -447,6 +447,22 @@ class phpbb_questionnaire_phpbb_data_provider $result['dbms'] = $dbms; $result['acm_type'] = $acm_type; $result['load_extensions'] = $load_extensions; + $result['user_agent'] = 'Unknown'; + + // Try to get user agent vendor and version + $match = array(); + $user_agent = (!empty($_SERVER['HTTP_USER_AGENT'])) ? (string) $_SERVER['HTTP_USER_AGENT'] : ''; + $agents = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol'); + + // We check here 1 by 1 because some strings occur after others (for example Mozilla [...] Firefox/) + foreach ($agents as $agent) + { + if (preg_match('#(' . $agent . ')[/ ]?([0-9.]*)#i', $user_agent, $match)) + { + $result['user_agent'] = $match[1] . ' ' . $match[2]; + break; + } + } return $result; } -- cgit v1.2.1 From 33e58d8e9038610fa708cdbaf951f1fb8e28f3c0 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Sep 2009 19:49:19 +0000 Subject: Fix bug #51105. - Ignore (disable) newly generated forum in forums list. Related to r9896. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10135 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 5a44af836f..045d8a2e8e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1936,7 +1936,7 @@ class acp_forums 'L_ACL_LINK' => $l_acl, 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), 'S_COPY_ACTION' => $action, - 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], false, false, false, false), + 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), )); } -- cgit v1.2.1 From e4e59b3b659cc71144c73f1f71e89f03f1cc56b5 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 11 Sep 2009 13:53:56 +0000 Subject: #50985 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10136 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewfolder.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 6493b54e1f..0ad602eb5c 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -194,13 +194,15 @@ function view_folder($id, $mode, $folder_id, $folder) else { // Build Recipient List if in outbox/sentbox - $address = $data = array(); + + $address_temp = $address = $data = array(); if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { foreach ($folder_info['rowset'] as $message_id => $row) { - $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); + $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); + $address[$message_id] = array(); } } @@ -224,8 +226,12 @@ function view_folder($id, $mode, $folder_id, $folder) $_types = array('u', 'g'); foreach ($_types as $ug_type) { - if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) + if (isset($address_temp[$message_id][$ug_type]) && sizeof($address_temp[$message_id][$ug_type])) { + if (!isset($address[$message_id][$ug_type])) + { + $address[$message_id][$ug_type] = array(); + } if ($ug_type == 'u') { $sql = 'SELECT user_id as id, username as name @@ -238,21 +244,31 @@ function view_folder($id, $mode, $folder_id, $folder) FROM ' . GROUPS_TABLE . ' WHERE '; } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type]))); + $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); $result = $db->sql_query($sql); while ($info_row = $db->sql_fetchrow($result)) { - $address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; - unset($address[$message_id][$ug_type][$info_row['id']]); + $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; + unset($address_temp[$message_id][$ug_type][$info_row['id']]); } $db->sql_freeresult($result); } } - decode_message($message_row['message_text'], $message_row['bbcode_uid']); + // There is the chance that all recipients of the message got deleted. To avoid creating + // exports without recipients, we add a bogus "undisclosed recipient". + if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) && + !(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u']))) + { + $address[$message_id]['u'] = array(); + $address[$message_id]['u']['to'] = array(); + $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; + } + decode_message($message_row['message_text'], $message_row['bbcode_uid']); + $data[] = array( 'subject' => censor_text($row['message_subject']), 'sender' => $row['username'], -- cgit v1.2.1 From bf63d6cf10eb2bfd007dc220245ccfdab55a4f34 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 11 Sep 2009 14:38:23 +0000 Subject: rollback; will be in 3.0.7 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10138 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_pm_viewfolder.php | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 0ad602eb5c..6493b54e1f 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -194,15 +194,13 @@ function view_folder($id, $mode, $folder_id, $folder) else { // Build Recipient List if in outbox/sentbox - - $address_temp = $address = $data = array(); + $address = $data = array(); if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) { foreach ($folder_info['rowset'] as $message_id => $row) { - $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - $address[$message_id] = array(); + $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); } } @@ -226,12 +224,8 @@ function view_folder($id, $mode, $folder_id, $folder) $_types = array('u', 'g'); foreach ($_types as $ug_type) { - if (isset($address_temp[$message_id][$ug_type]) && sizeof($address_temp[$message_id][$ug_type])) + if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) { - if (!isset($address[$message_id][$ug_type])) - { - $address[$message_id][$ug_type] = array(); - } if ($ug_type == 'u') { $sql = 'SELECT user_id as id, username as name @@ -244,31 +238,21 @@ function view_folder($id, $mode, $folder_id, $folder) FROM ' . GROUPS_TABLE . ' WHERE '; } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); + $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type]))); $result = $db->sql_query($sql); while ($info_row = $db->sql_fetchrow($result)) { - $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; - unset($address_temp[$message_id][$ug_type][$info_row['id']]); + $address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; + unset($address[$message_id][$ug_type][$info_row['id']]); } $db->sql_freeresult($result); } } - // There is the chance that all recipients of the message got deleted. To avoid creating - // exports without recipients, we add a bogus "undisclosed recipient". - if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) && - !(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u']))) - { - $address[$message_id]['u'] = array(); - $address[$message_id]['u']['to'] = array(); - $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; - } - decode_message($message_row['message_text'], $message_row['bbcode_uid']); - + $data[] = array( 'subject' => censor_text($row['message_subject']), 'sender' => $row['username'], -- cgit v1.2.1 From c768cff554212c04c6da254418657faf4eab0b15 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 12 Sep 2009 13:17:58 +0000 Subject: fix #49625 r10002 - Do not drop forum_id on mcp_front (un)approval Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10139 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_front.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 0ee3eb2466..50e14b9336 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -120,7 +120,7 @@ function mcp_front_view($id, $mode, $action) } $s_hidden_fields = build_hidden_fields(array( - 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main') + 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&f=' . $forum_id : '')) )); $template->assign_vars(array( -- cgit v1.2.1