# HG changeset patch # User Dan # Date 1192677429 14400 # Node ID 88b85b9b9272d5b4b79aa5c50e0f9480a2362d1e # Parent 253118325c65543c051a9dc9bfca392a57329179 What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now. diff -r 253118325c65 -r 88b85b9b9272 decir/delete.php --- a/decir/delete.php Wed Oct 17 21:52:27 2007 -0400 +++ b/decir/delete.php Wed Oct 17 23:17:09 2007 -0400 @@ -40,7 +40,8 @@ $tid = intval($row['topic_id']); -$acl_type = ( $row['poster_id'] == $session->user_id && $session->user_logged_in ) ? 'decir_edit_own' : 'decir_edit_other'; +$own_post = ( $row['poster_id'] == $session->user_id && $session->user_logged_in ); +$acl_type = ( $own_post ) ? 'decir_edit_own' : 'decir_edit_other'; $post_perms = $session->fetch_page_acl(strval($pid), 'DecirPost'); if ( !$post_perms->get_permissions($acl_type) ) @@ -53,6 +54,15 @@ { if ( isset($_POST['do']['delete']) ) { + // Check permissions (of course!) + $acl_type = ( $own_post + ? ( $_POST['delete_method'] == 'hard' ? 'decir_delete_own_post_hard' : 'decir_delete_own_post_soft' ) + : ( $_POST['delete_method'] == 'hard' ? 'decir_delete_other_post_hard' : 'decir_delete_other_post_soft' ) + ); + if ( !$post_perms->get_permissions($acl_type) ) + { + die_friendly('Error', '
You do not have access to perform this type of deletion on this post.
'); + } // Nuke it $result = decir_delete_post($pid, $_POST['edit_reason'], ( $_POST['delete_method'] == 'hard' )); if ( $result ) diff -r 253118325c65 -r 88b85b9b9272 decir/edit.php --- a/decir/edit.php Wed Oct 17 21:52:27 2007 -0400 +++ b/decir/edit.php Wed Oct 17 23:17:09 2007 -0400 @@ -39,7 +39,8 @@ $row = $db->fetchrow(); $db->free_result(); -$acl_type = ( $row['poster_id'] == $session->user_id && $session->user_logged_in ) ? 'decir_edit_own' : 'decir_edit_other'; +$own_post = ( $row['poster_id'] == $session->user_id && $session->user_logged_in ); +$acl_type = ( $own_post ) ? 'decir_edit_own' : 'decir_edit_other'; $post_perms = $session->fetch_page_acl(strval($pid), 'DecirPost'); if ( !$post_perms->get_permissions($acl_type) ) @@ -69,6 +70,15 @@ // Save changes if ( isset($_POST['do']['delete']) ) { + // Check permissions (of course!) + $acl_type = ( $own_post + ? ( $_POST['delete_method'] == 'hard' ? 'decir_delete_own_post_hard' : 'decir_delete_own_post_soft' ) + : ( $_POST['delete_method'] == 'hard' ? 'decir_delete_other_post_hard' : 'decir_delete_other_post_soft' ) + ); + if ( !$post_perms->get_permissions($acl_type) ) + { + die_friendly('Error', 'You do not have access to perform this type of deletion on this post.
'); + } // Nuke it $result = decir_delete_post($pid, $_POST['edit_reason']); if ( $result ) diff -r 253118325c65 -r 88b85b9b9272 decir/functions.php --- a/decir/functions.php Wed Oct 17 21:52:27 2007 -0400 +++ b/decir/functions.php Wed Oct 17 23:17:09 2007 -0400 @@ -210,14 +210,18 @@ return false; // Obtain a list of posts in the topic - $q = $db->sql_query('SELECT post_id FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); + $q = $db->sql_query('SELECT post_id, post_deleted FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); if ( !$q ) $db->_die('Decir functions.php in decir_delete_topic()'); if ( $db->numrows() < 1 ) return false; $posts = array(); + $del_count = 0; while ( $row = $db->fetchrow() ) { + if ( $row['post_deleted'] == 1 ) + // Don't decrement the post count for deleted posts + $del_count++; $posts[] = $row['post_id']; } @@ -252,7 +256,7 @@ } // Update forum stats - $post_count = count($posts); + $post_count = count($posts) - $del_count; $q = $db->sql_query('UPDATE '.table_prefix."decir_forums SET num_topics = num_topics - 1, num_posts = num_posts - $post_count WHERE forum_id = $forum_id;"); if ( !$q ) $db->_die('Decir functions.php in decir_delete_topic()'); @@ -358,14 +362,18 @@ return false; // Obtain a list of posts in the topic - $q = $db->sql_query('SELECT post_id FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); + $q = $db->sql_query('SELECT post_id, post_deleted FROM '.table_prefix.'decir_posts WHERE topic_id = ' . $topic_id . ';'); if ( !$q ) $db->_die('Decir functions.php in decir_delete_topic()'); if ( $db->numrows() < 1 ) return false; $posts = array(); + $del_count = 0; while ( $row = $db->fetchrow() ) { + if ( $row['post_deleted'] == 1 ) + // Don't decrement the post count for deleted posts + $del_count++; $posts[] = $row['post_id']; } @@ -379,7 +387,7 @@ $q = $db->sql_query('UPDATE ' . table_prefix . "decir_topics SET topic_deleted = 0, topic_deletor = NULL, topic_delete_reason = NULL WHERE topic_id = $topic_id;"); // Update forum stats - $post_count = count($posts); + $post_count = count($posts) - $del_count; $q = $db->sql_query('UPDATE '.table_prefix."decir_forums SET num_topics = num_topics + 1, num_posts = num_posts + $post_count WHERE forum_id = $forum_id;"); if ( !$q ) $db->_die('Decir functions.php in decir_restore_topic()'); diff -r 253118325c65 -r 88b85b9b9272 decir/functions_viewtopic.php --- a/decir/functions_viewtopic.php Wed Oct 17 21:52:27 2007 -0400 +++ b/decir/functions_viewtopic.php Wed Oct 17 23:17:09 2007 -0400 @@ -93,7 +93,9 @@ {USER_TITLE}' . print_r($session, true) . ''); + $this->parser->assign_bool(Array( 'whos_online_support' => $who_support, 'user_is_online' => $user_online, 'post_edited' => ( $row['edit_count'] > 0 ), 'post_deleted' => ( $row['post_deleted'] == 1 ), - // FIXME: This should check something on ACLs - 'show_post' => ( $row['post_deleted'] != 1 || $session->user_level >= USER_LEVEL_MOD ) + 'show_post' => ( $session->get_permissions('decir_see_deleted_post_full') || $row['post_deleted'] != 1 ), + 'user_is_registered' => ( $row['poster_id'] > 1 ) )); return $this->parser->run(); } diff -r 253118325c65 -r 88b85b9b9272 decir/posting.php --- a/decir/posting.php Wed Oct 17 21:52:27 2007 -0400 +++ b/decir/posting.php Wed Oct 17 23:17:09 2007 -0400 @@ -77,6 +77,16 @@ if ( !$parms['authorized'] ) $errors[] = 'Invalid authorization key'; + // If the user isn't logged in, check the CAPTCHA code + if ( !$session->user_logged_in ) + { + $captcha_hash = $_POST['captcha_hash']; + $captcha_code = $_POST['captcha_code']; + $real_code = $session->get_captcha($captcha_hash); + if ( $real_code != $captcha_code ) + $errors[] = 'The confirmation code you entered was incorrect.'; + } + if ( sizeof($errors) < 1 ) { // Collect other options @@ -137,7 +147,7 @@ { /** - * @TODO: validate read permissions + * @FIXME: validate read permissions */ $post_id = intval($paths->getParam(2)); @@ -288,6 +298,14 @@ echo '
Post subject: | '; +if ( !$session->user_logged_in ) +{ + $hash = $session->make_captcha(); + $captcha_url = makeUrlNS('Special', 'Captcha/' . $hash); + $captcha_img = ""; + echo ' |
Image verification: | ' . $captcha_img . ' |
Please input the code you see in the image: | |
'; echo ''; echo ' |