Archived
1
0

x fixed horizontal scrollbar in blackTed (and maybe similar) theme

x quick-fixed bug with UTF8 characters
+ added censoring of words
+ added automatic shoutbox-insertion into blackTed if installed
+ added "Type your shout"-message to input field
* simplified package-info.xml a bit
This commit is contained in:
mbirth 2006-09-04 06:44:04 +00:00
parent fb8bc5cf31
commit 093eb52301
6 changed files with 70 additions and 60 deletions

View File

@ -5,7 +5,7 @@
<id>Deep:SMF_Shoutbox</id>
<type>modification</type>
<version>1.14</version>
<install for="1.1 RC2">
<install for="1.1 RC2, 1.1 RC3">
<require-file name="sbox.php" destination="$sourcedir" />
<require-file name="sboxDB.php" destination="$sourcedir" />
<require-file name="sbox.english.php" destination="$languagedir" />
@ -23,38 +23,7 @@
]]></readme>
<modification type="file">sbox_latest.xml</modification>
</install>
<install for="1.1 RC3">
<require-file name="sbox.php" destination="$sourcedir" />
<require-file name="sboxDB.php" destination="$sourcedir" />
<require-file name="sbox.english.php" destination="$languagedir" />
<require-file name="sbox.german.php" destination="$languagedir" />
<require-file name="sbox.template.php" destination="$themedir" />
<require-file name="sbox_refresh.gif" destination="$themedir/images" />
<require-file name="chat-inbound_GSM.wav" destination="$boarddir" />
<code type="file">sbox_setup.php</code>
<readme type="inline"><![CDATA[
This allows you to put a shoutbox on your SMF forum above the board index of the default theme.
Originally written By Deep (diem4@gmx.net), inspired by Matthew Wolf (a.k.a Grudge)
Heavily improved by Markus Birth (mbirth@webwriters.de)
Copyright 2006 - Neither this package or any of it's contents may be distributed without authorisation.
]]></readme>
<modification type="file">sbox_latest.xml</modification>
</install>
<uninstall for="1.1 RC2">
<readme type="inline">Uninstall will remove all the changes made by the shoutbox. You must do this before upgrading!</readme>
<modification type="file" reverse="true">sbox_latest.xml</modification>
<remove-file name="$sourcedir/sbox.php" />
<remove-file name="$sourcedir/sboxDB.php" />
<remove-file name="$languagedir/sbox.english.php" />
<remove-file name="$languagedir/sbox.german.php" />
<remove-file name="$themedir/sbox.template.php" />
<remove-file name="$themedir/images/sbox_refresh.gif" />
<remove-file name="$boarddir/chat-inbound_GSM.wav" />
<remove-file name="$boarddir/sbox.history.html" />
<code type="file">sbox_remove.php</code>
</uninstall>
<uninstall for="1.1 RC3">
<uninstall for="1.1 RC2, 1.1 RC3">
<readme type="inline">Uninstall will remove all the changes made by the shoutbox. You must do this before upgrading!</readme>
<modification type="file" reverse="true">sbox_latest.xml</modification>
<remove-file name="$sourcedir/sbox.php" />

View File

@ -9,6 +9,7 @@ $txt['sbox_History'] = 'History';
$txt['sbox_HistoryClear'] = 'Clear history';
$txt['sbox_HistoryNotFound'] = 'No history found.';
$txt['sbox_Guest'] = 'Guest';
$txt['sbox_TypeShout'] = '<Type your message and press ENTER>';
// Settings
$txt['sbox_Visible'] = 'Shoutbox is visible';

View File

@ -9,6 +9,7 @@ $txt['sbox_History'] = 'Verlauf';
$txt['sbox_HistoryClear'] = 'Verlauf l&ouml;schen';
$txt['sbox_HistoryNotFound'] = 'Kein Verlauf gefunden.';
$txt['sbox_Guest'] = 'Gast';
$txt['sbox_TypeShout'] = '<Geben Sie Ihre Nachricht ein und drücken Sie ENTER>';
// Einstellungen
$txt['sbox_Visible'] = 'Shoutbox ist sichtbar';

View File

@ -47,15 +47,18 @@ function template_shout_box() {
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center" valign="middle">
<form name="sbox" action="' . $sourceurl . '/sboxDB.php?action=write" method="post" target="sboxframe" style="margin: 0;" onsubmit="setTimeout(\'clearSbox()\', 500);">
<form name="sbox" action="' . $sourceurl . '/sboxDB.php?action=write" method="post" target="sboxframe" style="margin: 0;" onsubmit="if (this.sboxText.value == \'' . $txt['sbox_TypeShout'] . '\') return false; else setTimeout(\'clearSbox()\', 500);" enctype="multipart/form-data" accept-charset="' . $context['character_set'] . '">
<a href="' . $sourceurl . '/sboxDB.php?" target="sboxframe"><img src="'.$imgdir.'sbox_refresh.gif" border="0" width="16" height="17" align="absmiddle" alt="' . $txt['sbox_Refresh'] . '" /></a>';
if ((!$context['user']['is_guest']) || ($modSettings['sbox_GuestAllowed'] == "1")) {
echo '
<input type="hidden" name="ts" value="'.forum_time(true).'">
<input class="windowbg2" type="text" name="sboxText" size="100" maxlength="320" />&nbsp;<input type="submit" class="input" value="&nbsp;shout&nbsp;" />';
<input class="windowbg2" type="text" name="sboxText" size="100" maxlength="320" onFocus="if (this.value==\'' . $txt['sbox_TypeShout'] . '\') this.value = \'\';" onBlur="if (this.value==\'\') this.value=\'' . $txt['sbox_TypeShout'] . '\';" />&nbsp;<input type="submit" class="input" value="&nbsp;shout&nbsp;" />';
}
echo '
</form>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
document.sbox.sboxText.value = \'' . $txt['sbox_TypeShout'] . '\';
// ]]></script>
</td>
</tr>';

View File

@ -70,6 +70,19 @@ function locked_filewrite($filename, $data, $timeLimit = 300000, $staleAge = 5)
}
// END: BORROWED FROM http://de2.php.net/manual/en/function.flock.php
function missinghtmlentities($text) {
// entitify missing characters, ignore entities already there (Unicode / UTF8) (hopefully in &#123;-notation)
$split = preg_split('/(&#[\d]+;)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$result = '';
foreach ($split as $s) {
if (substr($s, 0, 2) != '&#' || substr($s, -1, 1) != ';') {
$result .= htmlentities($s, ENT_NOQUOTES, $context['character_set']);
} else {
$result .= $s;
}
}
return $result;
}
//display html header
echo '<html xmlns="http://www.w3.org/1999/xhtml"' . ($context['right_to_left']?' dir="rtl"':'') . '>
@ -81,7 +94,7 @@ $row = mysql_fetch_assoc($result);
$refreshBlocked = false;
$delta = time() - $row['time'];
if ((!empty($_REQUEST['action'])) && ($_REQUEST['action'] == 'write')) $dontblock = true; else $dontblock = false;
if (($delta > $modSettings['lastActive']*60) && ($modSettings['sbox_BlockRefresh'] == '1') && (!$dontblock)) {
if (($delta > $modSettings['lastActive']*60) && ($modSettings['sbox_BlockRefresh'] == '1') && (!$dontblock)) {
$refreshBlocked = true;
} else {
echo '
@ -117,7 +130,10 @@ echo '
}
body {
padding: 0px 0px 0px 0px;
width: 100%;
padding: 0;
margin: 0;
border: 0;
background-color: ' . $modSettings['sbox_BackgroundColor'] . ';
}
DIV.Even A[target="_blank"], DIV.Odd A[target="_blank"] {
@ -134,7 +150,7 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
case 'write':
if (((!$context['user']['is_guest']) || ($modSettings['sbox_GuestAllowed'] == '1')) && !empty($_REQUEST['sboxText'])) {
$content=$_REQUEST['sboxText'];
$content = $_REQUEST['sboxText'];
// get current timestamp
$date = time();
@ -161,23 +177,23 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
$content = stripslashes($content); // shouting content
$content = substr($content, 8);
$content = htmlentities($content);
$content = missinghtmlentities($content);
if ($modSettings['sbox_AllowBBC'] == '1' && ($context['user']['id'] > 0 || $modSettings['sbox_GuestBBC'] == '1')) {
$content = parse_bbc($content);
}
$output = '[&nbsp;' . $ds . '&nbsp;]&nbsp;<b>' . $sbox_NickPrefix;
if ($context['user']['id'] > 0) {
if ($context['user']['id'] > 0) {
$output .= '<a href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '" target="_blank" class="' . $divclass . '">';
$output .= ((!empty($context['user']['name']))?$context['user']['name']:$context['user']['username']);
$output .= '</a>';
} else {
$output .= 'Guest-' . base_convert($piph, 16, 36);
$output .= 'Guest-' . base_convert($piph, 16, 36);
}
$output .= $sbox_NickSuffix . '</b>&nbsp;' . $content . '</div><br />' . "\n";
if (!file_exists($sbox_HistoryFile)) {
// TODO: Prepare file ... HTML-header, stylesheet, etc.
// TODO: Prepare file ... HTML-header, stylesheet, etc.
}
locked_filewrite($sbox_HistoryFile, $output);
@ -191,10 +207,10 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
$lockDir = $sbox_HistoryFile . '.lock';
$start = time();
while ((is_dir($lockDir)) && ((time() - $start) < 5)) {
usleep(100000); // sleep 1/10th of a second (for a PC these are ages!)
usleep(100000); // sleep 1/10th of a second (for a PC these are ages!)
}
if (!is_dir($lockDir)) @unlink($sbox_HistoryFile);
}
if (!is_dir($lockDir)) @unlink($sbox_HistoryFile);
}
}
break;
@ -214,18 +230,18 @@ echo '
echo "\n" . '<div class="Odd"><b>[ ' . strftime($user_info['time_format'], forum_time(true)) . ' ]';
if ($refreshBlocked) {
echo ' [ <span class="Kill">' . $txt['sbox_RefreshBlocked'] . '</span> ]';
echo ' [ <span class="Kill">' . $txt['sbox_RefreshBlocked'] . '</span> ]';
}
echo '</b></div>';
if ($context['user']['is_admin']) {
if ($modSettings['sbox_DoHistory'] == '1') {
echo "\n" . '<div class="Odd">';
if (file_exists($sbox_HistoryFile)) {
if (file_exists($sbox_HistoryFile)) {
echo '[<a href="' . str_replace($boarddir, $boardurl, $sbox_HistoryFile) . '" target="_blank">' . $txt['sbox_History'] . '</a>]';
echo ' [<a href="' . $_SERVER['PHP_SELF'] . '?action=clearhist" class="Kill" onClick="return clearHist();">' . $txt['sbox_HistoryClear'] . '</a>]';
} else {
echo '[' . $txt['sbox_HistoryNotFound'] . ']';
echo '[' . $txt['sbox_HistoryNotFound'] . ']';
}
echo '</div>';
}
@ -259,28 +275,29 @@ if(mysql_num_rows($result)) {
$content = stripslashes($row['content']); // shouting content
$piph = substr($content, 0, 8);
$content = substr($content, 8);
$content = htmlentities($content);
if ($modSettings['sbox_AllowBBC'] == '1' && ($name > 0 || $modSettings['sbox_GuestBBC'] == '1')) {
censorText($content);
$content = missinghtmlentities($content);
if ($modSettings['sbox_AllowBBC'] == '1' && ($name > 0 || $modSettings['sbox_GuestBBC'] == '1')) {
$content = parse_bbc($content);
}
if (!empty($_REQUEST['ts']) && !$div && $date<$_REQUEST['ts']) {
if ($count > 0 && $modSettings['sbox_NewShoutsBar'] == '1') {
if ($count > 0 && $modSettings['sbox_NewShoutsBar'] == '1') {
echo '<hr>' . "\n";
}
$div = true;
}
if ($name != $lname) {
if ($name != $lname) {
$count++; // increase counter
}
$lname = $name;
// display shouting message and use a different color each second row
if ($count % 2 == 0) {
$divclass = 'Odd';
$divclass = 'Odd';
} else {
$divclass = 'Even';
$divclass = 'Even';
}
/* $r = $g = $b = 0;
@ -289,7 +306,7 @@ if(mysql_num_rows($result)) {
switch ($i % 3) {
case 0: $r += $x; break;
case 1: $g += $x; break;
case 2: $b += $x; break;
case 2: $b += $x; break;
}
}
$r = dechex($r % 192);
@ -303,7 +320,7 @@ if(mysql_num_rows($result)) {
echo "\n" . '<div class="' . $divclass . '" style="color: #' . $colh . '">'; */
echo "\n" . '<div class="' . $divclass . '">';
if ($context['user']['is_admin'] || ($modSettings['sbox_ModsRule'] && count(boardsAllowedTo('moderate_board'))>0)) {
if ($context['user']['is_admin'] || ($modSettings['sbox_ModsRule'] && count(boardsAllowedTo('moderate_board'))>0)) {
echo '[<a title="' . $txt['sbox_KillShout'] . '" class="Kill" onClick="return kill();" href="' . $_SERVER['PHP_SELF'] . '?action=kill&kill=' . $row['id'] . '">X</a>]';
}
@ -312,22 +329,22 @@ if(mysql_num_rows($result)) {
$ds = $wd . '&nbsp;|&nbsp;' . $ts;
// highlight username, realname and make sound
if (!empty($context['user']['name']) && strpos($content, $context['user']['name']) !== false) {
if (!empty($context['user']['name']) && strpos($content, $context['user']['name']) !== false) {
if ($div === false) $alert = true;
$content = str_replace($context['user']['name'], '<b><u>' . $context['user']['name'] . '</u></b>', $content);
}
if (!empty($user_info['username']) && $user_info['username'] != $context['user']['name'] && strpos($content, $user_info['username']) !== false) {
if ($div === false) $alert = true;
$content = str_replace($user_info['username'], '<b><u>' . $user_info['username'] . '</u></b>', $content);
$content = str_replace($user_info['username'], '<b><u>' . $user_info['username'] . '</u></b>', $content);
}
echo '[&nbsp;' . $ds . '&nbsp;]&nbsp;<b>' . $sbox_NickPrefix;
if ($name > 0) {
if ($name > 0) {
if ($modSettings['sbox_UserLinksVisible'] == '1') echo '<a href="' . $scripturl . '?action=profile;u=' . $name . '" target="_top" class="' . $divclass . '">';
echo ((!empty($row['realName']))?$row['realName']:$row['memberName']);
if ($modSettings['sbox_UserLinksVisible'] == '1') echo '</a>';
} else {
echo $txt['sbox_Guest'] . '-' . base_convert($piph, 16, 36);
echo $txt['sbox_Guest'] . '-' . base_convert($piph, 16, 36);
}
echo $sbox_NickSuffix . '</b>&nbsp;' . $content . '</div>';
}

View File

@ -76,6 +76,25 @@
</operation>
</file>
<!-- Edit BoardIndex.template.php in the blackTed Theme. -->
<file name="$themes_dir/blackTed/BoardIndex.template.php" error="skip">
<operation>
<search position="replace"><![CDATA[
}
/* Each category in categories is made up of:
]]></search>
<add><![CDATA[
}
// display shoutbox
if (function_exists('sbox')) sbox();
/* Each category in categories is made up of:
]]></add>
</operation>
</file>
<!-- Edit Subs.php and add sbox(). -->
<file name="$sourcedir/Subs.php">
<operation>