Page 1 of 1

shoutbox

Posted: Fri Aug 27, 2004 2:16 am
by AzNBlade001
I have installed the newest version of cms made simple multi language. I have just found the advertising iframe before website content.  It is like this:where post_id = 112388;
";

Re: shoutbox

Posted: Sun Jan 11, 2009 2:12 am
by joerns
I've built a shoutbox but this one is for the backend, doesn't use any database and my coding style could be much better :)
I include it in index.php and it does a good job since it makes it possible to leave messages for other admins.
Perhaps someone can build something useful out of it ??? Well, I don't think so but you can try...

[Edit]The second PHP tag ist missing. Worked nevertheless...

Re: shoutbox

Posted: Sun Jan 11, 2009 6:15 pm
by joerns
Where?

Re: shoutbox

Posted: Sun Jan 11, 2009 8:34 pm
by nhaack
cool... it is on-board already? What is it called? Is it in the plug-in directory?

Best
Nils

Re: shoutbox

Posted: Sun Jan 11, 2009 11:36 pm
by joerns
Well I couldn't find it and so adapted my little script for the new version :)
What it looks like: Image

Re: shoutbox

Posted: Thu Feb 12, 2009 3:47 am
by Slagar
Is this functionality already available, Mark? Where?  :o

Joerns, that looks fantastic!! I haven't tried it yet, but might do later :)
If there aren't any other solutions around, maybe this could be made into a simple module. I wish I knew more about module development myself  :-\

Also, I do agree with the OP that front-end shoutbox functionality could be quite handy!

Re: shoutbox

Posted: Thu Feb 12, 2009 5:36 am
by Nullig
Excellent addon joerns. I tweaked it a little, coded english translations and added it to the dashboard page in admin, where system messages are shown.

Here's the code for:

shout.php

Code: Select all

<?php

// Settings...
$shout_filename=".htshout"; //Clever: Use a filename that starts with ".ht" to make Apache deny access automatically...
$shout_lang=array("title"=>"Admin Message Board","enter"=>"New message:","submit"=>"Submit","nodisplay"=>"The entries can not be displayed...","nostore"=>"The entry could not be saved.","created"=>"Board created.");
$shout_maxlen=1000;
$shout_timeformat="d.m.Y H:i:s"; //PHP-Time... -> http://de.php.net/manual/de/function.date.php

// (c) 2009 by js
$shout_time=date($shout_timeformat);
if(!file_exists($shout_filename))file_put_contents($shout_filename,"(".$shout_time.")\t".$shout_lang["created"]."\n");
$shout_content=file_get_contents($shout_filename);

if(isset($CMS_ADMIN_PAGE)&&$CMS_ADMIN_PAGE==1){
	//included, show entry list...
	
	echo '<div class="pagecontainer">
	<div class="pageoverflow"><div class="pageheader">'.$shout_lang["title"].'</div></div>
	';
	if($shout_content==false)echo '<div class="error">'.$shout_lang["nodisplay"].'</div>';
	else{
		$shout_content=htmlentities($shout_content,ENT_QUOTES,"UTF-8");
		$shout_content=preg_replace("/(^|\n)(.+)\t/",'<h3 style="margin:0;margin-top:3px;">$2</h3>',$shout_content); //put name+time into heading
		echo '<div style="border:1px ridge black;background-color:white;padding:5px;margin-bottom:5px;">'.$shout_content.'</div>';
	}
	echo '
	<form action="shout.php" method="POST"><input type="hidden" name="'.CMS_SECURE_PARAM_NAME.'" value="'.$_SESSION[CMS_USER_KEY].'" />'.$shout_lang["enter"].' <input type="text" name="shout_text" style="width:500px;"> <input type="submit" value="'.$shout_lang["submit"].'"></form>
	</div>';
	
}else{
	//direct call, seems to be a new entry...
	
	//Security things...
	require_once("../include.php");
	check_login();
	
	$shout_dest="index.php?".CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY];
	if(isset($_POST["shout_text"])){
		$shout_post=$_POST["shout_text"];
		$shout_post=trim(str_replace(array("\n","\r"),"",$shout_post)); //For Security...
		if($shout_post!=""){
			$shout_content="(".$shout_time.") ".$gCms->variables['username']."\t".$shout_post."\n".$shout_content;
			$shout_content=substr($shout_content,0,$shout_maxlen).((strlen($shout_content)>$shout_maxlen)?"...":"");
			if(file_put_contents($shout_filename,$shout_content)) redirect($shout_dest);
			else echo '<div class="error">'.$shout_lang["nostore"].'</div>';
		} else redirect($shout_dest);
	}else redirect($shout_dest);
}

?>
and I added it to the dashboard.php file, near the bottom:

Code: Select all

$themeObject->DisplayDashboardPageItem("end");
include_once("shout.php");
?></div></div>
Nullig

Re: shoutbox

Posted: Sat Apr 18, 2009 11:56 am
by joerns
Hmmm.
I think it would be better to shorten the entries when a new entry is added.
In your version the .htshout file will still be cropped after the specified lenght ($shout_maxlength) what isn't necessary any more, then.
There are so many things that could be improved. Perhaps the message board should be somewhat integrated with the System Messages (although it would prefer to only have it on the first page). Then data should be stored in a database, and modules should have the possibility to add messages (like "Guestbook: There is a new entry, please check").
Someone want to implement that? :)