Erweiterung für Signatures control MOD v1.2.1

In diesem Forum können Mod-Autoren ihre Mods vorstellen, die sich noch im Entwicklungsstatus befinden. Der Einbau in Foren im produktiven Betrieb wird nicht empfohlen.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Benutzeravatar
Waagenbauer
Mitglied
Beiträge: 219
Registriert: 11.06.2001 02:00
Kontaktdaten:

Erweiterung für Signatures control MOD v1.2.1

Beitrag von Waagenbauer »

Der Signatures control MOD v1.2.1 ist eine feine Sache.
Man kann damit eine Menge Kriterien für die Signaturen der User einstellen.
Es können Images in Anzahl und Größe & die Zeichenlänge begrenzt werden. BBCcodes eingeschränkt werden usw.
Hier bekommt ihr den MOD: http://www.golfexpert.net/link.php?from=01&to=11
Und hier eine Übersetzung der Sprachdatei: http://www.supra4ever.de/text/lang_sig_control.txt

Nur gibts es ein Problem dabei. Mit dem MOD kann man nur ALLE Signaturen löschen.

Mit meinem Tool hier werden die Signaturen geprüft und nur die gelöscht, die gegen die eingestellten Regeln verstoßen.

Code: Alles auswählen

<?php
// **************************************************************************
// Signatures Filter Tool v1.0
// For the "Signatures control MOD v1.2.1" by http://www.golfexpert.net/phpbb
// Programmed by Downer, Webmaster @ http://www.kaltmacher.de
// **************************************************************************
 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$sql = "SELECT user_id, username, user_sig, user_allowsignature
	FROM " . USERS_TABLE . "
	WHERE user_id <> " . ANONYMOUS . "
	ORDER BY user_id";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
}

if ( $row = $db->sql_fetchrow($result) )
{
	$users = 0;
	$error_sigs = 0;
	$user_id_array = array();
	$username_array = array();
	do
	{
		$error = FALSE;
		$username = $row['username'];
		$user_id = $row['user_id'];
		$signature = $row['user_sig'];
	
// Signatures control MOD
if ( $signature != '' && $row['user_allowsignature'] == 1 )
{
		if ( strlen($signature) > $board_config['max_sig_chars'] && !$board_config['max_sig_chars'] )
		{
			$error = TRUE;
		}
		
	// Start add - Signatures control MOD
	$sig_error_list = '';

	// BBCodes control
	$bbcode_error_list = '';
	$bbcode_error_list .= ( !$board_config['sig_allow_font_sizes'] && substr_count(strtolower($signature), '[/size]') > 0 ) ? '[size]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_bold'] && substr_count(strtolower($signature), '[/b]') > 0 ) ? '[b]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_italic'] && substr_count(strtolower($signature), '[/i]') > 0 ) ? '[i]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_underline'] && substr_count(strtolower($signature), '[/u]') > 0 ) ? '[u]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_colors'] && substr_count(strtolower($signature), '[/color]') > 0 ) ? '[color]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_quote'] && substr_count(strtolower($signature), '[/quote]') > 0 ) ? '[quote]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_code'] && substr_count(strtolower($signature), '[/clode]') > 0 ) ? '[clode]' : ''; // <--- ***ACHTUNG! *** Vor dem Einbau hier: 2x clode gegen code ersezen!
	$bbcode_error_list .= ( !$board_config['sig_allow_list'] && substr_count(strtolower($signature), '[/list]') > 0 ) ? '[list]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_url'] && substr_count(strtolower($signature), '[/url]') > 0 ) ? '[url]' : '';
	$bbcode_error_list .= ( !$board_config['sig_allow_images'] && substr_count(strtolower($signature), '[/img]') > 0 ) ? '[img]' : '';

	$exotic_bbcodes_list = explode(",", $board_config['sig_exotic_bbcodes_disallowed']);
	while ( list($bbckey, $exotic_bbcode) = @each($exotic_bbcodes_list) )
	{
		$exotic_bbcode = trim(strtolower($exotic_bbcode));
		if ( $exotic_bbcode != '' )
		{
			$bbcode_error_list .= ( substr_count(strtolower($signature), '[/'.$exotic_bbcode.']') > 0 ) ? '['.$exotic_bbcode.']' : '';
		}
	}

	if ( $bbcode_error_list != '' )
	{
		$error = TRUE;
	}

	// Number of lines control
	if ( $board_config['sig_max_lines'] )
	{
		if ( count(explode("\n", $signature)) > $board_config['sig_max_lines'] ) 
		{ 
			$error = TRUE;
		}
	}

	// Wordwrap control
	if ( $board_config['sig_wordwrap'] )
	{
		$signature_no_url = preg_replace("#\[img\].*?\[/img\]|\[\/?(size.*?|b|i|u|color.*?|quote.*?|code|list.*?|url.*?)\]#si", "", $signature);
		$signature_splited = preg_split("/[\s,]+/", $signature_no_url);

		foreach($signature_splited as $key => $word)
		{
			$length = strlen($word);
			if( $length > $board_config['sig_wordwrap'] )
			{
				$words[$key] = $word;
			}
		}

		if ( count($words) ) 
		{ 
			$error = TRUE;
		}
	}

	// Font size limit control (imposed font size is managed in viewtopic.php)
	if ( $board_config['sig_allow_font_sizes'] == 2 )
	{
		if( preg_match_all("#\[size=([0-9]+?)\](.*?)\[/size\]#si", $signature, $sig_sizes_list) )
		{
			if ( $board_config['sig_min_font_size'] && min($sig_sizes_list[1]) < $board_config['sig_min_font_size'] )
			{
				$error = TRUE;
			}
			if ( $board_config['sig_max_font_size'] && max($sig_sizes_list[1]) > $board_config['sig_max_font_size'] )
			{
				$error = TRUE;
			}
		}
	}

	// Images control (except file the size error message)
	$total_image_files_size = 0;

	if( $board_config['sig_allow_images'] && preg_match_all("#\[img\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img\]#si", $signature, $sig_images_list) )
	{
		if( count($sig_images_list[0]) > $board_config['sig_max_images'] && $board_config['sig_max_images'] != 0 )
		{
			$error = TRUE;
		}

		for( $i = 0; $i < count($sig_images_list[0]); $i++ )
		{
			$image_url = $sig_images_list[1][$i].$sig_images_list[3][$i];

			preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $image_url, $image_url_ary);

			if ( empty($image_url_ary[4]) )
			{
				$error = true;
			} else
			{
				$image_size_control = false;
				if ( $board_config['sig_max_img_height'] != 0 || $board_config['sig_max_img_width'] != 0 )
				{
					usleep(1500);
					if ( list($image_width, $image_height) = @getimagesize($image_url) )
					{
						$image_size_control = true;
						if( ($board_config['sig_max_img_height'] != 0 && $image_height > $board_config['sig_max_img_height']) ||
						    ($board_config['sig_max_img_width'] != 0 && $image_width > $board_config['sig_max_img_width']) )
						{
							$error = TRUE;
						}
					}
				}
	
				$image_data = '';
				$image_file_size_control = 0;
				if( $board_config['sig_max_img_files_size'] != 0 || $board_config['sig_max_img_av_files_size'] != 0 ||
					(($board_config['sig_max_img_height'] != 0 || $board_config['sig_max_img_width'] != 0) && $image_size_control == false) )
				{
					if( $image_fd = @fopen($image_url, "rb") )
					{
						while (!feof($image_fd))
						{
							$image_data .= fread($image_fd, 1024);
						}
						fclose($image_fd);

						$total_image_files_size += strlen($image_data);
						$image_file_size_control = 3;
					} else		
					{
						$base_get = '/' . $image_url_ary[4];
						$port = ( !empty($image_url_ary[3]) ) ? $image_url_ary[3] : 80;

						if ( !($image_fsock = @fsockopen($image_url_ary[2], $port, $errno, $errstr)) )
						{
							$error = true;
						} else
						{
							@fputs($image_fsock, "GET $base_get HTTP/1.1\r\n");
							@fputs($image_fsock, "HOST: " . $image_url_ary[2] . "\r\n");
							@fputs($image_fsock, "Connection: close\r\n\r\n");

							while( !@feof($image_fsock) )
							{
								$image_data .= @fread($image_fsock, 1024);
							}
							@fclose($image_fsock);		

							if ( preg_match('#Content-Length\: ([0-9]+)[^ /][\s]+#i', $image_data, $image_file_data) )
							{
								$total_image_files_size += $image_file_data[1]; 
								$image_file_size_control = 2;
							} else
							{
								$total_image_files_size += strlen($image_data)-307; 
								$image_file_size_control = 1;
							}
						}
					}
				}

				if( ($board_config['sig_max_img_height'] != 0 || $board_config['sig_max_img_width'] != 0) && $image_size_control == false )
				{
					if( $image_file_size_control == 2 )
					{
						$image_data = substr($image_data, strlen($image_data) - $image_file_data[1], $image_file_data[1]);
					}

					if( function_exists('ImageCreateFromString') )
					{
						if( $image_string = @ImageCreateFromString($image_data) )
						{
							$image_width = ImageSX($image_string);
							$image_height = ImageSY($image_string);

							if( ($board_config['sig_max_img_height'] != 0 && $image_height > $board_config['sig_max_img_height']) ||
							    ($board_config['sig_max_img_width'] != 0 && $image_width > $board_config['sig_max_img_width']) )
							{
								$error = TRUE;
							}

							ImageDestroy($image_string);
						} else
						{
							if( $board_config['sig_allow_on_max_img_size_fail'] == 0 )
							{
								$error = TRUE;
							}
						}
					}else
					{
						if( $board_config['sig_allow_on_max_img_size_fail'] == 0 )
						{
							$error = TRUE;
						}
					}
				}
			}
		}
	}
}

if ( $error )
{
	$user_id_array[] = $user_id;
	$username_array[] = $username;
	$error_sigs++;
}
		$users++;
	}
	while ( $row = $db->sql_fetchrow($result) );
	$db->sql_freeresult($result);
}

$error_user_ids = implode(", ",$user_id_array);
$error_usernames = implode(", ",$username_array);

if ( $error_user_ids )
{
$sql = "UPDATE " . USERS_TABLE . " SET user_sig = ''
	WHERE user_id IN ($error_user_ids)
	";

if ( $result = $db->sql_query($sql) )
{
	$result_msg = 'Signaturen gefiltert';
}
else
{
	$result_msg = 'ERROR: Signaturen konnten nicht gefiltert werden';
}
}
else
{
	$result_msg = 'Alle Signaturen OK';
}

die($result_msg.' : '.$error_sigs.'<br><br>'.$error_usernames);
?>
http://www.kaltmacher.de - Die Seite für PC-Freaks und Profis.
Antworten

Zurück zu „phpBB 2.0: Mods in Entwicklung“