News:

Wondering if this will always be free?  See why free is better.

Main Menu

SMF Shoutbox

Started by Deep, March 15, 2006, 08:09:52 AM

Previous topic - Next topic

Deep

#80
Quote from: littleone
Can you specify the coding to be placed and where it needs to be placed to get the local time.
Please have a look on the file sboxDB.php in the package of version 1.05beta.

I want to explain the changes step by step.
First you need a new designed database table to store the shout contents. In this new table the field time (varchar(25)) is changed to shouttime (int(11)) to store a timestamp instead of a string which contains a text with the time. The PHP command to create this table is:

$result = mysql_query("
CREATE TABLE {$db_prefix}sbox_messages
(id int(11) NOT NULL auto_increment,
shouttime int(11) NOT NULL default '',
name varchar(80) NOT NULL default '',
content text NOT NULL,
PRIMARY KEY (id)) TYPE=MyISAM;");


Now in sboxDB.php you have to replace the following code:

// insert shout message into database
$sql = "insert into ".$db_prefix."sbox_content (name,content,time) values ('".$user_info['username']."','".$content."','$date')";
db_query($sql,__FILE__,__LINE__);

// delete old shout messages (get id of last shouting and delete all shoutings as defined in settings
$result = db_query("select id from ".$db_prefix."sbox_content where name='".$user_info['username']."' and content='".$content."' and time='$date'",__FILE__,__LINE__);
$rows = mysql_fetch_assoc($result) ;
$sql = "delete from ".$db_prefix."sbox_content where id < '".($rows["id"]-$modSettings['sbox_MaxLines'])."'";
db_query($sql,__FILE__,__LINE__);


with:

$time=time();

// insert shout message into database
$sql = "insert into ".$db_prefix."sbox_messages (name,content,shouttime) values ('".$user_info['username']."','".$content."','".$time."')";
db_query($sql,__FILE__,__LINE__);

// delete old shout messages (get id of last shouting and delete all shoutings as defined in settings)
$result = db_query("select id from ".$db_prefix."sbox_messages where name='".$user_info['username']."' and content='".$content."' and shouttime='$time'",__FILE__,__LINE__);
$rows = mysql_fetch_assoc($result) ;
$sql = "delete from ".$db_prefix."sbox_messages where id < '".($rows["id"]-$modSettings['sbox_MaxLines'])."'";
db_query($sql,__FILE__,__LINE__);


Now there is a timestamp written to the database.
To display it, you have to replace in sboxDB.php the following code:

// get shout messages out of database
$result = db_query("select * from ".$db_prefix."sbox_content order by id desc, time asc limit ".$modSettings['sbox_MaxLines'],__FILE__,__LINE__);
if(mysql_num_rows($result))
{
$count=0; // counter to distinguish font color
while($row = mysql_fetch_assoc($result))
{
$count = $count + 1; // increase counter
$name = $row["name"]; // user name
$date = $row["time"]; // shouting date and time
$content = stripslashes($row['content']); // shouting content

// replace smilie code with path to smilie image
$content = str_replace ($txt['sbox_smilie01_code'], '<img src="'.$imgdir.$txt['sbox_smilie01_file'].'" alt="'.$txt['sbox_smilie01_text'].'" title="'.$txt['sbox_smilie01_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie02_code'], '<img src="'.$imgdir.$txt['sbox_smilie02_file'].'" alt="'.$txt['sbox_smilie02_text'].'" title="'.$txt['sbox_smilie02_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie03_code'], '<img src="'.$imgdir.$txt['sbox_smilie03_file'].'" alt="'.$txt['sbox_smilie03_text'].'" title="'.$txt['sbox_smilie03_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie04_code'], '<img src="'.$imgdir.$txt['sbox_smilie04_file'].'" alt="'.$txt['sbox_smilie04_text'].'" title="'.$txt['sbox_smilie04_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie05_code'], '<img src="'.$imgdir.$txt['sbox_smilie05_file'].'" alt="'.$txt['sbox_smilie05_text'].'" title="'.$txt['sbox_smilie05_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie06_code'], '<img src="'.$imgdir.$txt['sbox_smilie06_file'].'" alt="'.$txt['sbox_smilie06_text'].'" title="'.$txt['sbox_smilie06_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie07_code'], '<img src="'.$imgdir.$txt['sbox_smilie07_file'].'" alt="'.$txt['sbox_smilie07_text'].'" title="'.$txt['sbox_smilie07_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie08_code'], '<img src="'.$imgdir.$txt['sbox_smilie08_file'].'" alt="'.$txt['sbox_smilie08_text'].'" title="'.$txt['sbox_smilie08_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie09_code'], '<img src="'.$imgdir.$txt['sbox_smilie09_file'].'" alt="'.$txt['sbox_smilie09_text'].'" title="'.$txt['sbox_smilie09_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie10_code'], '<img src="'.$imgdir.$txt['sbox_smilie10_file'].'" alt="'.$txt['sbox_smilie10_text'].'" title="'.$txt['sbox_smilie10_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie11_code'], '<img src="'.$imgdir.$txt['sbox_smilie11_file'].'" alt="'.$txt['sbox_smilie11_text'].'" title="'.$txt['sbox_smilie11_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie12_code'], '<img src="'.$imgdir.$txt['sbox_smilie12_file'].'" alt="'.$txt['sbox_smilie12_text'].'" title="'.$txt['sbox_smilie12_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie13_code'], '<img src="'.$imgdir.$txt['sbox_smilie13_file'].'" alt="'.$txt['sbox_smilie13_text'].'" title="'.$txt['sbox_smilie13_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie14_code'], '<img src="'.$imgdir.$txt['sbox_smilie14_file'].'" alt="'.$txt['sbox_smilie14_text'].'" title="'.$txt['sbox_smilie14_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie15_code'], '<img src="'.$imgdir.$txt['sbox_smilie15_file'].'" alt="'.$txt['sbox_smilie15_text'].'" title="'.$txt['sbox_smilie15_text'].'" border="0" />', $content);

// display shouting message and use a different color each second row
if ($count % 2)
echo '
<div class="OddLine">';
else
echo '
<div class="EvenLine">';
if ($context['user']['is_admin'])
echo '<a title="'.$txt['sbox_KillShout'].'" class="Kill" onclick="return killYesNo();" href="sboxDB.php?action=kill&kill='.$row['id'].'">[X]</a>';

echo '[&nbsp;'.$date.'&nbsp;]&nbsp;<b>&lt;'.$name.'&gt;</b>&nbsp;'.$content.'</div>';
}


with:

// get shout messages out of database
$result = db_query("select id,name,shouttime,content from ".$db_prefix."sbox_messages order by id desc, shouttime asc limit ".$modSettings['sbox_MaxLines'],__FILE__,__LINE__);
if(mysql_num_rows($result))
{
$count=0; // counter to distinguish font color
while($row = mysql_fetch_assoc($result))
{
$count = $count + 1; // increase counter
$name = $row["name"]; // user name
$shouttime = $row["shouttime"]; // shouting date and time
$content = stripslashes($row['content']); // shouting content

$time=$shouttime;

// replace smilie code with path to smilie image
$content = str_replace ($txt['sbox_smilie01_code'], '<img src="'.$imgdir.$txt['sbox_smilie01_file'].'" alt="'.$txt['sbox_smilie01_text'].'" title="'.$txt['sbox_smilie01_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie02_code'], '<img src="'.$imgdir.$txt['sbox_smilie02_file'].'" alt="'.$txt['sbox_smilie02_text'].'" title="'.$txt['sbox_smilie02_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie03_code'], '<img src="'.$imgdir.$txt['sbox_smilie03_file'].'" alt="'.$txt['sbox_smilie03_text'].'" title="'.$txt['sbox_smilie03_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie04_code'], '<img src="'.$imgdir.$txt['sbox_smilie04_file'].'" alt="'.$txt['sbox_smilie04_text'].'" title="'.$txt['sbox_smilie04_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie05_code'], '<img src="'.$imgdir.$txt['sbox_smilie05_file'].'" alt="'.$txt['sbox_smilie05_text'].'" title="'.$txt['sbox_smilie05_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie06_code'], '<img src="'.$imgdir.$txt['sbox_smilie06_file'].'" alt="'.$txt['sbox_smilie06_text'].'" title="'.$txt['sbox_smilie06_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie07_code'], '<img src="'.$imgdir.$txt['sbox_smilie07_file'].'" alt="'.$txt['sbox_smilie07_text'].'" title="'.$txt['sbox_smilie07_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie08_code'], '<img src="'.$imgdir.$txt['sbox_smilie08_file'].'" alt="'.$txt['sbox_smilie08_text'].'" title="'.$txt['sbox_smilie08_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie09_code'], '<img src="'.$imgdir.$txt['sbox_smilie09_file'].'" alt="'.$txt['sbox_smilie09_text'].'" title="'.$txt['sbox_smilie09_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie10_code'], '<img src="'.$imgdir.$txt['sbox_smilie10_file'].'" alt="'.$txt['sbox_smilie10_text'].'" title="'.$txt['sbox_smilie10_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie11_code'], '<img src="'.$imgdir.$txt['sbox_smilie11_file'].'" alt="'.$txt['sbox_smilie11_text'].'" title="'.$txt['sbox_smilie11_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie12_code'], '<img src="'.$imgdir.$txt['sbox_smilie12_file'].'" alt="'.$txt['sbox_smilie12_text'].'" title="'.$txt['sbox_smilie12_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie13_code'], '<img src="'.$imgdir.$txt['sbox_smilie13_file'].'" alt="'.$txt['sbox_smilie13_text'].'" title="'.$txt['sbox_smilie13_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie14_code'], '<img src="'.$imgdir.$txt['sbox_smilie14_file'].'" alt="'.$txt['sbox_smilie14_text'].'" title="'.$txt['sbox_smilie14_text'].'" border="0" />', $content);
$content = str_replace ($txt['sbox_smilie15_code'], '<img src="'.$imgdir.$txt['sbox_smilie15_file'].'" alt="'.$txt['sbox_smilie15_text'].'" title="'.$txt['sbox_smilie15_text'].'" border="0" />', $content);

// Offset the time.
$time = $time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
if ($time < 0)
$time = 0;

// get actual weekday
$days = array($txt['sbox_Sunday'],$txt['sbox_Monday'],$txt['sbox_Tuesday'],$txt['sbox_Wednesday'],$txt['sbox_Thurday'],$txt['sbox_Friday'],$txt['sbox_Saturday']);
$day=$days[date("w",$time)]; // weekday
$date=$day." | ". date("G:i",$time); // time

// display shouting message and use a different color each second row
if ($count % 2)
echo '
<div class="OddLine">';
else
echo '
<div class="EvenLine">';
if ($context['user']['is_admin'])
echo '<a title="'.$txt['sbox_KillShout'].'" class="Kill" onclick="return killYesNo();" href="sboxDB.php?action=kill&kill='.$row['id'].'">[X]</a>';

echo '[&nbsp;'.$date.'&nbsp;]&nbsp;<b>&lt;'.$name.'&gt;</b>&nbsp;'.$content.'</div>';
}


It seems to be easier if you just replace your sboxDB.php with that one out of the 1.05beta package.


Quote from: x0joshua0x
Is there a way to make the username show as the persons display name instead of the account name.
I know there of course is a way to display the persons display name instead of the account name, but i don´t have experiences with this part of SMF.
I can not guarantee that it works, but try to replace in sboxDB.php any occurany of:

$user_info['username']


with:

$context['member']['name']

Does it work?


Quote from: littleone
Id also like to see membergroup specific permissions so that I can grant my moderators the ability to delete shouts.
I am sorry, but i do not have the time to do that.
I have no experience with this part of SMF.
I can not guarantee that it works, but if you want all moderators to be able to delete shouts, try to replace in sboxDB.php any occurany of:

$context['user']['is_admin']


with:

allowedTo('moderate_forum')


@x0joshua0x:
@littleone:
It seems to be a good idea if you ask some more experienced SMF coders to answer your questions. In both cases i can tell you what to replace, but i am not sure if i told you the right replacement.

However, have a happy sunday! :-)

Deep

littleone

Quote from: Deep on May 21, 2006, 08:02:20 AM

I want to explain the changes step by step.
First you need a new designed database table to store the shout contents. In this new table the field time (varchar(25)) is changed to shouttime (int(11)) to store a timestamp instead of a string which contains a text with the time. The PHP command to create this table is:

$result = mysql_query("
CREATE TABLE {$db_prefix}sbox_messages
(id int(11) NOT NULL auto_increment,
shouttime int(11) NOT NULL default '',
name varchar(80) NOT NULL default '',
content text NOT NULL,
PRIMARY KEY (id)) TYPE=MyISAM;");



Can you be more specific on this?  I don't quite understand what you mean by this.  What should the table be called, how do I create it, where does that code go?  anything will help, you've been a great help so far :)

littleone

disregard that.   I was able to figure it out and even learned something new :)

littleone

Quote from: Deep on May 21, 2006, 08:02:20 AM
Quote from: littleone
Id also like to see membergroup specific permissions so that I can grant my moderators the ability to delete shouts.
I am sorry, but i do not have the time to do that.
I have no experience with this part of SMF.
I can not guarantee that it works, but if you want all moderators to be able to delete shouts, try to replace in sboxDB.php any occurany of:

$context['user']['is_admin']


with:

allowedTo('moderate_forum')



Ok this worked fantastically except there is a case of sbox_content that also needs to be changed to sbox_messages.  It appears after the second "$context['user']['is_admin']"

At first it wasnt working so I went back and looked and that was the problem.  Just so you know for future reference and anyone else who might want to do this.


kriskd

#84
Local time and showing display name are no longer of any importance to me.  I was struggling to get the Users Online Today working and in the process broke my wonderful shoutbox.  Here's a screen shot of it.  The texting works fine, but not the smileys:

Image Removed

And here's a sample error from my error log.  Can anyone assist me with this?


Apply Filter: Only show the error messages of this URL  http://www.sprechereast.com/forum/index.php
Apply Filter: Only show the errors with the same message
8: Undefined index: sbox_smilie15_code
File: /home/.cutiekins/sprechereast/sprechereast.com/forum/Themes/default/sbox.template.php (eval?)
Line: 66
SMF 2.0.2

kriskd

At this point I think I need to uninstall the shoutbox and start over, but when I go into the package manager and click uninstall I get the following:

Error in Package Installation
At least one error was encountered during a test installation of this package. It is strongly recommended that you do not continue with installation unless you know what you are doing, and have made a backup very recently. This error may be caused by a conflict between the package you're trying to install and another package you have already installed, an error in the package, a package which requires another package that you don't have installed yet, or a package designed for another version of SMF.

Obviously, I'm a bit gun shy on proceeding.  Any help is appreciated.

I'm using SMF 1.1 RC2
SMF 2.0.2

littleone

Go ahead and uninstall it, regardless of what the test says.  On the file that the test failed, you will need to go into that file and remove the remaining coding (relevant to the shout box) yourself from that file.  Then do a clean install.

kriskd

#87
Quote from: littleone on May 21, 2006, 12:11:16 PM
Go ahead and uninstall it, regardless of what the test says.  On the file that the test failed, you will need to go into that file and remove the remaining coding (relevant to the shout box) yourself from that file.  Then do a clean install.

Modifications.english.php and Modsettings.php are failing.  The first one is just a tiny file that I added some things too.  The second file would have been updated when I installed the shoutbox.  Could I just replace the file on the server with the original file I have locally?  Also, I have a few other mods installed.  I imagine restoring Modsettings.php could potentially cause them not to work.

And what about Boardindex?  Can that stay as is with the shoutbox code in it.  Will it hurt anything?  And what about sboxDB.php in Sources.  Do I need to do anything with that?

Sorry about the million questions... this is just quite scary for me.
SMF 2.0.2

littleone

I would recommend downloading a new version of the sbox and find the codes and remove them from the "Test Failed" files.  You might have simply removed a , or a > in there somewhere which will cause a test failed as its looking for the EXACT code, so I would suggest doing the uninstall anyway and then cleaning out the effected codes in the "Test Failed" files.

Doing a the uninstall will be best.  Just trying to play with replacing certain files can start to effect other things.  As far as the boardindex, if that wasnt set in the original install then it shouldnt be effected now.

The sboxDB would be removed in the install, and reinstalled so you wouldnt need to do anything

kriskd

The uninstall was successful, thank goodness!

Could I just try a re-install and see what happens?  I never manually updated Modsettings.php at all so there shouldn't have been any human changes there.  Modifications.english.php is just a tiny file that is easy enough to restore.

Let me know if you think it's safe enough just to do a fresh install.
SMF 2.0.2

littleone

I would say absolutely no.  You should go in and manually make sure no codes relating the the shout box exist.  other wise you will duplicate the codes.  Meaning some things might show up multiple times.  Like the day or the posts might show up 2 + times and its will be a pain to go back in.  In addition if some code was replaced in stead of added to, your install in will not be sucessful because the original code no longer exists.  I am not sure if this is the case, but its not worth the risk.

When I first started playing with SMF I made alot of these same mistakes.

kriskd

Okay, I just used MS-Word to compare what what was on my server to the original file for ModSettings.  Don't worry, of course I won't save anything within Word.  There were some additional fields for profile settings because I installed the custom profile fields mod.  Then I found this big chunk of code that appears to be specific for the shoutbox:


function ModifySboxSettings()
{
global $txt, $scripturl, $context, $settings, $sc;

$config_vars = array
(
array('check', 'sbox_Visible'),
array('check', 'sbox_GuestAllowed'),
array('check', 'sbox_SmiliesVisible'),
array('int', 'sbox_MaxLines'),
array('int', 'sbox_Height'),
array('int', 'sbox_RefreshTime'),
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(
'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_TextSize1', array(
'8px' => '8xp',
'9px' => '9xp',
'10px' => '10xp',
'11px' => '11xp',
'12px' => '12xp',
'13px' => '13xp',
'14px' => '14xp',
'15px' => '15xp',
'16px' => '16xp',
'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_TextColor1'),
array('select', 'sbox_TextSize2', array(
'8px' => '8xp',
'9px' => '9xp',
'10px' => '10xp',
'11px' => '11xp',
'12px' => '12xp',
'13px' => '13xp',
'14px' => '14xp',
'15px' => '15xp',
'16px' => '16xp',
'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_TextColor2'),
array('text', 'sbox_BackgroundColor')
);

// Saving?
if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=featuresettings;sa=sbox');
}

$context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=sbox';
$context['settings_title'] = $txt['sbox_ModTitle'];

prepareDBSettingContext($config_vars);
}


Does it look like everything there?  Did I miss a comman, semi-colon, whatever?  Should I delete that bit, upload the file, ensure it works and then try to re-install the shoutbox?  Are there any other Sources or Themes files I need to check for shoutbox code?

Thanks again to littleone and anyone else who can help.
SMF 2.0.2

littleone

I would suggest your remove the custom profile mod and then remove whatever coding you have to.  You can always add the custom profile stuff back again after you get the shout box fixed.  The custom profile fields is a rather simple mod.

kriskd

I did as you suggested and uninstalled the custom profile mod.  I then uploaded a fresh copy of ModSettings.php and attempted to re-install the SMF shoutbox and got the same result as in my screen shot from several posts back.  :(  However, at least when I uninstalled it, I didn't have any errors so it appears to have uninstalled correctly.  I'm at a loss here as to how to get it working.
SMF 2.0.2

kriskd

To add to this mystery, I got this mod working perfectly on my test forum along with 5 other mods.  Is there anyway I can copy the working files from that domain to my real domain?
SMF 2.0.2

kriskd

Well, folks, I am seriously thinking of backing up my db, wiping this message board and doing a fresh install.  To add to my problems, my ignore boards mod is showing errors in my error log.
SMF 2.0.2

PostThis

I cannot thank you enough for this mod!

It did not install correctly on the first try, but I read through this thread and found the solution. Clickety-click, it works!

It's absolutely fabulous, the interface is perfect, everything works like it's supposed to and with the instructions you posted, I made it work on other skins as well.

Love it, two thumbs up!  :) :) :) :)

x0joshua0x

@Deep
thnx 4 the quick response, i tried the suggested fix but it did not work, after messing around a bit i did manage to get it here is what i did:

just replaced in shoutDB.php

$user_info['username']

with:

$user_info['name']

and it worked like a charm :)

thnx 4 the mod

cheers

squirrelof09

QuoteSorry, but i don´t have the time to do so. Why do you want some users to be able to shout and others not?

Well, better say..

If a user is on the ban list they shall not be able to shout.

Edit: do you think it is possable to limit the maximum size in submitted Images in the shout box?

or have a page in Features in Options that lets you disable certain bbc code?

kriskd

Another question now that I have this working on my site once again.  Is there a way to turn off the refresh completely?
SMF 2.0.2

Advertisement: