Archived
1
0

+ added UPGRADE feature - Package Manager shows an error for some file - ignore that!

! It's because PM checks mods against current file. Upgrade works by removing old changes from current file and applying new changes - which can't be applied as long as the old changes are still there - that's why PM shows that error.
+ more configuration variables in sboxDB.php
+ made background and text color of sbox theme-dependent. Alternating colors can be specified in settings for bright and dark themes - should work for all themes where there's a properly set windowbg2-class
* rewrote uninstall-code to SMF-package-sdk-example
This commit is contained in:
mbirth 2006-09-05 09:43:37 +00:00
parent 093eb52301
commit 7be9d6d99a
8 changed files with 295 additions and 224 deletions

View File

@ -5,6 +5,7 @@
<id>Deep:SMF_Shoutbox</id>
<type>modification</type>
<version>1.14</version>
<install for="1.1 RC2, 1.1 RC3">
<require-file name="sbox.php" destination="$sourcedir" />
<require-file name="sboxDB.php" destination="$sourcedir" />
@ -23,8 +24,70 @@
]]></readme>
<modification type="file">sbox_latest.xml</modification>
</install>
<upgrade from="1.10" for="1.1 RC2, 1.1 RC3">
<readme type="inline"><![CDATA[Thanks for trying the shiny new update feature. Although the Package manager might show you an error, the upgrade should work.
PLEASE UNINSTALL ANY LANGUAGE PACK FOR SHOUTBOX BEFORE UPGRADING!]]></readme>
<modification type="file" reverse="true" format="boardmod">sbox_110.mod</modification>
<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_upgrade.php</code>
<modification type="file">sbox_latest.xml</modification>
</upgrade>
<upgrade from="1.11" for="1.1 RC2, 1.1 RC3">
<readme type="inline"><![CDATA[Thanks for trying the shiny new update feature. Although the Package manager might show you an error, the upgrade should work.
PLEASE UNINSTALL ANY LANGUAGE PACK FOR SHOUTBOX BEFORE UPGRADING!]]></readme>
<modification type="file" reverse="true" format="boardmod">sbox_111.mod</modification>
<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_upgrade.php</code>
<modification type="file">sbox_latest.xml</modification>
</upgrade>
<upgrade from="1.12" for="1.1 RC2, 1.1 RC3">
<readme type="inline"><![CDATA[Thanks for trying the shiny new update feature. Although the Package manager might show you an error, the upgrade should work.
PLEASE UNINSTALL ANY LANGUAGE PACK FOR SHOUTBOX BEFORE UPGRADING!]]></readme>
<modification type="file" reverse="true" format="boardmod">sbox_112.mod</modification>
<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_upgrade.php</code>
<modification type="file">sbox_latest.xml</modification>
</upgrade>
<upgrade from="1.13" for="1.1 RC2, 1.1 RC3">
<readme type="inline"><![CDATA[Thanks for trying the shiny new update feature. Although the Package manager might show you an error, the upgrade should work.
PLEASE UNINSTALL ANY LANGUAGE PACK FOR SHOUTBOX BEFORE UPGRADING!]]></readme>
<modification type="file" reverse="true" format="boardmod">sbox_113.mod</modification>
<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_upgrade.php</code>
<modification type="file">sbox_latest.xml</modification>
</upgrade>
<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>
<readme type="inline">Uninstall will remove all the changes made by the shoutbox.</readme>
<modification type="file" reverse="true">sbox_latest.xml</modification>
<remove-file name="$sourcedir/sbox.php" />
<remove-file name="$sourcedir/sboxDB.php" />

View File

@ -4,7 +4,7 @@
$txt['sbox_ModTitle'] = 'SMF Shoutbox';
$txt['sbox_KillShout'] = 'Do you want to kill this shout?';
$txt['sbox_Refresh'] = 'Refresh';
$txt['sbox_RefreshBlocked'] = 'Automatic refresh disabled due to inactivity';
$txt['sbox_RefreshBlocked'] = '[<span class="Kill">Automatic refresh disabled due to inactivity</span>]';
$txt['sbox_History'] = 'History';
$txt['sbox_HistoryClear'] = 'Clear history';
$txt['sbox_HistoryNotFound'] = 'No history found.';
@ -31,12 +31,10 @@ $txt['sbox_RefreshTime'] = 'Refresh time (secs)';
$txt['sbox_BlockRefresh'] = 'Block Refresh after inactivity (' . $modSettings['lastActive'] . ' mins)';
$txt['sbox_EnableSounds'] = 'Enable sounds';
$txt['sbox_FontFamily1'] = '1. Font family';
$txt['sbox_FontFamily2'] = '2. Font family';
$txt['sbox_TextSize1'] = '1. Font size';
$txt['sbox_TextColor1'] = '1. Font color';
$txt['sbox_TextSize2'] = '2. Font size';
$txt['sbox_TextColor2'] = '2. Font color';
$txt['sbox_BackgroundColor'] = 'Background color';
$txt['sbox_FontFamily'] = 'Font family';
$txt['sbox_TextSize'] = 'Font size';
$txt['sbox_TextColor1'] = '2. Font color for light themes';
$txt['sbox_DarkThemes'] = 'List of dark themes<div class="smalltext">(Directory names separated by vertical line, e.g. "BlackDaySMF1|blood_and_black")</div>';
$txt['sbox_TextColor2'] = '2. Font color for dark themes';
?>

View File

@ -4,7 +4,7 @@
$txt['sbox_ModTitle'] = 'SMF Shoutbox';
$txt['sbox_KillShout'] = 'Diesen Shout löschen?';
$txt['sbox_Refresh'] = 'Neu laden';
$txt['sbox_RefreshBlocked'] = 'Automatische Aktualisierung wegen Inaktivit&auml;t ausgeschaltet';
$txt['sbox_RefreshBlocked'] = '[<span class="Kill">Automatische Aktualisierung wegen Inaktivit&auml;t ausgeschaltet</span>]';
$txt['sbox_History'] = 'Verlauf';
$txt['sbox_HistoryClear'] = 'Verlauf l&ouml;schen';
$txt['sbox_HistoryNotFound'] = 'Kein Verlauf gefunden.';
@ -31,12 +31,10 @@ $txt['sbox_RefreshTime'] = 'Aktualisierungsintervall (sec)';
$txt['sbox_BlockRefresh'] = 'Aktualisierung nach Inaktivit&auml;t stoppen (' . $modSettings['lastActive'] . ' min)';
$txt['sbox_EnableSounds'] = 'Kl&auml;nge abspielen';
$txt['sbox_FontFamily1'] = '1. Schriftart';
$txt['sbox_FontFamily2'] = '2. Schriftart';
$txt['sbox_TextSize1'] = '1. Schriftgr&ouml;&szlig;e';
$txt['sbox_TextColor1'] = '1. Schriftfarbe';
$txt['sbox_TextSize2'] = '2. Schriftgr&ouml;&szlig;e';
$txt['sbox_TextColor2'] = '2. Schriftfarbe';
$txt['sbox_BackgroundColor'] = 'Hintergrundfarbe';
$txt['sbox_FontFamily'] = 'Schriftart';
$txt['sbox_TextSize'] = 'Schriftgr&ouml;&szlig;e';
$txt['sbox_TextColor1'] = '2. Schriftfarbe f&uuml;r helle Themes';
$txt['sbox_DarkThemes'] = 'Liste dunkler Themes<div class="smalltext">(Verzeichnisnamen getrennt durch "|", z.B. "BlackDaySMF1|blood_and_black")</div>';
$txt['sbox_TextColor2'] = '2. Schriftfarbe f&uuml;r dunkle Themes';
?>

View File

@ -9,21 +9,33 @@ if (!defined('SMF'))
die('Hacking attempt...');
loadLanguage('sbox');
/***[ BEGIN CONFIGURATION ]***************************************************/
$sbox_HistoryFile = $boarddir . '/sbox.history.html';
$sbox_NickPrefix = '&lt;';
$sbox_NickPrefix = '&lt;'; // this won't be linked to the profile page
$sbox_NickInnerPrefix = '<b>'; // this will be linked to the profile page, use formatting tags (<B>) here
$sbox_NickInnerSuffix = '</b>'; // so that they are applied inside the <A>, otherwise they won't work
$sbox_NickSuffix = '&gt;';
$sbox_DatePrefix = '[';
$sbox_DateSeparator = '&nbsp;'; // separates weekday from time
$sbox_DateSuffix = ']';
/***[ END CONFIGURATION ]*****************************************************/
// BEGIN: BORROWED FROM http://de2.php.net/manual/en/function.flock.php
/*
* I hope this is usefull.
* If mkdir() is atomic,
* then we do not need to worry about race conditions while trying to make the lockDir,
* unless of course were writing to NFS, for which this function will be useless.
* so thats why i pulled out the usleep(rand()) peice from the last version
* unless of course we're writing to NFS, for which this function will be useless.
* so thats why i pulled out the usleep(rand()) piece from the last version
*
* Again, its important to tailor some of the parameters to ones indivdual usage
* I set the default $timeLimit to 3/10th's of a second (maximum time allowed to achieve a lock),
* but if your writing some extrememly large files, and/or your server is very slow, you may need to increase it.
* but if you're writing some extrememly large files, and/or your server is very slow, you may need to increase it.
* Obviously, the $staleAge of the lock directory will be important to consider as well if the writing operations might take a while.
* My defaults are extrememly general and you're encouraged to set your own
*
@ -101,6 +113,14 @@ if (($delta > $modSettings['lastActive']*60) && ($modSettings['sbox_BlockRefresh
<meta http-equiv="refresh" content="' . $modSettings['sbox_RefreshTime'] . ';URL=sboxDB.php?ts=' . time() . '">';
}
$sbox_CurTheme = strtolower(substr($settings['theme_url'], strrpos($settings['theme_url'], '/')+1));
$sbox_DarkThemes = explode('|', strtolower($modSettings['sbox_DarkThemes']));
if (in_array($sbox_CurTheme, $sbox_DarkThemes)) {
$sbox_TextColor2 = $modSettings['sbox_TextColor2'];
} else {
$sbox_TextColor2 = $modSettings['sbox_TextColor1'];
}
echo '
<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/style.css?rc2" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
@ -111,22 +131,21 @@ echo '
if (parent && parent.document.sbox.ts) {
parent.document.sbox.ts.value = ' . forum_time(true) . ';
}
// if (parent.document.sbox.ts.value != ' . forum_time(true) . ') alert(\'Time mismatch! (\'+parent.document.sbox.ts.value+\' / ' . forum_time(true) . ')\');
// ]]></script>
<style type="text/css">
.Odd, A.Odd {
font-family: ' . $modSettings['sbox_FontFamily1'] . ';
.windowbg2 {
font-family: ' . $modSettings['sbox_FontFamily'] . ';
font-style: normal;
font-size: ' . $modSettings['sbox_TextSize1'] . ';
font-size: ' . $modSettings['sbox_TextSize'] . ';
font-weight: normal;
color: ' . $modSettings['sbox_TextColor1'] . ';
text-decoration: none;
}
.Even, A.Even {
font-family: ' . $modSettings['sbox_FontFamily2'] . ';
font-style: normal;
font-size: ' . $modSettings['sbox_TextSize2'] . ';
.Even {
color: ' . $sbox_TextColor2 . ';
font-weight: normal;
color: ' . $modSettings['sbox_TextColor2'] . ';
text-decoration: none;
}
body {
@ -134,12 +153,8 @@ echo '
padding: 0;
margin: 0;
border: 0;
background-color: ' . $modSettings['sbox_BackgroundColor'] . ';
}
DIV.Even A[target="_blank"], DIV.Odd A[target="_blank"] {
text-decoration: none;
color: blue;
}
.Kill, A.Kill {
color: #ff0000;
}
@ -173,7 +188,7 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
// write into history if needed
if ($modSettings['sbox_DoHistory'] == '1') {
$ds = date('Y-m-d', $date) . '&nbsp;|&nbsp;' . date('H:i.s', $date);
$ds = $sbox_DatePrefix . date('Y-m-d', $date) . $sbox_DateSeparator . date('H:i.s', $date) . $sbox_DateSuffix;
$content = stripslashes($content); // shouting content
$content = substr($content, 8);
@ -182,15 +197,15 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
$content = parse_bbc($content);
}
$output = '[&nbsp;' . $ds . '&nbsp;]&nbsp;<b>' . $sbox_NickPrefix;
$output = $ds . '&nbsp;' . $sbox_NickPrefix;
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 .= $sbox_NickInnerPrefix . ((!empty($context['user']['name']))?$context['user']['name']:$context['user']['username']) . $sbox_NickInnerSuffix;
$output .= '</a>';
} else {
$output .= 'Guest-' . base_convert($piph, 16, 36);
$output .= $sbox_NickInnerPrefix . 'Guest-' . base_convert($piph, 16, 36) . $sbox_NickInnerSuffix;
}
$output .= $sbox_NickSuffix . '</b>&nbsp;' . $content . '</div><br />' . "\n";
$output .= $sbox_NickSuffix . '&nbsp;' . $content . '</div><br />' . "\n";
if (!file_exists($sbox_HistoryFile)) {
// TODO: Prepare file ... HTML-header, stylesheet, etc.
@ -226,24 +241,24 @@ if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) {
// close header and open body
echo '
</head>
<body>';
<body class="windowbg2"><div class="windowbg2">';
echo "\n" . '<div class="Odd"><b>[ ' . strftime($user_info['time_format'], forum_time(true)) . ' ]';
echo "\n" . '<b>' . $sbox_DatePrefix . strftime($user_info['time_format'], forum_time(true)) . $sbox_DateSuffix;
if ($refreshBlocked) {
echo ' [ <span class="Kill">' . $txt['sbox_RefreshBlocked'] . '</span> ]';
echo ' ' . $txt['sbox_RefreshBlocked'];
}
echo '</b></div>';
echo '</b><br />';
if ($context['user']['is_admin']) {
if ($modSettings['sbox_DoHistory'] == '1') {
echo "\n" . '<div class="Odd">';
echo "\n";
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 '</div>';
echo '';
}
}
@ -295,7 +310,7 @@ if(mysql_num_rows($result)) {
// display shouting message and use a different color each second row
if ($count % 2 == 0) {
$divclass = 'Odd';
$divclass = 'windowbg2';
} else {
$divclass = 'Even';
}
@ -326,7 +341,7 @@ if(mysql_num_rows($result)) {
$wd = $txt['days_short'][date('w', $date)];
$ts = date('H:i', $date);
$ds = $wd . '&nbsp;|&nbsp;' . $ts;
$ds = $sbox_DatePrefix . $wd . $sbox_DateSeparator . $ts . $sbox_DateSuffix;
// highlight username, realname and make sound
if (!empty($context['user']['name']) && strpos($content, $context['user']['name']) !== false) {
@ -338,15 +353,15 @@ if(mysql_num_rows($result)) {
$content = str_replace($user_info['username'], '<b><u>' . $user_info['username'] . '</u></b>', $content);
}
echo '[&nbsp;' . $ds . '&nbsp;]&nbsp;<b>' . $sbox_NickPrefix;
echo $ds . '&nbsp;' . $sbox_NickPrefix;
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>';
if ($modSettings['sbox_UserLinksVisible'] == '1') echo '<a href="' . $scripturl . '?action=profile;u=' . $name . '" target="_top" style="text-decoration: none;"><span class="' . $divclass . '">';
echo $sbox_NickInnerPrefix . ((!empty($row['realName']))?$row['realName']:$row['memberName']) . $sbox_NickInnerSuffix;
if ($modSettings['sbox_UserLinksVisible'] == '1') echo '</span></a>';
} else {
echo $txt['sbox_Guest'] . '-' . base_convert($piph, 16, 36);
echo $sbox_NickInnerPrefix . $txt['sbox_Guest'] . '-' . base_convert($piph, 16, 36) . $sbox_NickInnerSuffix;
}
echo $sbox_NickSuffix . '</b>&nbsp;' . $content . '</div>';
echo $sbox_NickSuffix . '&nbsp;' . $content . '</div>';
}
if (($modSettings['sbox_EnableSounds']) && ($alert === true) && ($div === true)) {
echo '<embed src="' . $boardurl . '/chat-inbound_GSM.wav" hidden="true" autostart="true" loop="false"></embed>' . "\n";
@ -354,5 +369,6 @@ if(mysql_num_rows($result)) {
}
?>
</div>
</body>
</html>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "modification.dtd">
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is a modification file for SMF.
@ -136,6 +136,8 @@ $helptxt['sbox_RefreshTime'] = 'Here you can adjust the refresh time';
$helptxt['sbox_BlockRefresh'] = 'Defines whether the Shoutbox should stop refreshing after there have been no new shouts for a while. Users can still manually refresh the Shoutbox. The time treshold used is the <i>User online time treshold</i> found in the <i>Basic Features</i>-settings. (currently ' . $modSettings['lastActive'] . ' minutes)';
$helptxt['sbox_EnableSounds'] = 'Enables the notification sound, when your nickname was mentioned since the last refresh.';
$helptxt['sbox_DarkThemes'] = 'Enter all of your dark theme\'s directories separated by a vertical line. For those themes, every second shout will have the <i>2. Font color for dark themes</i> instead of that for light ones. It\'s your turn to find those two colors matching (or being readable in) all your themes.';
]]></add>
</operation>
</file>
@ -164,6 +166,8 @@ $helptxt['sbox_RefreshTime'] = 'Hier k&ouml;nnen Sie das Aktualisierungsinterval
$helptxt['sbox_BlockRefresh'] = 'Legt fest, ob die automatische Aktualisierung nach eine Weile Inaktivit&auml;t automatisch gestoppt werden soll. Benutzer k&ouml;nnen die Shoutbox weiterhin manuell aktualisieren. Die Zeitspanne wird unter <i>Zeit der Benutzeranzeige</i> in den <i>Standard-Funktionen</i> festgelegt. (Momentan ' . $modSettings['lastActive'] . ' Minuten)';
$helptxt['sbox_EnableSounds'] = 'Aktiviert einen Ton, der gespielt wird, wenn der eigene Nickname in einem neuen Shout auftaucht.';
$helptxt['sbox_DarkThemes'] = 'Geben Sie hier die Verzeichnisnamen Ihrer dunkleren Themen getrennt durch eine vertikale Linie an. F&uuml;r diese wird dann f&uuml;r jeden zweiten Shout die <i>2. Schriftfarbe f&uuml;r dunkle Themes</i> verwendet. Es liegt an Ihnen, eine Farbe zu finden, die in s&auml;mtlichen Ihrer dunklen Themen gut lesbar ist.';
]]></add>
</operation>
</file>
@ -225,18 +229,7 @@ function ModifySboxSettings() {
array('check', 'sbox_EnableSounds'),
'',
// Font stuff
array('select', 'sbox_FontFamily1', array(
'Garamond, serif' => 'Garamond, serif',
'Times, serif' => 'Times, serif',
'Arial, Helvetica, sans-serif' => 'Arial, Helvetica, sans-serif',
'Tahoma, Helvetica, sans-sarif' => 'Tahoma, Helvetica, sans-sarif',
'Verdana, sans-serif' => 'Verdana, sans-serif',
'cursive' => 'cursive',
'Palatino, fantasy' => 'Palatino, fantasy',
'Courier, monospace' => 'Courier, monospace',
),
),
array('select', 'sbox_FontFamily2', array(
array('select', 'sbox_FontFamily', array(
'Garamond, serif' => 'Garamond, serif',
'Times, serif' => 'Times, serif',
'Arial, Helvetica, sans-serif' => 'Arial, Helvetica, sans-serif',
@ -247,7 +240,7 @@ function ModifySboxSettings() {
'Courier, monospace' => 'Courier, monospace'
),
),
array('select', 'sbox_TextSize1', array(
array('select', 'sbox_TextSize', array(
'6pt' => '6pt',
'7pt' => '7pt',
'8pt' => '8pt',
@ -269,29 +262,8 @@ function ModifySboxSettings() {
),
),
array('text', 'sbox_TextColor1'),
array('select', 'sbox_TextSize2', array(
'6pt' => '6pt',
'7pt' => '7pt',
'8pt' => '8pt',
'9pt' => '9pt',
'10pt' => '10pt',
'11pt' => '11pt',
'12pt' => '12pt',
'13pt' => '13pt',
'14pt' => '14pt',
'15pt' => '15pt',
'16pt' => '16pt',
'xx-small' => 'xx-small',
'x-small' => 'x-small',
'small' => 'small',
'medium' => 'medium',
'large' => 'large',
'x-large' => 'x-large',
'xx-large' => 'xx-large'
),
),
array('text', 'sbox_DarkThemes'),
array('text', 'sbox_TextColor2'),
array('text', 'sbox_BackgroundColor'),
);
// Saving?

View File

@ -1,96 +1,42 @@
<?php
/******************************************************************************
* sbox_remove.php *
*******************************************************************************
* SMF: Simple Machines Forum - SMF Shoutbox MOD *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com) *
* =========================================================================== *
* Software Version: 1.04 *
* Software originally by: ? *
* Ported to SMF by: Deep, most code stolen from Matthew Wolf (Grudge) *
* Support, News, Updates at: http://www.simplemachines.org *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it *
* under the terms of the provided license as published by Lewis Media. *
* *
* This program is distributed in the hope that it is and will be useful, *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
* The latest version can always be found at http://www.simplemachines.org. *
******************************************************************************/
/*******************************************************************************
This is a simplified script to remove settings from SMF.
echo'
<html>
<head>
<title>SMF DataBase Editor - Ultimate Shoutbox</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<table border="0" cellspacing="1" cellpadding="4" bgcolor="#000000" width="90%">
<tr>
<th bgcolor="#34699E"><font color="#FFFFFF">SMF DB Editor - SMF-Shoutbox MOD - SQL UNINSTALL</font></th>
</tr>';
ATTENTION: If you are trying to UNINSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/sbox_remove.php (or similar.)
if (!isset($_REQUEST['sa']))
{
echo'
<tr>
<td bgcolor="#FFFFFF" align="center">
<font size="2"><a href="sbox_remove.php?sa=doit&man=yes">Click here to start shoutbox uninstallation</font></a><br /</td></tr></table>
';
}
else
{
echo '</table>';
================================================================================
if ((isset($_REQUEST['man'])) || (!isset($db_name)))
{
require_once (dirname(realpath($_SERVER['SCRIPT_FILENAME'])) . "/Settings.php");
$dbcon = mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name);
}
This script can be used to remove settings from the database for use
with SMF's $modSettings array. It is meant to be run either from the
package manager or directly by URL.
$error=0;
$shoutChunkSize = 350;
$timeLimitThreshold = 10;
$self = &$_SERVER['PHP_SELF'];
$start_time = time();
*******************************************************************************/
// Now time to make the new table
$result = mysql_query("DROP TABLE {$db_prefix}sbox_content;");
if (!$result)
{
echo "<font color=red>Error removing shoutbox table. SQL Error: ".mysql_error()."</font><BR />";
$error++;
}
else
echo "<font color=green>Shoutbox table deleted!</font><BR />";
// Type the settings prefix here
$mod_settings_prefix = 'sbox_';
$result = mysql_query("DELETE FROM {$db_prefix}settings WHERE variable LIKE 'sbox_%';");
if(!$result)
{
echo "<font color=red>Settings: ".mysql_error().".</font><br />";
$error++;
}
else
echo "<font color=green>Settings removed correctly!</font><br />";
/******************************************************************************/
$done = 1;
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot uninstall - please verify you put this in the same place as SMF\'s index.php.');
// Result
if (isset($done))
{
echo "</td></tr></table>";
if($error==0)
echo "<P>Downgrade of SQL was successfull.";
elseif ($error==1)
echo "<P>There was <B>one</B> error when downgrading your SQL.";
elseif ($error>1)
echo "<P>There were <B>$error</B> errors when downgrading your SQL.";
}
}
echo '</body></html>';
// drop table if it exists. Should make SMF-update 1.1rc2 -> 1.1rc3 easier.
$result = db_query("DROP TABLE `{$db_prefix}sbox_content`", __FILE__, __LINE__);
// Uh-oh spaghetti-oh!
if ($result === false)
echo '<b>Error:</b> Table drop failed!<br />';
$result = db_query("DELETE FROM `{$db_prefix}settings` WHERE variable LIKE '{$mod_settings_prefix}%'", __FILE__, __LINE__);
// Uh-oh spaghetti-oh!
if ($result === false)
echo '<b>Error:</b> Settings removal failed!<br />';
?>

View File

@ -38,13 +38,11 @@ $mod_settings = array(
'sbox_BlockRefresh' => '1',
'sbox_EnableSounds' => '0',
'sbox_FontFamily1' => 'Verdana, sans-serif',
'sbox_FontFamily2' => 'Verdana, sans-serif',
'sbox_TextSize1' => 'xx-small',
'sbox_TextColor1' => '#000000',
'sbox_TextSize2' => 'xx-small',
'sbox_TextColor2' => '#476c8e',
'sbox_BackgroundColor' => '#e5e5e8',
'sbox_FontFamily' => 'Verdana, sans-serif',
'sbox_TextSize' => 'xx-small',
'sbox_TextColor1' => '#476c8e',
'sbox_DarkThemes' => 'BlackDaySMF1|blood_and_black',
'sbox_TextColor2' => '#c7d6e2',
);
/******************************************************************************/

80
sbox_upgrade.php Normal file
View File

@ -0,0 +1,80 @@
<?php
/*******************************************************************************
This is a simplified script to add settings into SMF.
ATTENTION: If you are trying to INSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/add_settings.php (or similar.)
================================================================================
This script can be used to add new settings into the database for use
with SMF's $modSettings array. It is meant to be run either from the
package manager or directly by URL.
*******************************************************************************/
// Set the below to true to overwrite already existing settings with the defaults. (not recommended.)
$overwrite_old_settings = false;
// List settings here in the format: setting_key => default_value. Escape any "s. (" => \")
$mod_settings = array(
'sbox_Visible' => '1',
'sbox_ModsRule' => '0',
'sbox_DoHistory' => '1',
'sbox_GuestVisible' => '0',
'sbox_GuestAllowed' => '0',
'sbox_GuestBBC' => '0',
'sbox_SmiliesVisible' => '1',
'sbox_UserLinksVisible' => '1',
'sbox_AllowBBC' => '1',
'sbox_NewShoutsBar' => '1',
'sbox_MaxLines' => '50',
'sbox_Height' => '180',
'sbox_RefreshTime' => '20',
'sbox_BlockRefresh' => '1',
'sbox_EnableSounds' => '0',
'sbox_FontFamily' => 'Verdana, sans-serif',
'sbox_TextSize' => 'xx-small',
'sbox_TextColor1' => '#476c8e',
'sbox_DarkThemes' => 'BlackDaySMF1|blood_and_black',
'sbox_TextColor2' => '#c7d6e2',
);
/******************************************************************************/
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
// Turn the array defined above into a string of MySQL data.
$string = '';
foreach ($mod_settings as $k => $v)
$string .= '
(\'' . $k . '\', \'' . $v . '\'),';
// Sorted out the array defined above - now insert the data!
if ($string != '')
$result = db_query("
" . ($overwrite_old_settings ? 'REPLACE' : 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" . substr($string, 0, -1), __FILE__, __LINE__);
// Uh-oh spaghetti-oh!
if ($result === false)
echo '<b>Error:</b> Settings insertion failed!<br />';
if (file_exists($sourcedir . '/sboxDB.php')) {
$result = chmod($sourcedir . '/sboxDB.php', 0644);
if ($result === false)
echo '<b>Error:</b> CHMOD for sboxDB.php failed!<br />';
}
?>