Seite 1 von 2

Flood Controle greift nur bei registrierten (2.05)

Verfasst: 27.07.2003 21:33
von SevenIsMy
Hallo,

ich habe phpbb 2.05 installiert auf www.c-plusplus.de/forum und ich bin auch zufrieden mit (vobei ich weniger bug probleme hatte in 2.04).

problem: die flood controle funktioniert bei unregistrierten nicht 100%, wenn man schnell hintereinander auf "absenden" klickt kann man bis zu zwei postings pro sekunde machen

wenn man sich mehr zeit läst beim klicken dann funktioniert die flood contole ganz normal

das komische ist bei registrierten funktioniert die FC (flood controle) ohne probleme

ich sitze schon zwei tage an den problem, habt ihr vielleicht irgend welche ansatzpunkte für mich?

der code def für die FC zuständig ist

Code: Alles auswählen

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
{
	global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
	global $userdata, $user_ip;

	include($phpbb_root_path . 'includes/functions_search.'.$phpEx);

	$current_time = time();
//Dimah
//Orginal

	if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost')

//end of Orginal
//   if (($mode == 'newtopic' || $mode == 'reply') /*&& ($userdata['user_level'] != ADMIN || $userdata['user_level'] != MOD) */)
//end of Dimah
	{
		//
		// Flood control
		//
		$where_sql = ($userdata['user_id'] == ANONYMOUS) ? "poster_ip = '$user_ip'" : 'poster_id = ' . $userdata['user_id'];
		$sql = "SELECT MAX(post_time) AS last_post_time
			FROM " . POSTS_TABLE . "
			WHERE $where_sql";
		if ($result = $db->sql_query($sql))
		{
			if ($row = $db->sql_fetchrow($result))
			{
				if (intval($row['last_post_time']) > 0 && ($current_time - intval($row['last_post_time'])) < intval($board_config['flood_interval']))
				{
					message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
				}
			}
		}

        $f = fopen('./log.txt', 'a');
        fwrite($f,"submitzeitpunkt: $current_time\n".
                  "last_post_time: ".intval($row['last_post_time'])."\n".
                  "user: $post_username\n".
                  "ip: ".substr($user_ip, 0, 4)."\n\n");
        fclose($f);

	}

	if ($mode == 'editpost')
	{
		remove_search_post($post_id);
	}

	if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
	{
		$topic_vote = (!empty($poll_title) && count($poll_options) >= 2) ? 1 : 0;

		$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}

		if ($mode == 'newtopic')
		{
			$topic_id = $db->sql_nextid();
		}
	}

//Dimah
//Orginal

	$edited_sql = ($mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post']) ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1 " : "";

//end of Orginal
//	$edited_sql = ($mode == 'editpost') ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1 , post_last_editor = " . $userdata['user_id'] : "";
//end of Dimah

	$sql = ($mode != "editpost") ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)" : "UPDATE " . POSTS_TABLE . " SET post_username = '$post_username', enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . " WHERE post_id = $post_id";
	if (!$db->sql_query($sql, BEGIN_TRANSACTION))
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	if ($mode != 'editpost')
	{
		$post_id = $db->sql_nextid();
	}

	$sql = ($mode != 'editpost') ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '$post_message',  bbcode_uid = '$bbcode_uid', post_subject = '$post_subject' WHERE post_id = $post_id";
	if (!$db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	}

	add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject));

	//
	// Add poll
	//
	if (($mode == 'newtopic' || ($mode == 'editpost' && $post_data['edit_poll'])) && !empty($poll_title) && count($poll_options) >= 2)
	{
		$sql = (!$post_data['has_poll']) ? "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ($topic_id, '$poll_title', $current_time, " . ($poll_length * 86400) . ")" : "UPDATE " . VOTE_DESC_TABLE . " SET vote_text = '$poll_title', vote_length = " . ($poll_length * 86400) . " WHERE topic_id = $topic_id";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}

		$delete_option_sql = '';
		$old_poll_result = array();
		if ($mode == 'editpost' && $post_data['has_poll'])
		{
			$sql = "SELECT vote_option_id, vote_result
				FROM " . VOTE_RESULTS_TABLE . "
				WHERE vote_id = $poll_id
				ORDER BY vote_option_id ASC";
			if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_ERROR, 'Could not obtain vote data results for this topic', '', __LINE__, __FILE__, $sql);
			}

			while ($row = $db->sql_fetchrow($result))
			{
				$old_poll_result[$row['vote_option_id']] = $row['vote_result'];

				if (!isset($poll_options[$row['vote_option_id']]))
				{
					$delete_option_sql .= ($delete_option_sql != '') ? ', ' . $row['vote_option_id'] : $row['vote_option_id'];
				}
			}
		}
		else
		{
			$poll_id = $db->sql_nextid();
		}

		@reset($poll_options);

		$poll_option_id = 1;
		while (list($option_id, $option_text) = each($poll_options))
		{
			if (!empty($option_text))
			{
				$option_text = str_replace("\'", "''", htmlspecialchars($option_text));
				$poll_result = ($mode == "editpost" && isset($old_poll_result[$option_id])) ? $old_poll_result[$option_id] : 0;

				$sql = ($mode != "editpost" || !isset($old_poll_result[$option_id])) ? "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ($poll_id, $poll_option_id, '$option_text', $poll_result)" : "UPDATE " . VOTE_RESULTS_TABLE . " SET vote_option_text = '$option_text', vote_result = $poll_result WHERE vote_option_id = $option_id AND vote_id = $poll_id";
				if (!$db->sql_query($sql))
				{
					message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
				}
				$poll_option_id++;
			}
		}

		if ($delete_option_sql != '')
		{
			$sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "
				WHERE vote_option_id IN ($delete_option_sql)
					AND vote_id = $poll_id";
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Error deleting pruned poll options', '', __LINE__, __FILE__, $sql);
			}
		}
	}

	$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
	$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');

	return false;
}
das auskomentiert zwischen //Dimah und //end of Dimah sind ein paar mod, die ich aber ausgemacht habe solange das problem bestäht

und mit

Code: Alles auswählen

        $f = fopen('./log.txt', 'a');
        fwrite($f,"submitzeitpunkt: $current_time\n".
                  "last_post_time: ".intval($row['last_post_time'])."\n".
                  "user: $post_username\n".
                  "ip: ".substr($user_ip, 0, 4)."\n\n");
        fclose($f);
lasse ich eine kleine log schreiben
z.b. das habe ich grade aus den log gelessen

Code: Alles auswählen

submitzeitpunkt: 1059333915
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333916
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333917
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333917
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333918
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333918
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333919
last_post_time: 1059333558
user: tresdfg
ip: d9e7

submitzeitpunkt: 1059333919
last_post_time: 1059333558
user: tresdfg
ip: d9e7

(neuer versuch)

submitzeitpunkt: 1059334230
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334231
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334232
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334232
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334233
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334234
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334234
last_post_time: 1059333919
user: testhh
ip: d9e7

submitzeitpunkt: 1059334234
last_post_time: 1059333919
user: testhh
ip: d9e7

(die ip adresse ist gekürtz)


ahja fals ihr test machen wollt dann bitte in diesen thread
http://www.c-plusplus.de/forum/viewtopic.php?t=44049

danke

Verfasst: 28.07.2003 10:49
von Acid
hmm.. hast du mal testweise die functions_post.php gegen eine originale Datei ausgetauscht ? Wie hoch is bei dir das Flood Limit ?

Hast du irgendwas am Board verändert, das "Gäste" betrifft (neben der Tatsache, das man als Gast einen Namen eintragen muss).

Verfasst: 28.07.2003 19:36
von SevenIsMy
Acid hat geschrieben:hmm.. hast du mal testweise die functions_post.php gegen eine originale Datei ausgetauscht ?
noch nicht, würde mich aber sehr wundern wenns helfen würde, aber viel schaden kanns auch nicht

Wie hoch is bei dir das Flood Limit ?
35 Sekunden
Hast du irgendwas am Board verändert, das "Gäste" betrifft (neben der Tatsache, das man als Gast einen Namen eintragen muss).
vielleicht hätte ich es erwähnen sollen das unser uhrsprüngliches board ein ubb war,
ich habe mit hilfe des converters 9000 user und 300000 postings convertiert
(jetzt kommt bestimt der tipp mit den DB Maintenance Mod ;) )
aber erstens denke ich das der converter korekt gearbeitet hatt (weil ich ihn gebugfixt habe, die bugfixes wollte ich auch schon public machen, nur haben mir die phpbb bugs keine zeit gelassen) und außerdem greift die FC doch auf aktuele daten zu

dann habe ich bei gästen das anzeigen der 'Andere IP-Adressen, von denen dieser Benutzer geschrieben hat' ausgemacht weil er mir dann alle ips auflistet mit den jemals ein gast gepostet hat

Verfasst: 28.07.2003 21:35
von SevenIsMy
SevenIsMy hat geschrieben:
Acid hat geschrieben:hmm.. hast du mal testweise die functions_post.php gegen eine originale Datei ausgetauscht ?
noch nicht, würde mich aber sehr wundern wenns helfen würde, aber viel schaden kanns auch nicht
hat nicht geholfen

SevenIsMy hat geschrieben: (jetzt kommt bestimt der tipp mit den DB Maintenance Mod ;) )
das half auch nicht (hatt er ein paar andere fehler gekillt)

Verfasst: 28.07.2003 21:44
von SevenIsMy
neue entdekung, in mozilla kann mann nicht flooden (ka ob das eine wichtige erkentnis ist)

Verfasst: 29.07.2003 12:34
von Acid
Nich unbedingt.. bei Mozilla funktioniert das Senden der Informationen halt anders als beim IE (dort könnte man mehrere Male hintereinander auf den submit - Button klicken und es würde gesendet werden, bzw. die Flood Control würde greifen; bei Mozilla geht´s halt nur einmalig). Der Eintrag "Anonymous" existiert doch in der "users" Tabelle oder (Datenbank) ?

Verfasst: 29.07.2003 19:33
von SevenIsMy
Acid hat geschrieben: Der Eintrag "Anonymous" existiert doch in der "users" Tabelle oder (Datenbank) ?
jup mit der user_id -1

Verfasst: 29.07.2003 21:07
von Acid
Welche Datenbank wird genutzt und is eingestellt !?

Verfasst: 29.07.2003 21:56
von SevenIsMy
MySQL 3.23.4 und in der config.php steht $dbms = 'mysql';

ich habe aber auch schon den webmaster gefragt ob ein update auf 4.x möglich ist ( zu zeit ist er auf geschäftsreise, also die antwort wird noch dauern)

Verfasst: 30.07.2003 09:37
von Acid
Mit Vers.4 dürfte das Problem weiterhin bestehen (ich fragte, weil wenn 3 genutzt wird und 4 eingetragen is, kann es zu den merkwürdigsten Fehlern kommen). Könntest du mal auf deinem Server einen weitere 2.0.5er installieren und dort die Flood Control überprüfen (bei der Installation einen anderen Prefix angeben)?

Hast du auch mal versucht, die Flood Control herunterzusetzen und dann wieder auf 35 sec. (oder generell sie etwas herunterzuschrauben) !?