News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

nneonneo's Shoutbox

Started by nneonneo, December 26, 2006, 06:58:11 PM

Previous topic - Next topic

juniorj23

hey nneoneo's after i add the user image to the shoutbox and all some user name is longer than some and the image is kinda out of order how can i fix it so that all image is in line???

Mythers

Hey !

I've got a question: I'm currently using Midnight Sun theme on my forum. But, when i install the theme on the site with the shoutbox after editing the Index.template.php my shoutbox is at the Top left corner.

I'm a really newbie when it comes to Php etc.
So, how can i make the shoutbox be where it is when i use SMF core for an example ?

Any help is very Appreciated !

Edit: I'm using SMF 2.0 beta 4

_Anthony_

Quote from: Mythers on January 22, 2009, 03:10:11 PM
Hey !

I've got a question: I'm currently using Midnight Sun theme on my forum. But, when i install the theme on the site with the shoutbox after editing the Index.template.php my shoutbox is at the Top left corner.

I'm a really newbie when it comes to Php etc.
So, how can i make the shoutbox be where it is when i use SMF core for an example ?

Any help is very Appreciated !

Edit: I'm using SMF 2.0 beta 4
Post your index.template.php.
I'll do it for you.

Quote from: mantodeus on January 22, 2009, 11:08:04 AM
Hi guys

First I want to say that this is awesome mod!Amazing job,thank you man.

Now one question - shrink and expand button is not working for me ???
Everything else is perfect,only this is bugging me :(
Post your index.template.php
I'll see why it isn't working.

changaroo

echo '<div style="text-align: left">';

echo '</div>';

why doesnt that align the chat to the left? save me mrmoney :D

_Anthony_

Quote from: changaroo on January 22, 2009, 08:45:30 PM
echo '<div style="text-align: left">';

echo '</div>';

why doesnt that align the chat to the left? save me mrmoney :D
Post your yshout.php, I'll make the required edits to align left.

changaroo

<?php
// nneonneo's AJAX shoutbox
// Version 1.22

// Figure out where the yshout folder is
global $yshoutdir;
$yshoutdir=(defined('SMF')||isset($yshout_from_index))?'yshout/':'';
// Check configuration files
if(!file_exists($yshoutdir.'settings.php'))
{
echo 'Error: No settings.';
return;
}
if(!
file_exists($yshoutdir.'_banlist.php'))
{
// If _banlist.php has been deleted, assume it should be reset to defaults
$ban_ips_readpost=$ban_ips_post=$ban_names_readpost=$ban_names_post=array();
$sbMaintenance=false;
writeBanList();
}
// Load settings
require_once($yshoutdir."settings.php");
global 
$ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$sbMaintenance;
require_once(
$yshoutdir.'_banlist.php');
// Figure out which file we're logging chats to
global $shoutFile;
if(!isset(
$shoutFile))
$shoutFile='home';
if(isset(
$_REQUEST['file']))
$shoutFile=$_REQUEST['file'];
$shoutFile=preg_replace('/[^A-Za-z0-9_]/','',$shoutFile);
global 
$chatPath,$historyPath;
$chatsFullDir=$yshoutdir.$chatsDir.'/';
$chatPath=$chatsFullDir.sprintf($chatFormat,$shoutFile);
$historyPath=($historyFormat==='')?'':$chatsFullDir.sprintf($historyFormat,$shoutFile);

// If the shoutbox isn't require'd from SMF, we need to load some SMF components.
$loadedFromSMF=true;
if(!
defined('SMF'))
{
$loadedFromSMF=false;
session_start();
require(dirname(__FILE__) . "/../SSI.php");
require_once($sourcedir '/Subs-Post.php');
$defaultEncoding=(empty($context['character_set']) ? 'ISO-8859-1' $context['character_set']);
header('Content-type: text/html; charset='.$defaultEncoding);
}
// Set up some useful globals
global $func,$smcFunc,$ip,$isSMF1,$user;
$ip $_SERVER['REMOTE_ADDR'];
$isSMF1 = isset($func);
if(!
$isSMF1)
$func=$smcFunc;
$maxLines+=1// off-by-one correction
$user=$context['user']; // shortcut, for brevity
if(!$loadedFromSMF)
{
loadUserSettings();
loadPermissions();
loadTheme();
writeLog(); // mark user as online
}
// Are you banned from reading the shoutbox?
if(in_array($ip$ban_ips_readpost) || in_array($user['username'], $ban_names_readpost) || in_array($user['name'], $ban_names_readpost))
{
echo $txt['yshout_banned'];
return;
}
if(!
allowedTo('yshout_view'))
{
if(isGuest())
echo $txt['yshout_no_guests'];
return;
}

// Check guest status and grab guest username
if(isGuest())
{
if($autoGuestName!==false)
$user['username']=$user['name']=$_COOKIE['username']=$autoGuestName.substr(md5($ip),0,4);
elseif(isset($_POST['username']) || isset($_COOKIE['username']))
{
$requsername=isset($_POST['username'])?$_POST['username']:$_COOKIE['username'];
$requsername=$func['htmlspecialchars'](html_entity_decode(urldecode($requsername)),ENT_QUOTES);
$user['username']=$user['name']=$_COOKIE['username']=$requsername;
}
}
// Check user group membership
$user['is_sbmod']=false;
$user['can_sbpost']=false;
if(
allowedTo('yshout_moderate'))
$user['is_sbmod']=true;
if(
allowedTo('yshout_post'))
$user['can_sbpost']=true;

if(
$loadedFromSMF)
{
// Initialize the shoutbox and quit
initShoutbox($user,true);
return;
}

// Permission checks
function isGuest($user=false)
{
if($user===false) global $user;
return !$user['is_logged'];
}

function 
isMod($user=false)
{
if($user===false) global $user;
return $user['is_admin'] || $user['is_sbmod'];
}

function 
isPostBanned($user=false)
{
global $ip,$ban_ips_post,$ban_names_post;
if($user===false) global $user;
return in_array($ip$ban_ips_post) || in_array($user['username'], $ban_names_post) || in_array($user['name'], $ban_names_post);
}

// $_GET commands
// administrative: ban/unban and delete
if(isset($_GET['banid']))
{
if(!isset($_GET['mode']))
{
global $boardurl;
doMsg(<<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<base href="
$boardurl/" />
<meta http-equiv="content-type" content="text/html; charset=
$defaultEncoding" />
<title>
{$txt['yshout_ban_conf']}</title>
<script type="text/javascript">
//<![CDATA[
function ajaxGet(args) {
window.location=window.location+'&'+args;
}
//]]>
</script>
</head>
<body>
<h1>
{$txt['yshout_select_mode']}</h1>
<p><a href="javascript:ajaxGet('banid=
{$_GET['banid']}&amp;sesc={$_GET['sesc']}&amp;mode=rp');">{$txt['yshout_rp']}</a></p>
<p><a href="javascript:ajaxGet('banid=
{$_GET['banid']}&amp;sesc={$_GET['sesc']}&amp;mode=p');">{$txt['yshout_p']}</a></p>
</body>
</html>
EOF
);
exit;
}
if(isMod())
{
$error=checkSession('request','',false);
if($error!=='')
{
loadLanguage('Errors');
die($txt[$error]);
}
if(!is_numeric($_GET['banid']))
{
// not an ID, so probably an IP
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_ips_',$_GET['mode'],$_GET['banid']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
exit;
}
if(loadMemberData(Array($_GET['banid']),false,'minimal')===false)
{
doMsg($txt['yshout_error'].$txt['yshout_no_user']);
exit;
}
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_names_',$_GET['mode'],$user_profile[$_GET['banid']][$isSMF1?'memberName':'member_name']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
}
exit;
}

if(isset(
$_GET['unban']))
{
if(isMod())
{
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_'.$_GET["type"].'s_','u',$_GET['unban']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
}
exit;
}

if(isset(
$_GET['delete']))
{
if(isMod())
{
$error=checkSession('request','',false);
if($error!=='')
{
loadLanguage('Errors');
die($txt[$error]);
}
$success=deleteShout($_GET['delete'],$chatPath);
if(isset($_GET['history']) && !$success)
$success=deleteShout($_GET['delete'],$historyPath);
if($success)
echo $txt['yshout_del_success'];
}
exit;
}
// Regular user $_GET commands: history, help
if(isset($_GET["history"]))
{
history();
exit;
}

if(isset(
$_GET["help"]))
{
help();
exit;
}
// If $_GET doesn't carry a command, check the request type
if(!isset($_POST["reqtype"]))
{
echo $txt['yshout_no_action'];
return;
}

$reqType $_POST["reqtype"];

function 
initShoutbox($user,$fromSMF)
{
// This function initializes the shoutbox: it prints the tool links,
// current shouts and shout form
global $gzipCompression,$txt,$user,$maxUsernameChars,$maxShoutChars,$sbMaintenance,$autoGuestName,$shoutFormOnTop;
if($gzipCompression && !$fromSMFob_start("ob_gzhandler");
// Language check -- only admins will see this
if($user['is_admin'] && !isset($txt['yshout_history']) && !isset($_COOKIE['yShout_read_txt_notice']))
{
global $user_info,$language,$settings;
$user_language=isset($user_info['language']) ? $user_info['language'] : $language;
if($user_language != 'english' || $settings['theme_dir'] != $settings['default_theme_dir'])
echo '<span style="color:red;background:white">
Warning! The shoutbox text files for your language are not installed.
This may cause the shoutbox and admin settings to appear wrong.<br /><br />
To fix this problem, copy <strong>'
,$settings['default_theme_dir'],'/languages/Modifications.english.php</strong>
to <strong>'
,$settings['theme_dir'],'/languages/Modifications.',$user_language,'.php</strong> and translate as desired.<br /><br />
To <strong>ignore</strong> this notice, click <a href="javascript:set_cookie(\'yShout_read_txt_notice\',\'true\',3600*24*365);delete_cookie(\'yShout_open\');loadChat();">here</a>.<br /><br /></span>'
;
}
// Tool links (History, Commands, etc.)
echo '<span id="yshout-toollinks">';
echo '[<a href="javascript:goTo(\'history\')">',$txt['yshout_history'],'</a>] ';
echo '[<a href="javascript:goTo(\'help\')">',$txt['yshout_commands'],'</a>]';
if(isMod())
{
echo ' [<a href="javascript:history_number=prompt(\'How far back?\',200);if(history_number){goTo(\'history&amp;n=\'+history_number)}else{void(0)}">',$txt['yshout_exthistory'],'</a>]';
if(!isset($_COOKIE['yShout_hideadmlinks']))
echo ' [<a href="javascript:set_cookie(\'yShout_hideadmlinks\',\'true\',3600*24*365);delete_cookie(\'yShout_open\');loadChat();">',$txt['yshout_hide'],$txt['yshout_admlinks'],'</a>]';
else
echo ' [<a href="javascript:delete_cookie(\'yShout_hideadmlinks\');delete_cookie(\'yShout_open\');loadChat();">',$txt['yshout_show'],$txt['yshout_admlinks'],'</a>]';
echo ' [<a href="javascript:autoShout(\'/return\');">',$txt['yshout_return'],'</a>]';
}
echo '</span>'// yshout-toollinks
if(!$shoutFormOnTop)
echo '<div id="shouts">',readChat(),'</div>';
// Shout form
echo '
<form id="shout-form" name="shout_form" action="#" onsubmit="doSend();return false;">
<fieldset>'
;
$inputForumName=' <input id="forum-name" type="text" maxlength="'.$maxUsernameChars.'" ';
$inputShoutText=' <input id="shout-text" type="text" maxlength="'.$maxShoutChars.'" ';
$inputShoutButton=' <input id="shout-button" type="submit" ';
if(isPostBanned())
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',$txt['yshout_p_banned'],'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_banned'],'" disabled="disabled" />';
elseif(!isMod() && $sbMaintenance!==false)
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',$sbMaintenance,'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_maintenance'],'" disabled="disabled" />';
elseif(!$user['can_sbpost'])
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',isGuest()?$txt['yshout_no_guests']:$txt['yshout_no_posting'],'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_maintenance'],'" disabled="disabled" />';
else
{
if(isGuest() && $autoGuestName===false)
echo '
'
,$inputForumName,'value="',$user['name'], '" />';
else
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />';
echo '
'
,$inputShoutText,'value="" />
'
,$inputShoutButton,'value="',$txt['yshout_shout_button'],'" />';
}
echo '
</fieldset>
</form>'
;
if($shoutFormOnTop)
echo '<div id="shouts">',readChat(),'</div>';
if($gzipCompression && !$fromSMFob_end_flush();
}
// Figure out the request
switch($reqType) {
case "init":
initShoutbox($user,false);
break;
case "shout":
if(isPostBanned()) break;
if(!$user['can_sbpost']) break;
if(!isMod() && $sbMaintenance!==false) break;
$shoutText $_POST["shout"];
if($shoutText[0]=='/' && $allowCommands)
{
if(isMod())
{
if(processCommand($shoutText))
break;
}
elseif(!isGuest() || $guestCommands)
{
$shoutText=substr($shoutText,0,$maxShoutChars);
if(processUserCommand($shoutText)) break;
}
}
$shoutName $user['name'];

if(!isMod())
$shoutText=substr($shoutText,0,$maxShoutChars);

makeShout($shoutText,$user);
break;
case "refresh":
refreshChats(false);
break;
case "autoshout":
if(isMod())
processCommand($_POST["shout"]);
break;
}

function 
doMsg($msg)
{
echo $msg// tell user
$_SESSION['readingCmd']=$msg// make sure user keeps seeing this message; see readChat
}

function 
processCommand($text) {
global $reqType$maxLines$ip$user$bannedCommands$txt$sbMaintenance;
global $ban_ips_readpost$ban_ips_post$ban_names_readpost$ban_names_post;
if($text[0]!='/') return false// no slash, no service
$data=explode(' ',$text,2); // "2" means to make the first "word" separated from the rest
$cmd=$data[0]; // first word is the cmd. No cmds can have spaces.
$args=(isset($data[1])?$data[1]:''); // are there even any arguments?
if(in_array($cmd,$bannedCommands)) return false;
switch($cmd) {
case "/clear":
global $chatPath$historyPath;
$fileContents='';
if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);
$handle=fopen($chatPath'w');
fputs($handle,'');
fclose($handle);
if($historyPath !== '')
{
$handle=fopen($historyPath'a');
fputs($handle,$fileContents);
fclose($handle);
}
return true;
case "/return"// I'm done reading
unset($_SESSION['readingCmd']);
echo readChat();
return true;
case "/lock":
if($args=='')
{
doMsg($txt['yshout_error'].$txt['yshout_lock_arg_error']);
return true;
}
if($sbMaintenance !== false)
doMsg(sprintf($txt['yshout_lock_changed'],$args));
else
doMsg(sprintf($txt['yshout_lock_success'], $args));
$sbMaintenance $args;
writeBanList();
return true;
case "/unlock":
if($sbMaintenance === false)
{
doMsg($txt['yshout_error'].$txt['yshout_unlock_already']);
return true;
}
$sbMaintenance false;
writeBanList();
doMsg($txt['yshout_unlock_success']);
return true;
case "/banlist"// who's banned?
$_SESSION['readingCmd']=$text;
$temp=Array();
echo '<table>
<caption>'
,$txt['yshout_banlist_caption'],'</caption>';
echo '<tr><td>',$txt['yshout_ip_bans'],$txt['yshout_rp'],'</td><td>';
$temp=Array();
foreach($ban_ips_readpost as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=ip');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_ip_bans'],$txt['yshout_p'],'</td><td>';
$temp=Array();
foreach($ban_ips_post as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=ip');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_username_bans'],$txt['yshout_rp'],'</td><td>';
$temp=Array();
foreach($ban_names_readpost as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=name');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_username_bans'],$txt['yshout_p'],'</td><td>';
$temp=Array();
foreach($ban_names_post as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=name');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '</table>';
return true;
case "/ban"// need to be more specific!
doMsg($txt['yshout_error'].$txt['yshout_ban_type_error']);
return true;
case "/banuser":
case "/banip":
$type=($cmd=='/banip')?'ban_ips_':'ban_names_'// prefixes for variables
$ar=explode(' ',$args,2); // true argument array. the "2" ensures that we cut only once: mode can't have spaces but user can.
if(count($ar)!=2// whoops: only one argument?
{
doMsg($txt['yshout_error'].$txt['yshout_ban_mode_error']);
return true;
}
$mode=$ar[0]; // set up vars
$id=$ar[1];
doBan($type,$mode,$id);
return true;
case "/impersonate":
// <user> [userlevel] [ip] [userid] /[shout text]
$slashpos=strpos($args,' /'); // use ' /' as a separator, so we can see how many args came before
if($slashpos===false// no shout? invalid formatting?
{
doMsg($txt['yshout_error'].$txt['yshout_imp_slash_error']);
return true;
}
$shout=substr($args,$slashpos+2);
$ar=explode(' ',substr($args,0,$slashpos));
$name='';
$userlevel=0;
$userid=0;

switch(count($ar)) // how many args did we get?
{
case 0// no args
doMsg($txt['yshout_error'].$txt['yshout_imp_uname_error']);
return true;
case 4// reverse order to save space: we just set them from the back!
$userid=intval($ar[3]);
case 3:
$ip=$ar[2]; // corrupt the global >:D
case 2:
$userlevel=intval($ar[1]);
case 1:
$name=html_entity_decode($ar[0]);
break;
default:
doMsg($txt['yshout_error'].$txt['yshout_imp_max4_error']); // just so they know that we only have 4 params
return true;
}
$ip.='.'// to set off the impersonated msgs
$fakeuser=array('id'=>$userid,'name'=>$name,'is_admin'=>($userlevel==2)?1:0,'is_sbmod'=>($userlevel==1)?1:0,'is_logged'=>($userlevel==-1)?0:1); // fake SMF $user array
makeShout($shout,$fakeuser);
return true;
default: // not a command
return processUserCommand($text);
}
return false;
}

function 
processUserCommand($text) {
global $reqType,$chatPath,$historyPath,$maxLines,$ip,$ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$user,$bannedCommands,$func;
if($text[0]!='/') return false// no slash, no service
$data=explode(' ',$text,2); // "2" means to make the first "word" separated from the rest
$cmd=$data[0]; // first word is the cmd. No cmds can have spaces.
$args=(isset($data[1])?$data[1]:''); // are there even any arguments?
if(in_array($cmd,$bannedCommands)) return false;
switch($cmd) {
case "/help":
if(empty($args)) help();
elseif($args[0]!='/'help('/'.$args);
else help($args);
$_SESSION['readingCmd']=$text;
return true;
case "/return"// I'm done reading
unset($_SESSION['readingCmd']);
echo readChat();
return true;
case "/pi":
$s_pi='141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';
$n=5;
if($args!=''$n=intval($args);
$res=($n==0)?"PI IS EXACTLY 3!":'3.'.substr($s_pi,0,$n-1).(substr($s_pi,$n-1,1)+(substr($s_pi,$n,1)>=5?1:0));
// all that nasty little bit does is add the first n-2 chars, then add the last digit and increment if rounding is necessary.
makeShout($res);
return true;
case "/me":
$newText cleanupShout($args.' ');
$shoutName=$user['name'];
makeRawShout("<span class=\"meaction\"> * $shoutName $newText</span>",$user);
return true;
default:
return false;
}
return false;
}
// utility functions for banning and deleting
function doBan($type,$mode,$id)
{
global $ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$txt;
switch($mode)
{
case 'u'// nice guy
$r=$type.'readpost'// need to search both ban arrays. Search this one first...
$index=array_search($id,$$r); // where is my little banned user?
if($index===false)
{
$r=$type.'post'// ...and this one second on failure.
$index=array_search($id,$$r);
if($index===false// whoops, both searches failed!
{
doMsg($txt['yshout_error'].'Couldn\'t find user to unban!');
return false;
}
}
array_splice($$r,$index,1); // cut the 1 element loose with splice. $$r is used because $r is the string variable denoting the target array.
doMsg("Success: unbanned $id.");
break;
case 'rp':
array_push(${$type.'readpost'},$id); // easy, huh!
doMsg("Success: banned $id from reading and posting.");
break;
case 'p':
array_push(${$type.'post'},$id);
doMsg("Success: banned $id from posting.");
break;
default:
doMsg($txt['yshout_error']."Invalid mode $mode! Use only 'u', 'rp' or 'p'!");
return false;
}
writeBanList(); // write the final report
return true;
}

function 
writeBanList() // generate our dynamic ban list, which is 'require'd at the start of this script
{
global $ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$sbMaintenance,$yshoutdir;
$writeText "<"."?php\n"// php header
$writeText .= '$ban_ips_readpost = '.var_export($ban_ips_readpost,true).";\n"// bans
$writeText .= '$ban_ips_post = '.var_export($ban_ips_post,true).";\n";
$writeText .= '$ban_names_readpost = '.var_export($ban_names_readpost,true).";\n";
$writeText .= '$ban_names_post = '.var_export($ban_names_post,true).";\n";
$writeText .= '$sbMaintenance = '.var_export($sbMaintenance,true).";\n";
$writeText .= '?'.'>'// end tag
$handle fopen($yshoutdir."_banlist.php""w");
if($handle===false) die('File error (writeBanList); aborted');
$failcount=0;
while( !flock($handleLOCK_EX) ) // just IN CASE two bans happen simultaneously
{
usleep(50000);
$failcount++;
if($failcount 20) die('Write error (writeBanList); aborted'); // one second
}
fwrite($handle$writeText);
flock($handleLOCK_UN);
fclose($handle);
}

function 
deleteShout($spanTitle$chatPath) {
$fileContents '';

if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);
$newFileContents=preg_replace('/<p[^>]*><span class="shout-timestamp" title="'.str_replace('|','\|',$spanTitle).'">.+\n/','',$fileContents);
if($fileContents == $newFileContents) return false;
$handle fopen($chatPath"w");
fputs($handle$newFileContents);
fclose($handle);
return true;
}

// utility functions for shouting
function cleanupShout($text) {
global $func,$bannedCode,$context;
$text $func['htmlspecialchars'](stripslashes($text), ENT_QUOTES);
foreach($bannedCode as $searchString)
$text preg_replace('/'.preg_quote($searchString,'/').'/i','',$text);
preparsecode($text);
$text parse_bbc($text);
censorText($text);
return $text;
}

function 
makeShout($text,$user=false) {
if($user===false)
global $user;
$text cleanupShout($text.' ');

$a_style "";
global $user_profile;
if(loadMemberData(Array($user['id']),false,'profile')!==false)
{
$profile=$user_profile[$user['id']];
$a_style ' class="userclass" style="color: '.(empty($profile['member_group_color']) ? $profile['post_group_color'] : $profile['member_group_color']).'"';
}

$shoutName=$user['name'];
$userID=$user['id'];
if(isGuest($user))
$writeText=$shoutName;
else
$writeText="<a$a_style href=\"index.php?action=profile;u=$userID\">$shoutName</a>";
$writeText.=": $text";
makeRawShout($writeText,$user);
}

function 
makeRawShout($text,$user=false) {
global $maxLines,$chatPath,$historyPath,$ip;

if($user===false)
global $user;

$emTitle=time()." | $ip";
$banID=isGuest($user)?$ip:$user['id'];
$timestamp="<span class=\"shout-timestamp\" title=\"$emTitle\"><timeval=".time()."></span>";
$delLink="<a href=\"javascript:ajaxGet('delete=$emTitle&amp;sesc=<sesc>')\">del</a>";
$banLink="<a href=\"javascript:ajaxGet('banid=$banID&amp;sesc=<sesc>')\">ban</a>";
$adminlinks="<span class=\"shout-adminlinks\">$delLink&nbsp;$banLink&nbsp;</span>";
writeLine("<p class=\"shout\">$timestamp&nbsp;$adminlinks$text</p>\n",$chatPath);
truncateChat($maxLines,$chatPath,$historyPath);
refreshChats(true);
}

function 
truncateChat($maxLines,$chatPath,$historyPath) {
$fileContents '';

if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);

$lines explode("\n"$fileContents);

if(count($lines) > $maxLines) {
$newText substr($fileContentsstrpos($fileContents"\n") + 1);
$handle fopen($chatPath"w");

fputs($handle$newText);
fclose($handle);

if($historyPath !== '')
{
// History
$oldText substr($fileContents0strpos($fileContents"\n") + 1);
$handle fopen($historyPath"a");
fputs($handle$oldText);
fclose($handle);
}
}
}

function 
writeLine($writeText,$chatPath) {
$handle fopen($chatPath"a");
if($handle===false) die('File error (writeLine); aborted');
$failcount=0;
while( !flock($handleLOCK_EX) ) // just IN CASE two shouts happen simultaneously
{
usleep(50000);
$failcount++;
if($failcount 20) die('Write error (writeLine); aborted'); // one second
}
fwrite($handle$writeText);
flock($handleLOCK_UN);
fclose($handle);
}

// utility functions for reading shouts
function processChats($chatText$user=false) {
if($user===false)
global $user;
if(!isMod($user) || isset($_COOKIE['yShout_hideadmlinks']))
$chatText preg_replace('/<span class="shout-adminlinks".+?<\/span>/','',$chatText);
if(!isMod($user))
$chatText preg_replace('/<span class="shout-timestamp" title="(\d+) \| [0-9\.]+">/','<span class="shout-timestamp" title="\\1 | logged">',$chatText);
global $sc;
if(isMod($user))
$chatText preg_replace('/<sesc>/',$sc,$chatText);
$chatText=preg_replace_callback("/<timeval=(\d+)>/","preg_timeformat",$chatText);
return $chatText;
}

function 
readChat($chatPath=false$force=false) {
global $user,$reverseShouts;
if($chatPath === false)
global $chatPath;
if(isset($_SESSION['readingCmd']) && !$force)
{
$c=$_SESSION['readingCmd'];
if($c[0]=='/'// it's a command, redo command to retain the message
{
if(isMod()) processCommand($c);
else processUserCommand($c);
}
else
echo $c;
return ' ';
}
$chatText "";

if(file_exists($chatPath))
$chatText file_get_contents($chatPath);
$chatText=processChats($chatText,$user);
if($reverseShouts)
$chatText=implode("\n"array_reverse(explode("\n"$chatText)));
return $chatText.' '// hack: totally empty responses can break some browsers
}

function 
refreshChats($forceRefresh=false) {
global $chatPath,$user,$maxLines,$gzipCompression,$updateTimeout,$updatePeriod;
if(!file_exists($chatPath))
writeLine('',$chatPath);
$time=filemtime($chatPath);
$start_time=time();
$heartBeatSent=false;
if(!$forceRefresh)
{
session_write_close(); // so that future session requests succeed
while((time() - $start_time $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
@session_start(); // restart session, so updates to $_SESSION are applied
}
if($gzipCompression && !$heartBeatSentob_start("ob_gzhandler");
echo readChat();
if($gzipCompression && !$heartBeatSentob_end_flush();
}

// help and history handlers
function help($command='')
{
global $user,$defaultEncoding,$txt;
$cmdlist=$txt['yshout_cmdlist'];

$cmdlistadmin=$txt['yshout_cmdlistadmin'];
if(isMod())
$cmdlist=array_merge($cmdlist,$cmdlistadmin);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=<?php echo $defaultEncoding ?>" />
<title><?php echo $txt['yshout_cmd_reference']; ?></title>
<style type="text/css">
/*<![CDATA[*/
.meaction {
color: red;
}
/*]]>*/
</style>
</head>
<body>
<?php
if($command=='')
{
echo '<h1>',$txt['yshout_shoutbox'],' ',$txt['yshout_commands'],'</h1><div>';
foreach($cmdlist as $cmd=>$desc)
{
echo "$cmd$desc<br />\n";
}
echo '</div>';
}
else
{
echo '<div>';
if(isset($cmdlist[$command])) echo "$command{$cmdlist[$command]}<br />\n";
else echo "$command not found";
echo '</div>';
}
?>

</body>
</html>
<?php
}

function 
history()
{
global $chatPath,$historyPath,$boardurl,$gzipCompression,$defaultEncoding,$txt;

$n=250;
if(isset($_GET['n'])) $n=intval($_GET['n']); // integers only!
if($gzipCompressionob_start("ob_gzhandler");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<base href="<?php echo $boardurl,'/'?>" />
<meta http-equiv="content-type" content="text/html; charset=<?php echo $defaultEncoding ?>" />
<title><?php echo $txt['yshout_shoutbox'],' ',$txt['yshout_history']; ?></title>
<script type="text/javascript">
//<![CDATA[
function ajaxGet(args) {
window.location=window.location+'&'+args+'&'+'sesc=<?php global $sc; echo $sc?>';
}
//]]>
</script>
<style type="text/css">
/*<![CDATA[*/
/* form and toollink CSS omitted */
#yshout {
font-size: 10px;
overflow: hidden;
}
#yshout #shouts { /* main shouts area */
color: #000000;
}
#yshout .shout { /* one shout */
margin: 0 0 0; /* Top Bottom Linespacing */
line-height: 1;
}
#yshout .shout-timestamp {
font-style: normal;
font-weight: normal;
color: #000000;
}
#yshout .shout-adminlinks { /* del and ban buttons */
font-size: 6pt;
color: #141414;
}
/* from default theme */
.meaction {
color: red;
}
a:link {
color: #476C8E;
}
/*]]>*/
</style>
</head>
<body>
<h1><?php echo $txt['yshout_shoutbox'],' ',$txt['yshout_history']; ?></h1>
<div id="yshout">
<div id="shouts">
<?php
$text='';
if($historyPath !== '')
{
global $user;
require_once("class.tail.php");
$mytail = new tail($historyPath);
$mytail->setGrep(".*");
$mytail->setNumberOfLines($n);
$text=$mytail->output(PLAIN);
}
$text.=file_get_contents($chatPath);
echo processChats($text,$user);
?>

</div>
</div>
</body>
</html>
<?php
if(
$gzipCompressionob_end_flush();
exit;
}
?>

EdwardR

Hi there,

I got a "Template Parse Error" ? Has this already been covered? I'm not exactly the best at coding! I've posted the code below anywho. Any help would be appriceated.

<?php
// Version: 1.1; index

/*   This template is, perhaps, the most important template in the theme.  It
   contains the main template layer that displays the header and footer of
   the forum, namely with main_above and main_below.  It also contains the
   menu sub template, which appropriately displays the menu; the init sub
   template, which is there to set the theme up; (init can be missing.) and
   the linktree sub template, which sorts out the link tree.

   The init sub template should load any data and set any hardcoded options.

   The main_above sub template is what is shown above the main content, and
   should contain anything that should be shown up there.

   The main_below sub template, conversely, is shown after the main content.
   It should probably contain the copyright statement and some other things.

   The linktree sub template should display the link tree, using the data
   in the $context['linktree'] variable.

   The menu sub template should display all the relevant buttons the user
   wants and or needs.

   For more information on the templating system, please see the site at:
   http://www.simplemachines.org/
*/
// Initialize the template... mainly little settings.
function template_init()
{
   global 
$context$settings$options$txt;

   
/* Use images from default theme when using templates from the default theme?
      if this is 'always', images from the default theme will be used.
      if this is 'defaults', images from the default theme will only be used with default templates.
      if this is 'never' or isn't set at all, images from the default theme will not be used. */
   
$settings['use_default_images'] = 'never';

   
/* What document type definition is being used? (for font size and other issues.)
      'xhtml' for an XHTML 1.0 document type definition.
      'html' for an HTML 4.01 document type definition. */
   
$settings['doctype'] = 'xhtml';

   
/* The version this template/theme is for.
      This should probably be the version of SMF it was created for. */
   
$settings['theme_version'] = '1.1';

   
/* Set a setting that tells the theme that it can render the tabs. */
   
$settings['use_tabs'] = false;

   
/* Use plain buttons - as oppossed to text buttons? */
   
$settings['use_buttons'] = false;

   
/* Show sticky and lock status seperate from topic icons? */
   
$settings['seperate_sticky_lock'] = false;
    
    
// load custom language strings
   
loadLanguage('ThemeStrings');
}
// The main sub template above the content.
function template_main_above()
{
   global 
$context$settings$options$scripturl$txt$modSettings;

   
// Show right to left and the character set for ease of translating.
   
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
   <meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
   <meta name="description" content="'
$context['page_title'], '" />', empty($context['robot_no_index']) ? '' '
   <meta name="robots" content="noindex" />'
'
   <meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
   <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js?fin11"></script>
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var smf_theme_url = "'
$settings['theme_url'], '";
      var smf_images_url = "'
$settings['images_url'], '";
      var smf_scripturl = "'
$scripturl'";
      var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
      var smf_charset = "'
$context['character_set'], '";
   // ]]></script>
   <title>'
$context['page_title'], '</title>
   <link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?fin11" />
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?fin11" media="print" />';

   
/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
      Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
      Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
      Standards compliance mode happens when you use xhtml... */
   
if ($context['browser']['needs_size_fix'])
      echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

   
// Show all the relative links, such as help, search, contents, and the like.
   
echo '
   <link rel="help" href="'
$scripturl'?action=help" target="_blank" />
   <link rel="search" href="' 
$scripturl '?action=search" />
   <link rel="contents" href="'
$scripturl'" />';

   
// If RSS feeds are enabled, advertise the presence of one.
   
if (!empty($modSettings['xmlnews_enable']))
      echo 
'
   <link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

   
// If we're viewing a topic, these should be the previous and next topics, respectively.
   
if (!empty($context['current_topic']))
      echo 
'
   <link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
   <link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

   
// If we're in a board, or a topic for that matter, the index will be the board's index.
   
if (!empty($context['current_board']))
      echo 
'
   <link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';

  
#yshout p {
margin0 0 0/* Top Bottom Linespacing */
}
.
shout-invalid {
background#FFFDD1;
}
#yshout fieldset {
bordernone;
}
#yshout em {
font-stylenormal;
}
#yshout p {
line-height1;
margin-top0;
}
#yshout {
overflowhidden;
}
#yshout .shout-timestamp {
font-weightnormal;
color#000;
}
#yshout .adminlink {
font-size6pt;
color#141414;
}
#forum-name, #shout-text, #shout-button {
font-size9px;
margin0;
padding0;
}
#yshout #forum-name {
color#666666;
width70px;
margin-right5px;
}
#yshout #shout-text {
color#000000;
width310px;
margin-right5px;
}
#yshout #shout-button {
width55px;
}
</
style>';
// YSHOUT END

   // Output any remaining HTML headers. (from mods, maybe?)
   echo $context['
html_headers'], '
</head>
<
body>';

   // The top area with logo, avatar, user info, etc.
   echo '
   
<table class="tborder" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="margin:auto; text-align:left;">
      <
tr class="windowbg">';
         if (!empty($context['
user']['avatar']))
            echo '
<td valign="middle" align="center" style="padding:5px;">', $context['user']['avatar']['image'], '</td>';
      echo '
         
<td valign="middle" align="left" width="100%" class="tborder" style="border:0px;">';
   if ($context['
user']['is_logged'])
   {
      echo '
                     ', $txt['
hello_member'], ' <b>', $context['user']['name'], '</b>';


      // Only tell them about their messages if they can read their messages!
      if ($context['
allow_pm'])
         echo '
', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];
      echo '
      
<br />', $context['current_time'];

      // Is the forum in maintenance mode?
      if ($context['
in_maintenance'] && $context['user']['is_admin'])
         echo '
<br />
                     <
b>', $txt[616], '</b>';

      // Are there any members waiting for approval?
      if (!empty($context['
unapproved_members']))
         echo '
<br />
                     
', $context['unapproved_members'] == 1 ? $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="', $scripturl, '?action=regcenter">', $context['unapproved_members'] == 1 ? $txt['approve_member'] : $context['unapproved_members'] . ' ' . $txt['approve_members'], '</a', $txt['approve_members_waiting'];

      echo '
<br />
                     <
a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a><br />
                     <
a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a>';
   }
   // Otherwise they'
re a guest so politely ask them to register or login.
   else
   {
      echo 
'
                     '
$txt['welcome_guest'], '<br />
                     '
$context['current_time'], '<br />

                     <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/sha1.js"></script>
                        <form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" class="middletext" style="margin: 3px 1ex 1px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>    
                     <div style="text-align: right;">
                        <input type="text" name="user" size="10" /> <input type="password" name="passwrd" size="10" />
                        <select name="cookielength">
                           <option value="60">'
$txt['smf53'], '</option>
                           <option value="1440">'
$txt['smf47'], '</option>
                           <option value="10080">'
$txt['smf48'], '</option>
                           <option value="43200">'
$txt['smf49'], '</option>
                           <option value="-1" selected="selected">'
$txt['smf50'], '</option>
                        </select>
                        <input type="submit" value="'
$txt[34], '" /><br />
                        '
$txt['smf52'], '
                           <input type="hidden" name="hash_passwrd" value="" />
                        </div>
                     </form>'
;
   }
   echo 
'
         </td>
      </tr>'
;
   
// Show a random news item? (or you could pick one from news_lines...)
   
if (!empty($settings['enable_news']))
      echo 
'
      <tr class="windowbg2">
         <td colspan="2" height="24" class="tborder" style="border-width:1px 0 0 0; padding-left: 1ex;">
            <b>'
$txt[102], ':</b> '$context['random_news_line'], '
         </td>
      </tr>'
;

   echo 
'
   </table>
   <br />
   <div align="center">'
;
   
// Show the menu here, according to the menu sub template.
   
template_menu();
   echo 
'
   </div>
   <br />'
;
}
function 
template_main_below()
{
   global 
$context$settings$options$scripturl$txt;

   
// Show the "Powered by" and "Valid" logos, as well as the copyright.  Remember, the copyright must be somewhere!
   
echo '
   <br />
   <div align="center">
      '
theme_copyright(), ' <br /> ',$txt['mystica'],' <br /> ',$txt['rw_copy'],'
   </div>'
;

   
// Show the load time?
   
if ($context['show_load_time'])
      echo 
'
   <div align="center" class="smalltext">
      '
$txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'], '
   </div>'
;

   
// The following will be used to let the user know that some AJAX process is running
   
echo '
   <div id="ajax_in_progress" style="display: none;'
$context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' '''">'$txt['ajax_in_progress'], '</div>';
   
   
// And then we're done!
   
echo '
</body>
</html>'
;
}
// Show a linktree.  This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree()
{
   global 
$context$settings$options;

   
// Folder style or inline?  Inline has a smaller font.
   
echo '<span class="nav"'$settings['linktree_inline'] ? ' style="font-size: smaller;"' '''>';

   
// Each tree item has a URL and name.  Some may have extra_before and extra_after.
   
foreach ($context['linktree'] as $link_num => $tree)
   {
      
// Show the | | |-[] Folders.
      
if (!$settings['linktree_inline'])
      {
         if (
$link_num 0)
            echo 
str_repeat('<img src="' $settings['images_url'] . '/icons/linktree_main.gif" alt="| " border="0" />'$link_num 1), '<img src="' $settings['images_url'] . '/icons/linktree_side.gif" alt="|-" border="0" />';
         echo 
'<img src="' $settings['images_url'] . '/icons/folder_open.gif" alt="+" border="0" />&nbsp; ';
      }

      
// Show something before the link?
      
if (isset($tree['extra_before']))
         echo 
$tree['extra_before'];

      
// Show the link, including a URL if it should have one.
      
echo '<b>'$settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '" class="nav">' $tree['name'] . '</a>' $tree['name'], '</b>';

      
// Show something after the link...?
      
if (isset($tree['extra_after']))
         echo 
$tree['extra_after'];

      
// Don't show a separator for the last one.
      
if ($link_num != count($context['linktree']) - 1)
         echo 
$settings['linktree_inline'] ? ' &nbsp;|&nbsp; ' '<br />';
   }

   echo 
'</span>';
}
// Show the menu up top.  Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global 
$context$settings$options$scripturl$txt;

   
// Show the [home] and [help] buttons.
   
echo '
            <a href="'
$scripturl'">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/home.gif" alt="' $txt[103] . '" border="0" />' $txt[103]), '</a>'$context['menu_separator'], '
            <a href="'
$scripturl'?action=help">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/help.gif" alt="' $txt[119] . '" border="0" />' $txt[119]), '</a>'$context['menu_separator'];

   
// How about the [search] button?
   
if ($context['allow_search'])
      echo 
'
            <a href="'
$scripturl'?action=search">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/search.gif" alt="' $txt[182] . '" border="0" />' $txt[182]), '</a>'$context['menu_separator'];

   
// Is the user allowed to administrate at all? ([admin])
   
if ($context['allow_admin'])
      echo 
'
            <a href="'
$scripturl'?action=admin">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/admin.gif" alt="' $txt[2] . '" border="0" />' $txt[2]), '</a>'$context['menu_separator'];

   
// Edit Profile... [profile]
   
if ($context['allow_edit_profile'])
      echo 
'
            <a href="'
$scripturl'?action=profile">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/profile.gif" alt="' $txt[79] . '" border="0" />' $txt[467]), '</a>'$context['menu_separator'];

   
// The [calendar]!
   
if ($context['allow_calendar'])
      echo 
'
            <a href="'
$scripturl'?action=calendar">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/calendar.gif" alt="' $txt['calendar24'] . '" border="0" />' $txt['calendar24']), '</a>'$context['menu_separator'];

   
// If the user is a guest, show [login] and [register] buttons.
   
if ($context['user']['is_guest'])
   {
      echo 
'
            <a href="'
$scripturl'?action=login">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/login.gif" alt="' $txt[34] . '" border="0" />' $txt[34]), '</a>'$context['menu_separator'], '
            <a href="'
$scripturl'?action=register">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/register.gif" alt="' $txt[97] . '" border="0" />' $txt[97]), '</a>';
   }
   
// Otherwise, they might want to [logout]...
   
else
      echo 
'
            <a href="'
$scripturl'?action=logout;sesc='$context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' $context['user']['language'] . '/logout.gif" alt="' $txt[108] . '" border="0" />' $txt[108]), '</a>';
}
// Generate a strip of buttons, out of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
   global 
$settings$buttons$context$txt$scripturl;

   if (empty(
$button_strip))
      return 
'';

   
// Create the buttons...
   
foreach ($button_strip as $key => $value)
   {
      if (isset(
$value['test']) && empty($context[$value['test']]))
      {
         unset(
$button_strip[$key]);
         continue;
      }
      elseif (!isset(
$buttons[$key]) || $force_reset)
         
$buttons[$key] = '<a href="' $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . ($settings['use_image_buttons'] ? '<img src="' $settings['images_url'] . '/' . ($value['lang'] ? $context['user']['language'] . '/' '') . $value['image'] . '" alt="' $txt[$value['text']] . '" border="0" />' $txt[$value['text']]) . '</a>';

      
$button_strip[$key] = $buttons[$key];
   }

   echo 
'
      <td '
$custom_td'>'implode($context['menu_separator'], $button_strip) , '</td>';
}

?>



Thanks!


Sorry if this has already been covered!


Ed x


Quote from: ameo on May 07, 2008, 11:46:19 AM
I made sort of guide for dummies, or something like that, to place this shoutbox in News field, and make it look cool on forum.
Personally, I believe this is the best position for shoutbox, and if you don't need News on your forum you could place shoutbox instead.


NOTE: I wrote tutorial and it works for 1.17 !!!

NOTE 2: With nneonneo's help - this works like a charm with version 1.21 also :)
            For 1.21 installation see step 4 instead of step 1, and then 
            follow all other steps normally.


STEP 1
First steps you already know, but I'll repeat it just in case;

First download yShout and install it.
If you're using different theme than default one after

echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/fonts-compat.css" />';


you must add this code into your index.template.php :

// YSHOUT HERE
global $boardurl;
echo '
<script src="',$boardurl,'/yshout/js/prototype.js" type="text/javascript"></script>
<script src="',$boardurl,'/yshout/js/moo.ajax.js" type="text/javascript"></script>
<script src="',$boardurl,'/yshout/js/behaviour.js" type="text/javascript"></script>
<script src="',$boardurl,'/yshout/js/domFunction.js" type="text/javascript"></script>
<script type="text/javascript">

var myfunc = new domFunction(function()
{
loadChat();
}, { "yshout":"id"});
var board_url = "'; $boardurlparsed = parse_url($boardurl); echo (isset($boardurlparsed['path'])?$boardurlparsed['path']:""), '";

</script>
<script src="',$boardurl,'/yshout/js/yshout.js?Mar072008" type="text/javascript"></script>
<script type="text/javascript">var shoutFile = "home.txt";</script>
<style type="text/css">
#yshout {
font-size: 10px;
}
#yshout p {
margin: 0 0 0; /* Top Bottom Linespacing */
}
.shout-invalid {
background: #FFFDD1;
}
#yshout fieldset {
border: none;
}
#yshout em {
font-style: normal;
}
#yshout p {
line-height: 1;
margin-top: 0;
}
#yshout {
overflow: hidden;
}
#yshout .shout-timestamp {
font-weight: normal;
color: #000;
}
#yshout .adminlink {
font-size: 6pt;
color: #141414;
}
#forum-name, #shout-text, #shout-button {
font-size: 9px;
margin: 0;
padding: 0;
}
#yshout #forum-name {
color: #666666;
width: 70px;
margin-right: 5px;
}
#yshout #shout-text {
color: #000000;
width: 310px;
margin-right: 5px;
}
#yshout #shout-button {
width: 55px;
}
</style>';
// YSHOUT END



Then do this:


Of course you need news box to be displayed in order to see shoutbox in your index page.
To do that go to Theme options and click to:

1. DISABLE eNews   [it is very dangerous to leave it enabled, so if it is checked,
    you must uncheck it]

&
[/]


2. Show news fader on board index [check it]

3. fading delay - set to 0

Click save, then in News box put this code

a) for 1.15-1.17       <div id="yshout">',$txt['yshout_loading'],'


b) for 1.21             
<div id="yshout">Loading shoutbox...</div>

instead of putting second code somewhere else:

And save it.


If you wish to change News to Shout box or Shoutbox you'll need to find file index.english-utf8.php / index.english.php or of  any other language file you're using.  They are stored under Forum/Themes/default/languages/  In there you'll need to edit string    $txt[102] = 'News';   
to   $txt[102] = 'Shoutbox';  and re-upload that file to it's place. You'll need to replace old file with that new-one if you didn't delete old one first. 



// GUIDE FOR DUMMIES IS FINISHED //
I guess that's it. I hope it shall be helpful to at least someone.[/]


Step 4 is actually step 1 FOR 1.21 installation


In index.template.php, after
   // If we're in a board, or a topic for that matter, the index will be the board's index.
   if (!empty($context['current_board']))
      echo '
   <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />';

add
   // YSHOUT HERE - <head> code
   global $boardurl,$shoutFile;
   $shoutFile='home';
   $scripturlparsed = parse_url($scripturl);
   $scriptpath=isset($scripturlparsed['path'])?$scripturlparsed['path']:'/';
   $args='';
   foreach($_GET as $key => $value) // passthrough $_GET
      $args.='&'.urlencode($key).'='.urlencode($value);
   echo '
   <script src="',$boardurl,'/yshout/js/moo.ajax.js" type="text/javascript"></script>
   <script src="',$boardurl,'/yshout/settings.js" type="text/javascript"></script>
   <script type="text/javascript"><!-- // --><![CDATA[
   window.onload=function(){loadChat();};
   var shoutFile="',$shoutFile,'";
   var yshout_php="',$scriptpath,'?yshout',$args,'";
   // ]]></script>
   <script src="',$boardurl,'/yshout/js/yshout.js?July062008" type="text/javascript"></script>
   <style type="text/css">
      #yshout {
         font-size: 10px;
         overflow: hidden;
      }
      #yshout #yshout-toollinks { /* tool links (History, Commands, etc.) */
      }
      #yshout #shouts { /* main shouts area */
      }
      #yshout .shout { /* one shout */
         margin: 0 0 0; /* Top Bottom Linespacing */
         line-height: 1;
      }
      #yshout .shout-timestamp {
         font-style: normal;
         font-weight: normal;
      }
      #yshout .shout-adminlinks { /* del and ban buttons */
         font-size: 6pt;
         color: #141414;
      }
      #yshout #shout-form {
         margin: 0;
         padding: 0;
      }
      #yshout #shout-form fieldset {
         border: none;
      }
      #yshout #forum-name {
         width: 70px;
         margin-right: 5px;
      }
      #yshout #shout-text {
         width: 310px;
         margin-right: 5px;
      }
      #yshout #shout-button {
         width: 55px;
      }
      #yshout .shout-invalid { /* invalid shout (shout textbox) */
         background: #FFFDD1;
      }
   </style>';
   // YSHOUT END - <head> code




Best of luck 2 everyone[/hr]
You got the best of me ... Now I'm losing it .. Oh Oh Oh la la la oh oh!

nneonneo

@lorddusk, Don Pepito: Edit yshout.php, and change this line:
writeLine("<p class=\"shout\">$timestamp&nbsp;$adminlinks$text</p>\n",$chatPath);
to your liking. Affects new shouts only.
$timestamp is the [time], $adminlinks are the "del" and "ban" buttons, $text is the shout.

@kuzjnvn: Try this: edit yshout.php, and add above
require_once($sourcedir . '/Subs-Post.php');
this line:
global $sourcedir;

@wrbex: Open yshout/settings.php, and edit the $bannedCode section to add [img] and [/img] tags.

@renkliforum: Did you install the <head> code? The javascript is required for the shoutbox to work.

@Quexinos: Edit yshout/settings.php and change $maxLines to your liking. You may need to /clear the shoutbox to make it take effect.

@dangerboy: The names use the forum colours for consistency. If you want to change that, edit yshout.php and change these lines:
$a_style = "";
global $user_profile;
if(loadMemberData(Array($user['id']),false,'profile')!==false)
{
$profile=$user_profile[$user['id']];
$a_style = ' class="userclass" style="color: '.(empty($profile['member_group_color']) ? $profile['post_group_color'] : $profile['member_group_color']).'"';
}

to
$a_style = ' class="userclass" style="color: orange"';
Do make a backup in case you want to change it back.

@changaroo: In index.template.php, add
style="text-align: left"
after
<div id="yshout"
to justify the text.

@mantodeus: Did you install it manually? For AdvSB, there is some extra code that goes with the shrink/expand. See this page (SMF2) or this page (SMF1) for more information.

@juniorj23: You can't really do much about it, since all the avatars can be different sizes.

@EdwardR: You didn't quite paste in the entire shoutbox code:
   if (!empty($context['current_board']))
      echo '
   <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />';

  #yshout p {
margin: 0 0 0; /* Top Bottom Linespacing */


Just remove the code from #yshout p to // YSHOUT END, and try it again.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

mantodeus

#4968
Quote from: nneonneo on January 23, 2009, 09:13:17 AM

.....

@mantodeus: Did you install it manually? For AdvSB, there is some extra code that goes with the shrink/expand. See this page (SMF2) or this page (SMF1) for more information.

....

I am using SMF 2 Beta 3.1 and I just uploaded the package AdvSB and hit apply mode.I ma using default theme and I applied also bulgarian language to this mode,translation from the first post.

Have I to make any other changes ?

EDIT : Okay I followed the instructions from the link which you gave me and now it is working ! Thanks

juniorj23


lorddusk

Quote from: nneonneo on January 23, 2009, 09:13:17 AM
@lorddusk, Don Pepito: Edit yshout.php, and change this line:
writeLine("<p class=\"shout\">$timestamp&nbsp;$adminlinks$text</p>\n",$chatPath);
to your liking. Affects new shouts only.
$timestamp is the [time], $adminlinks are the "del" and "ban" buttons, $text is the shout.


Thanks, it worked, but i have a new question, the darker gray stripes, can you delete them? ( i mean the stripes that seperates the shouts... )

Mythers

Quote from: MrMoney on January 22, 2009, 08:25:34 PM
Quote from: Mythers on January 22, 2009, 03:10:11 PM
Hey !

I've got a question: I'm currently using Midnight Sun theme on my forum. But, when i install the theme on the site with the shoutbox after editing the Index.template.php my shoutbox is at the Top left corner.

I'm a really newbie when it comes to Php etc.
So, how can i make the shoutbox be where it is when i use SMF core for an example ?

Any help is very Appreciated !

Edit: I'm using SMF 2.0 beta 4
Post your index.template.php.
I'll do it for you.



?php
// Version: 2.0 Beta 4; index

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context, $settings, $options, $txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '2.0 Beta 4';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status separate from topic icons? */
$settings['separate_sticky_lock'] = true;

/* Does this theme use the strict doctype? */
$settings['strict_doctype'] = false;

/* Does this theme use post previews on the message index? */
$settings['message_index_preview'] = false;

/* Call to Theme String for languages  */
    if(loadlanguage('ThemeStrings') == false)
       loadLanguage('ThemeStrings', 'english');
}

// The main sub template above the content.
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title_html_safe'], '" />
<meta name="keywords" content="', $context['meta_keywords'], '" />
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?b4"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?b4"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "', $settings['theme_url'], '";
var smf_default_theme_url = "', $settings['default_theme_url'], '";
var smf_images_url = "', $settings['images_url'], '";
var smf_scripturl = "', $scripturl, '";
var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
var smf_charset = "', $context['character_set'], '";', $context['show_pm_popup'] ? '
if (confirm("' . $txt['show_personal_messages'] . '"))
window.open("' . $scripturl . '?action=pm");' : '', '
var ajax_notification_text = "', $txt['ajax_in_progress'], '";
var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
// ]]></script>
<title>', $context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';

// The ?b4 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />';

echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/print.css?b4" media="print" />';

echo '
<link rel="stylesheet" type="html" href="', $settings['theme_url'], '/resources.html?b4" />';

// IE7 needs some fixes for styles.
if ($context['browser']['is_ie7'])
echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/ie7.css" />';
// ..and IE6!
elseif ($context['browser']['is_ie6'])
echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/ie6.css" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="', $scripturl, '?action=help" />
<link rel="search" href="' . $scripturl . '?action=search" />
<link rel="contents" href="', $scripturl, '" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']))
echo '
<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - RSS" href="', $scripturl, '?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';
        // YSHOUT HERE - <head> code
global $boardurl,$shoutFile;
$shoutFile='home';
$scripturlparsed = parse_url($scripturl);
$scriptpath=isset($scripturlparsed['path'])?$scripturlparsed['path']:'/';
$args='';
foreach($_GET as $key => $value) // passthrough $_GET
$args.='&'.urlencode($key).'='.urlencode($value);
echo '
<script src="',$boardurl,'/yshout/js/moo.ajax.js" type="text/javascript"></script>
<script src="',$boardurl,'/yshout/settings.js" type="text/javascript"></script>
<script type="text/javascript"><!-- // --><![CDATA[
window.onload=function(){loadChat();};
var shoutFile="',$shoutFile,'";
var yshout_php="',$scriptpath,'?yshout',$args,'";
// ]]></script>
<script src="',$boardurl,'/yshout/js/yshout.js?July062008" type="text/javascript"></script>
<style type="text/css">
#yshout {
font-size: 10px;
overflow: hidden;
}
#yshout #yshout-toollinks { /* tool links (History, Commands, etc.) */
}
#yshout #shouts { /* main shouts area */
}
#yshout .shout { /* one shout */
margin: 0 0 0; /* Top Bottom Linespacing */
line-height: 1;
}
#yshout .shout-timestamp {
font-style: normal;
font-weight: normal;
}
#yshout .shout-adminlinks { /* del and ban buttons */
font-size: 6pt;
color: #141414;
}
#yshout #shout-form {
margin: 0;
padding: 0;
}
#yshout #shout-form fieldset {
border: none;
}
#yshout #forum-name {
width: 70px;
margin-right: 5px;
}
#yshout #shout-text {
width: 310px;
margin-right: 5px;
}
#yshout #shout-button {
width: 55px;
}
#yshout .shout-invalid { /* invalid shout (shout textbox) */
background: #FFFDD1;
}
</style>';
// YSHOUT END - <head> code
       
       
        // YSHOUT HERE - shoutbox code
global $txt,$context,$boarddir;
if(allowedTo('yshout_view'))
{
echo '<br /><b>',$txt['yshout_shoutbox'],'</b><br /><br />';
echo '<div id="yshout">';
include_once($boarddir.'/yshout/yshout.php');
echo '</div>';
}
elseif($context['user']['is_guest'])
echo $txt['yshout_no_guests'];
// YSHOUT END - shoutbox code
       

// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
// Create the main header object.
var mainHeader = new smfToggle("upshrink", ', empty($options['collapse_header']) ? 'false' : 'true', ');
mainHeader.useCookie(', $context['user']['is_guest'] ? 1 : 0, ');
mainHeader.setOptions("collapse_header", "', $context['session_id'], '");
mainHeader.addToggleImage("upshrink", "/upshrink.gif", "/upshrink2.gif");
mainHeader.addTogglePanel("user_section");
mainHeader.addTogglePanel("news_section");
// ]]></script>';

echo '
    <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var PreloadImages = new Array(
         "/images/submenu_top.png",
         "/images/submenu_bg.png"
      );

      var myImages = new Array();
      for(var i = 0; i < PreloadImages.length; i++)
      {
         myImages[i] = new Image();
         myImages[i].src = "'. $settings['theme_url'] .'" + PreloadImages[i];
      }
    // ]]></script>';

echo '
</head>
<body>';
}

function template_body_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
<div id="wrapper">
<div id="shad-l">
<div id="shad-r">
<div id="head-l">
<div id="head-r">
    <div id="header">
<div id="userarea">';
if ($context['user']['is_logged'])
{
echo '
<b>', $txt['hello_member_ndt'], ' ', $context['user']['name'], '</b><br />';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo $txt['msg_alert_you_have'], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

echo '
<a href="', $scripturl, '?action=unread">',$txt['showunread2'],'</a>&nbsp;/
<a href="', $scripturl, '?action=unreadreplies">',$txt['showreplies2'],'</a>&nbsp;/
<a href="', $scripturl, '?action=profile;sa=showPosts">',$txt['ownposts2'],'</a><br />
', $context['current_time'],'';

}
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
else
{
           echo sprintf($txt['welcome_forum']);
      echo '
            <br/>', $context['current_time'],'<br />';
}

echo '
</div>

<a href="'.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>';
echo '
</div>
</div>
</div>
<div id="toolbar">
',template_menu(),'
</div>
<div id="bodyarea">';

// Show the navigation tree.
theme_linktree();

}

function template_body_below()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
</div>';

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
echo '
<div id="foot-l">
<div id="foot-r">
<div id="footer">
<div id="footerarea">

<span class="smalltext">Midnight Sun by <a href="http://www.dzinerstudio.com"><b>Antechinus</b></a> | <a href="', $settings['theme_url'], '/resources.html?b4" target="_blank"><b>Resources</b></a> | <a href="http://www.dzinerstudio.com">DzinerStudio</a>
                                     
</span>';

echo '
</div>
</div>
</div>
</div>';

// Show the load time?
echo'       
         <div id="basebar" style="height: 20px; text-align: center; ">     
<span class="smalltext">', theme_copyright(), ' </span>';

if ($context['show_load_time'])
echo '<span class="smalltext">| '. $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</span>';
    echo '
         </div>';
}

function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
</div>
</div>
</div>
</body></html>';
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show = false)
{
global $context, $settings, $options, $shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;

//!!! Temporarily don't do it twice.
if (!empty($shown_linktree))
return;
$shown_linktree = true;

echo '
<ul id="linktree">';

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] .'</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo '&nbsp;>';

echo '
</li>';
}
echo '
</ul>';
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div class="tabs">
<ul>';
foreach ($context['menu_buttons'] as $act => $button)
{
echo '   <li><a ', $button['active_button'] ? ' class="current"' : '' , ' href="', $button['href'], '">
         <span class="menu-left"></span>
<span class="menu-right">' , $button['title'] , '</span></a>';

          //    Does this button have any subbuttons?
        if(!empty($button['sub_buttons']))
        {
            echo '
                             <div class="sub">
<ul>';
            foreach($button['sub_buttons'] as $sub_button)
                    echo '
                <li><a href="', $sub_button['href'], '">' , $sub_button['title'] , '</a></li>';
            echo '
                                 </ul>
</div>';      
         }

echo' </li>';

}

echo '
</ul>
</div>';

}

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $force_reset = false, $custom_td = '')
{
global $settings, $context, $txt, $scripturl;

// Create the buttons...
$buttons = array();
foreach ($button_strip as $key => $value)
{
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '<a href="' . $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';
}

if (empty($buttons))
return '';

// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

echo '
<div class="buttonlist', $direction != 'top' ? '_bottom' : '', '">
<ul class="clearfix">
<li>', implode('</li><li>', $buttons), '</li>
</ul>
</div>';

}

?>

nneonneo

@lorddusk: edit yshout.css or index.template.php
add after
#yshout hr { /* shout divider */

the line
display: none;
If you can't find #yshout hr, just add
#yshout hr {
display: none;
}

near other similar-looking blocks
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

_Anthony_

Quote from: Mythers on January 23, 2009, 04:33:54 PM
?php
// Version: 2.0 Beta 4; index

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context, $settings, $options, $txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '2.0 Beta 4';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status separate from topic icons? */
$settings['separate_sticky_lock'] = true;

/* Does this theme use the strict doctype? */
$settings['strict_doctype'] = false;

/* Does this theme use post previews on the message index? */
$settings['message_index_preview'] = false;

/* Call to Theme String for languages  */
    if(loadlanguage('ThemeStrings') == false)
       loadLanguage('ThemeStrings', 'english');
}

// The main sub template above the content.
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title_html_safe'], '" />
<meta name="keywords" content="', $context['meta_keywords'], '" />
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?b4"></script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?b4"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "', $settings['theme_url'], '";
var smf_default_theme_url = "', $settings['default_theme_url'], '";
var smf_images_url = "', $settings['images_url'], '";
var smf_scripturl = "', $scripturl, '";
var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
var smf_charset = "', $context['character_set'], '";', $context['show_pm_popup'] ? '
if (confirm("' . $txt['show_personal_messages'] . '"))
window.open("' . $scripturl . '?action=pm");' : '', '
var ajax_notification_text = "', $txt['ajax_in_progress'], '";
var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
// ]]></script>
<title>', $context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';

// The ?b4 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style', $context['theme_variant'], '.css?b4" />';

echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/print.css?b4" media="print" />';

echo '
<link rel="stylesheet" type="html" href="', $settings['theme_url'], '/resources.html?b4" />';

// IE7 needs some fixes for styles.
if ($context['browser']['is_ie7'])
echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/ie7.css" />';
// ..and IE6!
elseif ($context['browser']['is_ie6'])
echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/ie6.css" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="', $scripturl, '?action=help" />
<link rel="search" href="' . $scripturl . '?action=search" />
<link rel="contents" href="', $scripturl, '" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']))
echo '
<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - RSS" href="', $scripturl, '?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';
        // YSHOUT HERE - <head> code
global $boardurl,$shoutFile;
$shoutFile='home';
$scripturlparsed = parse_url($scripturl);
$scriptpath=isset($scripturlparsed['path'])?$scripturlparsed['path']:'/';
$args='';
foreach($_GET as $key => $value) // passthrough $_GET
$args.='&'.urlencode($key).'='.urlencode($value);
echo '
<script src="',$boardurl,'/yshout/js/moo.ajax.js" type="text/javascript"></script>
<script src="',$boardurl,'/yshout/settings.js" type="text/javascript"></script>
<script type="text/javascript"><!-- // --><![CDATA[
window.onload=function(){loadChat();};
var shoutFile="',$shoutFile,'";
var yshout_php="',$scriptpath,'?yshout',$args,'";
// ]]></script>
<script src="',$boardurl,'/yshout/js/yshout.js?July062008" type="text/javascript"></script>
<style type="text/css">
#yshout {
font-size: 10px;
overflow: hidden;
}
#yshout #yshout-toollinks { /* tool links (History, Commands, etc.) */
}
#yshout #shouts { /* main shouts area */
}
#yshout .shout { /* one shout */
margin: 0 0 0; /* Top Bottom Linespacing */
line-height: 1;
}
#yshout .shout-timestamp {
font-style: normal;
font-weight: normal;
}
#yshout .shout-adminlinks { /* del and ban buttons */
font-size: 6pt;
color: #141414;
}
#yshout #shout-form {
margin: 0;
padding: 0;
}
#yshout #shout-form fieldset {
border: none;
}
#yshout #forum-name {
width: 70px;
margin-right: 5px;
}
#yshout #shout-text {
width: 310px;
margin-right: 5px;
}
#yshout #shout-button {
width: 55px;
}
#yshout .shout-invalid { /* invalid shout (shout textbox) */
background: #FFFDD1;
}
</style>';
// YSHOUT END - <head> code
       
       
        // YSHOUT HERE - shoutbox code
global $txt,$context,$boarddir;
if(allowedTo('yshout_view'))
{
echo '<br /><b>',$txt['yshout_shoutbox'],'</b><br /><br />';
echo '<div id="yshout">';
include_once($boarddir.'/yshout/yshout.php');
echo '</div>';
}
elseif($context['user']['is_guest'])
echo $txt['yshout_no_guests'];
// YSHOUT END - shoutbox code
       

// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
// Create the main header object.
var mainHeader = new smfToggle("upshrink", ', empty($options['collapse_header']) ? 'false' : 'true', ');
mainHeader.useCookie(', $context['user']['is_guest'] ? 1 : 0, ');
mainHeader.setOptions("collapse_header", "', $context['session_id'], '");
mainHeader.addToggleImage("upshrink", "/upshrink.gif", "/upshrink2.gif");
mainHeader.addTogglePanel("user_section");
mainHeader.addTogglePanel("news_section");
// ]]></script>';

echo '
    <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var PreloadImages = new Array(
         "/images/submenu_top.png",
         "/images/submenu_bg.png"
      );

      var myImages = new Array();
      for(var i = 0; i < PreloadImages.length; i++)
      {
         myImages[i] = new Image();
         myImages[i].src = "'. $settings['theme_url'] .'" + PreloadImages[i];
      }
    // ]]></script>';

echo '
</head>
<body>';
}

function template_body_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
<div id="wrapper">
<div id="shad-l">
<div id="shad-r">
<div id="head-l">
<div id="head-r">
    <div id="header">
<div id="userarea">';
if ($context['user']['is_logged'])
{
echo '
<b>', $txt['hello_member_ndt'], ' ', $context['user']['name'], '</b><br />';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo $txt['msg_alert_you_have'], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

echo '
<a href="', $scripturl, '?action=unread">',$txt['showunread2'],'</a>&nbsp;/
<a href="', $scripturl, '?action=unreadreplies">',$txt['showreplies2'],'</a>&nbsp;/
<a href="', $scripturl, '?action=profile;sa=showPosts">',$txt['ownposts2'],'</a><br />
', $context['current_time'],'';

}
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
else
{
           echo sprintf($txt['welcome_forum']);
      echo '
            <br/>', $context['current_time'],'<br />';
}

echo '
</div>

<a href="'.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>';
echo '
</div>
</div>
</div>
<div id="toolbar">
',template_menu(),'
</div>
<div id="bodyarea">';

// Show the navigation tree.
theme_linktree();

}

function template_body_below()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
</div>';

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
echo '
<div id="foot-l">
<div id="foot-r">
<div id="footer">
<div id="footerarea">

<span class="smalltext">Midnight Sun by <a href="http://www.dzinerstudio.com"><b>Antechinus</b></a> | <a href="', $settings['theme_url'], '/resources.html?b4" target="_blank"><b>Resources</b></a> | <a href="http://www.dzinerstudio.com">DzinerStudio</a>
                                    
</span>';

echo '
</div>
</div>
</div>
</div>';

// Show the load time?
echo'      
         <div id="basebar" style="height: 20px; text-align: center; ">    
<span class="smalltext">', theme_copyright(), ' </span>';

if ($context['show_load_time'])
echo '<span class="smalltext">| '. $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</span>';
    echo '
         </div>';
}

function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
</div>
</div>
</div>
</body></html>';
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show = false)
{
global $context, $settings, $options, $shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;

//!!! Temporarily don't do it twice.
if (!empty($shown_linktree))
return;
$shown_linktree = true;

echo '
<ul id="linktree">';

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] .'</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo '&nbsp;>';

echo '
</li>';
}
echo '
</ul>';
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div class="tabs">
<ul>';
foreach ($context['menu_buttons'] as $act => $button)
{
echo '   <li><a ', $button['active_button'] ? ' class="current"' : '' , ' href="', $button['href'], '">
         <span class="menu-left"></span>
<span class="menu-right">' , $button['title'] , '</span></a>';

          //    Does this button have any subbuttons?
        if(!empty($button['sub_buttons']))
        {
            echo '
                             <div class="sub">
<ul>';
            foreach($button['sub_buttons'] as $sub_button)
                    echo '
                <li><a href="', $sub_button['href'], '">' , $sub_button['title'] , '</a></li>';
            echo '
                                 </ul>
</div>';     
         }

echo' </li>';

}

echo '
</ul>
</div>';

}

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $force_reset = false, $custom_td = '')
{
global $settings, $context, $txt, $scripturl;

// Create the buttons...
$buttons = array();
foreach ($button_strip as $key => $value)
{
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '<a href="' . $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';
}

if (empty($buttons))
return '';

// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

echo '
<div class="buttonlist', $direction != 'top' ? '_bottom' : '', '">
<ul class="clearfix">
<li>', implode('</li><li>', $buttons), '</li>
</ul>
</div>';

}

?>

<?php
// Version: 2.0 Beta 4; index

/*   This template is, perhaps, the most important template in the theme. It
   contains the main template layer that displays the header and footer of
   the forum, namely with main_above and main_below. It also contains the
   menu sub template, which appropriately displays the menu; the init sub
   template, which is there to set the theme up; (init can be missing.) and
   the linktree sub template, which sorts out the link tree.

   The init sub template should load any data and set any hardcoded options.

   The main_above sub template is what is shown above the main content, and
   should contain anything that should be shown up there.

   The main_below sub template, conversely, is shown after the main content.
   It should probably contain the copyright statement and some other things.

   The linktree sub template should display the link tree, using the data
   in the $context['linktree'] variable.

   The menu sub template should display all the relevant buttons the user
   wants and or needs.

   For more information on the templating system, please see the site at:
   http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
   global 
$context$settings$options$txt;

   
/* Use images from default theme when using templates from the default theme?
      if this is 'always', images from the default theme will be used.
      if this is 'defaults', images from the default theme will only be used with default templates.
      if this is 'never' or isn't set at all, images from the default theme will not be used. */
   
$settings['use_default_images'] = 'never';

   
/* What document type definition is being used? (for font size and other issues.)
      'xhtml' for an XHTML 1.0 document type definition.
      'html' for an HTML 4.01 document type definition. */
   
$settings['doctype'] = 'xhtml';

   
/* The version this template/theme is for.
      This should probably be the version of SMF it was created for. */
   
$settings['theme_version'] = '2.0 Beta 4';

   
/* Set a setting that tells the theme that it can render the tabs. */
   
$settings['use_tabs'] = true;

   
/* Use plain buttons - as oppossed to text buttons? */
   
$settings['use_buttons'] = true;

   
/* Show sticky and lock status separate from topic icons? */
   
$settings['separate_sticky_lock'] = true;

   
/* Does this theme use the strict doctype? */
   
$settings['strict_doctype'] = false;

   
/* Does this theme use post previews on the message index? */
   
$settings['message_index_preview'] = false;
   
   
/* Call to Theme String for languages  */
    
if(loadlanguage('ThemeStrings') == false)
       
loadLanguage('ThemeStrings''english');
}

// The main sub template above the content.
function template_html_above()
{
   global 
$context$settings$options$scripturl$txt$modSettings;

   
// Show right to left and the character set for ease of translating.
   
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
   <meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
   <meta name="description" content="'
$context['page_title_html_safe'], '" />
   <meta name="keywords" content="'
$context['meta_keywords'], '" />
   <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/scripts/script.js?b4"></script>
   <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/scripts/theme.js?b4"></script>
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var smf_theme_url = "'
$settings['theme_url'], '";
      var smf_default_theme_url = "'
$settings['default_theme_url'], '";
      var smf_images_url = "'
$settings['images_url'], '";
      var smf_scripturl = "'
$scripturl'";
      var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
      var smf_charset = "'
$context['character_set'], '";'$context['show_pm_popup'] ? '
      if (confirm("' 
$txt['show_personal_messages'] . '"))
         window.open("' 
$scripturl '?action=pm");' '''
      var ajax_notification_text = "'
$txt['ajax_in_progress'], '";
      var ajax_notification_cancel_text = "'
$txt['modify_cancel'], '";
   // ]]></script>
   <title>'
$context['page_title_html_safe'], '</title>';

   
// Please don't index these Mr Robot.
   
if (!empty($context['robot_no_index']))
      echo 
'
   <meta name="robots" content="noindex" />'
;

   
// The ?b4 part of this link is just here to make sure browsers don't cache it wrongly.
   
echo '
   <link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style'$context['theme_variant'], '.css?b4" />';

   echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/css/print.css?b4" media="print" />';
   
   echo 
'
   <link rel="stylesheet" type="html" href="'
$settings['theme_url'], '/resources.html?b4" />';

   
// IE7 needs some fixes for styles.
   
if ($context['browser']['is_ie7'])
      echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/css/ie7.css" />';
   
// ..and IE6!
   
elseif ($context['browser']['is_ie6'])
      echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/css/ie6.css" />';

   
// Show all the relative links, such as help, search, contents, and the like.
   
echo '
   <link rel="help" href="'
$scripturl'?action=help" />
   <link rel="search" href="' 
$scripturl '?action=search" />
   <link rel="contents" href="'
$scripturl'" />';

   
// If RSS feeds are enabled, advertise the presence of one.
   
if (!empty($modSettings['xmlnews_enable']))
      echo 
'
   <link rel="alternate" type="application/rss+xml" title="'
$context['forum_name_html_safe'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

   
// If we're viewing a topic, these should be the previous and next topics, respectively.
   
if (!empty($context['current_topic']))
      echo 
'
   <link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
   <link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

   
// If we're in a board, or a topic for that matter, the index will be the board's index.
   
if (!empty($context['current_board']))
      echo 
'
   <link rel="index" href="'
$scripturl'?board='$context['current_board'], '.0" />';
        
// YSHOUT HERE - <head> code
   
global $boardurl,$shoutFile;
   
$shoutFile='home';
   
$scripturlparsed parse_url($scripturl);
   
$scriptpath=isset($scripturlparsed['path'])?$scripturlparsed['path']:'/';
   
$args='';
   foreach(
$_GET as $key => $value// passthrough $_GET
      
$args.='&'.urlencode($key).'='.urlencode($value);
   echo 
'
   <script src="'
,$boardurl,'/yshout/js/moo.ajax.js" type="text/javascript"></script>
   <script src="'
,$boardurl,'/yshout/settings.js" type="text/javascript"></script>
   <script type="text/javascript"><!-- // --><![CDATA[
   window.onload=function(){loadChat();};
   var shoutFile="'
,$shoutFile,'";
   var yshout_php="'
,$scriptpath,'?yshout',$args,'";
   // ]]></script>
   <script src="'
,$boardurl,'/yshout/js/yshout.js?July062008" type="text/javascript"></script>
   <style type="text/css">
      #yshout {
         font-size: 10px;
         overflow: hidden;
      }
      #yshout #yshout-toollinks { /* tool links (History, Commands, etc.) */
      }
      #yshout #shouts { /* main shouts area */
      }
      #yshout .shout { /* one shout */
         margin: 0 0 0; /* Top Bottom Linespacing */
         line-height: 1;
      }
      #yshout .shout-timestamp {
         font-style: normal;
         font-weight: normal;
      }
      #yshout .shout-adminlinks { /* del and ban buttons */
         font-size: 6pt;
         color: #141414;
      }
      #yshout #shout-form {
         margin: 0;
         padding: 0;
      }
      #yshout #shout-form fieldset {
         border: none;
      }
      #yshout #forum-name {
         width: 70px;
         margin-right: 5px;
      }
      #yshout #shout-text {
         width: 310px;
         margin-right: 5px;
      }
      #yshout #shout-button {
         width: 55px;
      }
      #yshout .shout-invalid { /* invalid shout (shout textbox) */
         background: #FFFDD1;
      }
   </style>'
;
   
// YSHOUT END - <head> code
       

   // We'll have to use the cookie to remember the header...
   
if ($context['user']['is_guest'])
   {
      
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
      
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
   }

   
// Output any remaining HTML headers. (from mods, maybe?)
   
echo $context['html_headers'], '
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      // Create the main header object.
      var mainHeader = new smfToggle("upshrink", '
, empty($options['collapse_header']) ? 'false' 'true'');
      mainHeader.useCookie('
$context['user']['is_guest'] ? 0');
      mainHeader.setOptions("collapse_header", "'
$context['session_id'], '");
      mainHeader.addToggleImage("upshrink", "/upshrink.gif", "/upshrink2.gif");
      mainHeader.addTogglePanel("user_section");
      mainHeader.addTogglePanel("news_section");
   // ]]></script>'
;
   
   echo 
'
    <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var PreloadImages = new Array(
         "/images/submenu_top.png",
         "/images/submenu_bg.png"
      );

      var myImages = new Array();
      for(var i = 0; i < PreloadImages.length; i++)
      {
         myImages[i] = new Image();
         myImages[i].src = "'
$settings['theme_url'] .'" + PreloadImages[i];
      }
    // ]]></script>'
;

   echo 
'
</head>
<body>'
;
}

function 
template_body_above()
{
   global 
$context$settings$options$scripturl$txt$modSettings;

echo 
'
   <div id="wrapper">
      <div id="shad-l">
         <div id="shad-r">
            <div id="head-l">
               <div id="head-r">
                   <div id="header">
                     <div id="userarea">'
;
         if (
$context['user']['is_logged'])
         {
            echo 
'
                     <b>'
$txt['hello_member_ndt'], ' '$context['user']['name'], '</b><br />';

            
// Only tell them about their messages if they can read their messages!
            
if ($context['allow_pm'])
               echo 
$txt['msg_alert_you_have'], ' <a href="'$scripturl'?action=pm">'$context['user']['messages'], ' '$context['user']['messages'] != $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>'$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

            echo 
'
                        <a href="'
$scripturl'?action=unread">',$txt['showunread2'],'</a>&nbsp;/
                        <a href="'
$scripturl'?action=unreadreplies">',$txt['showreplies2'],'</a>&nbsp;/
                        <a href="'
$scripturl'?action=profile;sa=showPosts">',$txt['ownposts2'],'</a><br />
                        '
$context['current_time'],'';

         }
         
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
         
else
         {
                 echo 
sprintf($txt['welcome_forum']);
            echo 
'
                        <br/>'
$context['current_time'],'<br />';
         }

                  echo 
'
                     </div>
                     
                  <a href="'
.$scripturl.'" title=""><span id="logo">&nbsp;</span></a>';
               echo 
'
                  </div>
               </div>
            </div>'
;

        
// YSHOUT HERE - shoutbox code
   
global $txt,$context,$boarddir;
   if(
allowedTo('yshout_view'))
   {
      echo 
'<br /><b>',$txt['yshout_shoutbox'],'</b><br /><br />';
      echo 
'<div id="yshout">';
      include_once(
$boarddir.'/yshout/yshout.php');
      echo 
'</div>';
   }
   elseif(
$context['user']['is_guest'])
      echo 
$txt['yshout_no_guests'];
   
// YSHOUT END - shoutbox code

            
echo '<div id="toolbar">
               '
,template_menu(),'
            </div>
            <div id="bodyarea">'
;

   
// Show the navigation tree.
   
theme_linktree();

}

function 
template_body_below()
{
   global 
$context$settings$options$scripturl$txt;

         echo 
'
            </div>'
;

            
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
         
echo '
            <div id="foot-l">
               <div id="foot-r">
                  <div id="footer">
                     <div id="footerarea">
            
            <span class="smalltext">Midnight Sun by <a href="http://www.dzinerstudio.com"><b>Antechinus</b></a> | <a href="'
$settings['theme_url'], '/resources.html?b4" target="_blank"><b>Resources</b></a> | <a href="http://www.dzinerstudio.com">DzinerStudio</a>
                                                 
            </span>'
;
   
         echo 
'
                     </div>
                  </div>
               </div>
            </div>'
;
            
            
// Show the load time?
   
echo'       
         <div id="basebar" style="height: 20px; text-align: center; ">     
            <span class="smalltext">'
theme_copyright(), ' </span>';         
            
            if (
$context['show_load_time'])
               echo 
'<span class="smalltext">| '$txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</span>';
    echo 
'
         </div>'
;   
}

function 
template_html_below()
{
   global 
$context$settings$options$scripturl$txt$modSettings;

   echo 
'
         </div>
      </div>
   </div>
</body></html>'
;
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show false)
{
   global 
$context$settings$options$shown_linktree;

   
// If linktree is empty, just return - also allow an override.
   
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
      return;

   
//!!! Temporarily don't do it twice.
   
if (!empty($shown_linktree))
      return;
   
$shown_linktree true;

   echo 
'
   <ul id="linktree">'
;

   
// Each tree item has a URL and name. Some may have extra_before and extra_after.
   
foreach ($context['linktree'] as $link_num => $tree)
   {
      echo 
'
      <li'
, ($link_num == count($context['linktree']) - 1) ? ' class="last"' '''>';
      
// Show something before the link?
      
if (isset($tree['extra_before']))
         echo 
$tree['extra_before'];

      
// Show the link, including a URL if it should have one.
      
echo $settings['linktree_link'] && isset($tree['url']) ? '
         <a href="' 
$tree['url'] . '"><span>' $tree['name'] . '</span></a>' '<span>' $tree['name'] .'</span>';

      
// Show something after the link...?
      
if (isset($tree['extra_after']))
         echo 
$tree['extra_after'];

      
// Don't show a separator for the last one.
      
if ($link_num != count($context['linktree']) - 1)
         echo 
'&nbsp;>';

      echo 
'
      </li>'
;
   }
   echo 
'
   </ul>'
;
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global 
$context$settings$options$scripturl$txt;

   echo 
'   
      <div class="tabs">
         <ul>'
;
            foreach (
$context['menu_buttons'] as $act => $button)
    {         
             echo 
'   <li><a '$button['active_button'] ? ' class="current"' '' ' href="'$button['href'], '">
                        <span class="menu-left"></span>
                      <span class="menu-right">' 
$button['title'] , '</span></a>';
                     
          
//    Does this button have any subbuttons?
        
if(!empty($button['sub_buttons']))
        {
            echo 
'
                             <div class="sub">
                         <ul>'
;
            foreach(
$button['sub_buttons'] as $sub_button)
                    echo 
'
                <li><a href="'
$sub_button['href'], '">' $sub_button['title'] , '</a></li>';
            echo 
'
                                 </ul>                      
                      </div>'
;                       
         }
      
       echo
' </li>';
      
    }
   
   echo 
'
         </ul>
      </div>'
;

}

// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
   global 
$settings$context$txt$scripturl;

   
// Create the buttons...
   
$buttons = array();
   foreach (
$button_strip as $key => $value)
   {
      if (!isset(
$value['test']) || !empty($context[$value['test']]))
         
$buttons[] = '<a href="' $value['url'] . '" ' . (isset($value['custom']) ? $value['custom'] : '') . '><span>' $txt[$value['text']] . '</span></a>';
   }

   if (empty(
$buttons))
      return 
'';

   
// Make the last one, as easy as possible.
   
$buttons[count($buttons) - 1] = str_replace('<span>''<span class="last">'$buttons[count($buttons) - 1]);

   echo 
'
      <div class="buttonlist'
$direction != 'top' '_bottom' '''">
         <ul class="clearfix">
            <li>'
implode('</li><li>'$buttons), '</li>
         </ul>
      </div>'
;

}

?>


Try that.

_Anthony_

Quote from: changaroo on January 22, 2009, 09:04:58 PM
<?php
// nneonneo's AJAX shoutbox
// Version 1.22

// Figure out where the yshout folder is
global $yshoutdir;
$yshoutdir=(defined('SMF')||isset($yshout_from_index))?'yshout/':'';
// Check configuration files
if(!file_exists($yshoutdir.'settings.php'))
{
echo 'Error: No settings.';
return;
}
if(!
file_exists($yshoutdir.'_banlist.php'))
{
// If _banlist.php has been deleted, assume it should be reset to defaults
$ban_ips_readpost=$ban_ips_post=$ban_names_readpost=$ban_names_post=array();
$sbMaintenance=false;
writeBanList();
}
// Load settings
require_once($yshoutdir."settings.php");
global 
$ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$sbMaintenance;
require_once(
$yshoutdir.'_banlist.php');
// Figure out which file we're logging chats to
global $shoutFile;
if(!isset(
$shoutFile))
$shoutFile='home';
if(isset(
$_REQUEST['file']))
$shoutFile=$_REQUEST['file'];
$shoutFile=preg_replace('/[^A-Za-z0-9_]/','',$shoutFile);
global 
$chatPath,$historyPath;
$chatsFullDir=$yshoutdir.$chatsDir.'/';
$chatPath=$chatsFullDir.sprintf($chatFormat,$shoutFile);
$historyPath=($historyFormat==='')?'':$chatsFullDir.sprintf($historyFormat,$shoutFile);

// If the shoutbox isn't require'd from SMF, we need to load some SMF components.
$loadedFromSMF=true;
if(!
defined('SMF'))
{
$loadedFromSMF=false;
session_start();
require(dirname(__FILE__) . "/../SSI.php");
require_once($sourcedir '/Subs-Post.php');
$defaultEncoding=(empty($context['character_set']) ? 'ISO-8859-1' $context['character_set']);
header('Content-type: text/html; charset='.$defaultEncoding);
}
// Set up some useful globals
global $func,$smcFunc,$ip,$isSMF1,$user;
$ip $_SERVER['REMOTE_ADDR'];
$isSMF1 = isset($func);
if(!
$isSMF1)
$func=$smcFunc;
$maxLines+=1// off-by-one correction
$user=$context['user']; // shortcut, for brevity
if(!$loadedFromSMF)
{
loadUserSettings();
loadPermissions();
loadTheme();
writeLog(); // mark user as online
}
// Are you banned from reading the shoutbox?
if(in_array($ip$ban_ips_readpost) || in_array($user['username'], $ban_names_readpost) || in_array($user['name'], $ban_names_readpost))
{
echo $txt['yshout_banned'];
return;
}
if(!
allowedTo('yshout_view'))
{
if(isGuest())
echo $txt['yshout_no_guests'];
return;
}

// Check guest status and grab guest username
if(isGuest())
{
if($autoGuestName!==false)
$user['username']=$user['name']=$_COOKIE['username']=$autoGuestName.substr(md5($ip),0,4);
elseif(isset($_POST['username']) || isset($_COOKIE['username']))
{
$requsername=isset($_POST['username'])?$_POST['username']:$_COOKIE['username'];
$requsername=$func['htmlspecialchars'](html_entity_decode(urldecode($requsername)),ENT_QUOTES);
$user['username']=$user['name']=$_COOKIE['username']=$requsername;
}
}
// Check user group membership
$user['is_sbmod']=false;
$user['can_sbpost']=false;
if(
allowedTo('yshout_moderate'))
$user['is_sbmod']=true;
if(
allowedTo('yshout_post'))
$user['can_sbpost']=true;

if(
$loadedFromSMF)
{
// Initialize the shoutbox and quit
initShoutbox($user,true);
return;
}

// Permission checks
function isGuest($user=false)
{
if($user===false) global $user;
return !$user['is_logged'];
}

function 
isMod($user=false)
{
if($user===false) global $user;
return $user['is_admin'] || $user['is_sbmod'];
}

function 
isPostBanned($user=false)
{
global $ip,$ban_ips_post,$ban_names_post;
if($user===false) global $user;
return in_array($ip$ban_ips_post) || in_array($user['username'], $ban_names_post) || in_array($user['name'], $ban_names_post);
}

// $_GET commands
// administrative: ban/unban and delete
if(isset($_GET['banid']))
{
if(!isset($_GET['mode']))
{
global $boardurl;
doMsg(<<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<base href="
$boardurl/" />
<meta http-equiv="content-type" content="text/html; charset=
$defaultEncoding" />
<title>
{$txt['yshout_ban_conf']}</title>
<script type="text/javascript">
//<![CDATA[
function ajaxGet(args) {
window.location=window.location+'&'+args;
}
//]]>
</script>
</head>
<body>
<h1>
{$txt['yshout_select_mode']}</h1>
<p><a href="javascript:ajaxGet('banid=
{$_GET['banid']}&amp;sesc={$_GET['sesc']}&amp;mode=rp');">{$txt['yshout_rp']}</a></p>
<p><a href="javascript:ajaxGet('banid=
{$_GET['banid']}&amp;sesc={$_GET['sesc']}&amp;mode=p');">{$txt['yshout_p']}</a></p>
</body>
</html>
EOF
);
exit;
}
if(isMod())
{
$error=checkSession('request','',false);
if($error!=='')
{
loadLanguage('Errors');
die($txt[$error]);
}
if(!is_numeric($_GET['banid']))
{
// not an ID, so probably an IP
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_ips_',$_GET['mode'],$_GET['banid']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
exit;
}
if(loadMemberData(Array($_GET['banid']),false,'minimal')===false)
{
doMsg($txt['yshout_error'].$txt['yshout_no_user']);
exit;
}
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_names_',$_GET['mode'],$user_profile[$_GET['banid']][$isSMF1?'memberName':'member_name']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
}
exit;
}

if(isset(
$_GET['unban']))
{
if(isMod())
{
$oldread=isset($_SESSION['readingCmd'])?$_SESSION['readingCmd']:NULL;
doBan('ban_'.$_GET["type"].'s_','u',$_GET['unban']);
if($oldread==NULL) unset($_SESSION['readingCmd']);
else $_SESSION['readingCmd']=$oldread;
}
exit;
}

if(isset(
$_GET['delete']))
{
if(isMod())
{
$error=checkSession('request','',false);
if($error!=='')
{
loadLanguage('Errors');
die($txt[$error]);
}
$success=deleteShout($_GET['delete'],$chatPath);
if(isset($_GET['history']) && !$success)
$success=deleteShout($_GET['delete'],$historyPath);
if($success)
echo $txt['yshout_del_success'];
}
exit;
}
// Regular user $_GET commands: history, help
if(isset($_GET["history"]))
{
history();
exit;
}

if(isset(
$_GET["help"]))
{
help();
exit;
}
// If $_GET doesn't carry a command, check the request type
if(!isset($_POST["reqtype"]))
{
echo $txt['yshout_no_action'];
return;
}

$reqType $_POST["reqtype"];

function 
initShoutbox($user,$fromSMF)
{
// This function initializes the shoutbox: it prints the tool links,
// current shouts and shout form
global $gzipCompression,$txt,$user,$maxUsernameChars,$maxShoutChars,$sbMaintenance,$autoGuestName,$shoutFormOnTop;
if($gzipCompression && !$fromSMFob_start("ob_gzhandler");
// Language check -- only admins will see this
if($user['is_admin'] && !isset($txt['yshout_history']) && !isset($_COOKIE['yShout_read_txt_notice']))
{
global $user_info,$language,$settings;
$user_language=isset($user_info['language']) ? $user_info['language'] : $language;
if($user_language != 'english' || $settings['theme_dir'] != $settings['default_theme_dir'])
echo '<span style="color:red;background:white">
Warning! The shoutbox text files for your language are not installed.
This may cause the shoutbox and admin settings to appear wrong.<br /><br />
To fix this problem, copy <strong>'
,$settings['default_theme_dir'],'/languages/Modifications.english.php</strong>
to <strong>'
,$settings['theme_dir'],'/languages/Modifications.',$user_language,'.php</strong> and translate as desired.<br /><br />
To <strong>ignore</strong> this notice, click <a href="javascript:set_cookie(\'yShout_read_txt_notice\',\'true\',3600*24*365);delete_cookie(\'yShout_open\');loadChat();">here</a>.<br /><br /></span>'
;
}
// Tool links (History, Commands, etc.)
echo '<span id="yshout-toollinks">';
echo '[<a href="javascript:goTo(\'history\')">',$txt['yshout_history'],'</a>] ';
echo '[<a href="javascript:goTo(\'help\')">',$txt['yshout_commands'],'</a>]';
if(isMod())
{
echo ' [<a href="javascript:history_number=prompt(\'How far back?\',200);if(history_number){goTo(\'history&amp;n=\'+history_number)}else{void(0)}">',$txt['yshout_exthistory'],'</a>]';
if(!isset($_COOKIE['yShout_hideadmlinks']))
echo ' [<a href="javascript:set_cookie(\'yShout_hideadmlinks\',\'true\',3600*24*365);delete_cookie(\'yShout_open\');loadChat();">',$txt['yshout_hide'],$txt['yshout_admlinks'],'</a>]';
else
echo ' [<a href="javascript:delete_cookie(\'yShout_hideadmlinks\');delete_cookie(\'yShout_open\');loadChat();">',$txt['yshout_show'],$txt['yshout_admlinks'],'</a>]';
echo ' [<a href="javascript:autoShout(\'/return\');">',$txt['yshout_return'],'</a>]';
}
echo '</span>'// yshout-toollinks
if(!$shoutFormOnTop)
echo '<div id="shouts">',readChat(),'</div>';
// Shout form
echo '
<form id="shout-form" name="shout_form" action="#" onsubmit="doSend();return false;">
<fieldset>'
;
$inputForumName=' <input id="forum-name" type="text" maxlength="'.$maxUsernameChars.'" ';
$inputShoutText=' <input id="shout-text" type="text" maxlength="'.$maxShoutChars.'" ';
$inputShoutButton=' <input id="shout-button" type="submit" ';
if(isPostBanned())
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',$txt['yshout_p_banned'],'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_banned'],'" disabled="disabled" />';
elseif(!isMod() && $sbMaintenance!==false)
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',$sbMaintenance,'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_maintenance'],'" disabled="disabled" />';
elseif(!$user['can_sbpost'])
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />
'
,$inputShoutText,'value="',isGuest()?$txt['yshout_no_guests']:$txt['yshout_no_posting'],'" disabled="disabled" />
'
,$inputShoutButton,'value="',$txt['yshout_maintenance'],'" disabled="disabled" />';
else
{
if(isGuest() && $autoGuestName===false)
echo '
'
,$inputForumName,'value="',$user['name'], '" />';
else
echo '
'
,$inputForumName,'value="',$user['name'], '" disabled="disabled" />';
echo '
'
,$inputShoutText,'value="" />
'
,$inputShoutButton,'value="',$txt['yshout_shout_button'],'" />';
}
echo '
</fieldset>
</form>'
;
if($shoutFormOnTop)
echo '<div id="shouts">',readChat(),'</div>';
if($gzipCompression && !$fromSMFob_end_flush();
}
// Figure out the request
switch($reqType) {
case "init":
initShoutbox($user,false);
break;
case "shout":
if(isPostBanned()) break;
if(!$user['can_sbpost']) break;
if(!isMod() && $sbMaintenance!==false) break;
$shoutText $_POST["shout"];
if($shoutText[0]=='/' && $allowCommands)
{
if(isMod())
{
if(processCommand($shoutText))
break;
}
elseif(!isGuest() || $guestCommands)
{
$shoutText=substr($shoutText,0,$maxShoutChars);
if(processUserCommand($shoutText)) break;
}
}
$shoutName $user['name'];

if(!isMod())
$shoutText=substr($shoutText,0,$maxShoutChars);

makeShout($shoutText,$user);
break;
case "refresh":
refreshChats(false);
break;
case "autoshout":
if(isMod())
processCommand($_POST["shout"]);
break;
}

function 
doMsg($msg)
{
echo $msg// tell user
$_SESSION['readingCmd']=$msg// make sure user keeps seeing this message; see readChat
}

function 
processCommand($text) {
global $reqType$maxLines$ip$user$bannedCommands$txt$sbMaintenance;
global $ban_ips_readpost$ban_ips_post$ban_names_readpost$ban_names_post;
if($text[0]!='/') return false// no slash, no service
$data=explode(' ',$text,2); // "2" means to make the first "word" separated from the rest
$cmd=$data[0]; // first word is the cmd. No cmds can have spaces.
$args=(isset($data[1])?$data[1]:''); // are there even any arguments?
if(in_array($cmd,$bannedCommands)) return false;
switch($cmd) {
case "/clear":
global $chatPath$historyPath;
$fileContents='';
if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);
$handle=fopen($chatPath'w');
fputs($handle,'');
fclose($handle);
if($historyPath !== '')
{
$handle=fopen($historyPath'a');
fputs($handle,$fileContents);
fclose($handle);
}
return true;
case "/return"// I'm done reading
unset($_SESSION['readingCmd']);
echo readChat();
return true;
case "/lock":
if($args=='')
{
doMsg($txt['yshout_error'].$txt['yshout_lock_arg_error']);
return true;
}
if($sbMaintenance !== false)
doMsg(sprintf($txt['yshout_lock_changed'],$args));
else
doMsg(sprintf($txt['yshout_lock_success'], $args));
$sbMaintenance $args;
writeBanList();
return true;
case "/unlock":
if($sbMaintenance === false)
{
doMsg($txt['yshout_error'].$txt['yshout_unlock_already']);
return true;
}
$sbMaintenance false;
writeBanList();
doMsg($txt['yshout_unlock_success']);
return true;
case "/banlist"// who's banned?
$_SESSION['readingCmd']=$text;
$temp=Array();
echo '<table>
<caption>'
,$txt['yshout_banlist_caption'],'</caption>';
echo '<tr><td>',$txt['yshout_ip_bans'],$txt['yshout_rp'],'</td><td>';
$temp=Array();
foreach($ban_ips_readpost as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=ip');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_ip_bans'],$txt['yshout_p'],'</td><td>';
$temp=Array();
foreach($ban_ips_post as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=ip');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_username_bans'],$txt['yshout_rp'],'</td><td>';
$temp=Array();
foreach($ban_names_readpost as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=name');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '<tr><td>',$txt['yshout_username_bans'],$txt['yshout_p'],'</td><td>';
$temp=Array();
foreach($ban_names_post as $i)
$temp[]="<a href=\"javascript:ajaxGet('unban=$i&type=name');\">$i</a>";
echo implode($temp,','),'</tr>';
echo '</table>';
return true;
case "/ban"// need to be more specific!
doMsg($txt['yshout_error'].$txt['yshout_ban_type_error']);
return true;
case "/banuser":
case "/banip":
$type=($cmd=='/banip')?'ban_ips_':'ban_names_'// prefixes for variables
$ar=explode(' ',$args,2); // true argument array. the "2" ensures that we cut only once: mode can't have spaces but user can.
if(count($ar)!=2// whoops: only one argument?
{
doMsg($txt['yshout_error'].$txt['yshout_ban_mode_error']);
return true;
}
$mode=$ar[0]; // set up vars
$id=$ar[1];
doBan($type,$mode,$id);
return true;
case "/impersonate":
// <user> [userlevel] [ip] [userid] /[shout text]
$slashpos=strpos($args,' /'); // use ' /' as a separator, so we can see how many args came before
if($slashpos===false// no shout? invalid formatting?
{
doMsg($txt['yshout_error'].$txt['yshout_imp_slash_error']);
return true;
}
$shout=substr($args,$slashpos+2);
$ar=explode(' ',substr($args,0,$slashpos));
$name='';
$userlevel=0;
$userid=0;

switch(count($ar)) // how many args did we get?
{
case 0// no args
doMsg($txt['yshout_error'].$txt['yshout_imp_uname_error']);
return true;
case 4// reverse order to save space: we just set them from the back!
$userid=intval($ar[3]);
case 3:
$ip=$ar[2]; // corrupt the global >:D
case 2:
$userlevel=intval($ar[1]);
case 1:
$name=html_entity_decode($ar[0]);
break;
default:
doMsg($txt['yshout_error'].$txt['yshout_imp_max4_error']); // just so they know that we only have 4 params
return true;
}
$ip.='.'// to set off the impersonated msgs
$fakeuser=array('id'=>$userid,'name'=>$name,'is_admin'=>($userlevel==2)?1:0,'is_sbmod'=>($userlevel==1)?1:0,'is_logged'=>($userlevel==-1)?0:1); // fake SMF $user array
makeShout($shout,$fakeuser);
return true;
default: // not a command
return processUserCommand($text);
}
return false;
}

function 
processUserCommand($text) {
global $reqType,$chatPath,$historyPath,$maxLines,$ip,$ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$user,$bannedCommands,$func;
if($text[0]!='/') return false// no slash, no service
$data=explode(' ',$text,2); // "2" means to make the first "word" separated from the rest
$cmd=$data[0]; // first word is the cmd. No cmds can have spaces.
$args=(isset($data[1])?$data[1]:''); // are there even any arguments?
if(in_array($cmd,$bannedCommands)) return false;
switch($cmd) {
case "/help":
if(empty($args)) help();
elseif($args[0]!='/'help('/'.$args);
else help($args);
$_SESSION['readingCmd']=$text;
return true;
case "/return"// I'm done reading
unset($_SESSION['readingCmd']);
echo readChat();
return true;
case "/pi":
$s_pi='141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';
$n=5;
if($args!=''$n=intval($args);
$res=($n==0)?"PI IS EXACTLY 3!":'3.'.substr($s_pi,0,$n-1).(substr($s_pi,$n-1,1)+(substr($s_pi,$n,1)>=5?1:0));
// all that nasty little bit does is add the first n-2 chars, then add the last digit and increment if rounding is necessary.
makeShout($res);
return true;
case "/me":
$newText cleanupShout($args.' ');
$shoutName=$user['name'];
makeRawShout("<span class=\"meaction\"> * $shoutName $newText</span>",$user);
return true;
default:
return false;
}
return false;
}
// utility functions for banning and deleting
function doBan($type,$mode,$id)
{
global $ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$txt;
switch($mode)
{
case 'u'// nice guy
$r=$type.'readpost'// need to search both ban arrays. Search this one first...
$index=array_search($id,$$r); // where is my little banned user?
if($index===false)
{
$r=$type.'post'// ...and this one second on failure.
$index=array_search($id,$$r);
if($index===false// whoops, both searches failed!
{
doMsg($txt['yshout_error'].'Couldn\'t find user to unban!');
return false;
}
}
array_splice($$r,$index,1); // cut the 1 element loose with splice. $$r is used because $r is the string variable denoting the target array.
doMsg("Success: unbanned $id.");
break;
case 'rp':
array_push(${$type.'readpost'},$id); // easy, huh!
doMsg("Success: banned $id from reading and posting.");
break;
case 'p':
array_push(${$type.'post'},$id);
doMsg("Success: banned $id from posting.");
break;
default:
doMsg($txt['yshout_error']."Invalid mode $mode! Use only 'u', 'rp' or 'p'!");
return false;
}
writeBanList(); // write the final report
return true;
}

function 
writeBanList() // generate our dynamic ban list, which is 'require'd at the start of this script
{
global $ban_ips_readpost,$ban_ips_post,$ban_names_readpost,$ban_names_post,$sbMaintenance,$yshoutdir;
$writeText "<"."?php\n"// php header
$writeText .= '$ban_ips_readpost = '.var_export($ban_ips_readpost,true).";\n"// bans
$writeText .= '$ban_ips_post = '.var_export($ban_ips_post,true).";\n";
$writeText .= '$ban_names_readpost = '.var_export($ban_names_readpost,true).";\n";
$writeText .= '$ban_names_post = '.var_export($ban_names_post,true).";\n";
$writeText .= '$sbMaintenance = '.var_export($sbMaintenance,true).";\n";
$writeText .= '?'.'>'// end tag
$handle fopen($yshoutdir."_banlist.php""w");
if($handle===false) die('File error (writeBanList); aborted');
$failcount=0;
while( !flock($handleLOCK_EX) ) // just IN CASE two bans happen simultaneously
{
usleep(50000);
$failcount++;
if($failcount 20) die('Write error (writeBanList); aborted'); // one second
}
fwrite($handle$writeText);
flock($handleLOCK_UN);
fclose($handle);
}

function 
deleteShout($spanTitle$chatPath) {
$fileContents '';

if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);
$newFileContents=preg_replace('/<p[^>]*><span class="shout-timestamp" title="'.str_replace('|','\|',$spanTitle).'">.+\n/','',$fileContents);
if($fileContents == $newFileContents) return false;
$handle fopen($chatPath"w");
fputs($handle$newFileContents);
fclose($handle);
return true;
}

// utility functions for shouting
function cleanupShout($text) {
global $func,$bannedCode,$context;
$text $func['htmlspecialchars'](stripslashes($text), ENT_QUOTES);
foreach($bannedCode as $searchString)
$text preg_replace('/'.preg_quote($searchString,'/').'/i','',$text);
preparsecode($text);
$text parse_bbc($text);
censorText($text);
return $text;
}

function 
makeShout($text,$user=false) {
if($user===false)
global $user;
$text cleanupShout($text.' ');

$a_style "";
global $user_profile;
if(loadMemberData(Array($user['id']),false,'profile')!==false)
{
$profile=$user_profile[$user['id']];
$a_style ' class="userclass" style="color: '.(empty($profile['member_group_color']) ? $profile['post_group_color'] : $profile['member_group_color']).'"';
}

$shoutName=$user['name'];
$userID=$user['id'];
if(isGuest($user))
$writeText=$shoutName;
else
$writeText="<a$a_style href=\"index.php?action=profile;u=$userID\">$shoutName</a>";
$writeText.=": $text";
makeRawShout($writeText,$user);
}

function 
makeRawShout($text,$user=false) {
global $maxLines,$chatPath,$historyPath,$ip;

if($user===false)
global $user;

$emTitle=time()." | $ip";
$banID=isGuest($user)?$ip:$user['id'];
$timestamp="<span class=\"shout-timestamp\" title=\"$emTitle\"><timeval=".time()."></span>";
$delLink="<a href=\"javascript:ajaxGet('delete=$emTitle&amp;sesc=<sesc>')\">del</a>";
$banLink="<a href=\"javascript:ajaxGet('banid=$banID&amp;sesc=<sesc>')\">ban</a>";
$adminlinks="<span class=\"shout-adminlinks\">$delLink&nbsp;$banLink&nbsp;</span>";
writeLine("<p class=\"shout\">$timestamp&nbsp;$adminlinks$text</p>\n",$chatPath);
truncateChat($maxLines,$chatPath,$historyPath);
refreshChats(true);
}

function 
truncateChat($maxLines,$chatPath,$historyPath) {
$fileContents '';

if(file_exists($chatPath))
$fileContents file_get_contents($chatPath);

$lines explode("\n"$fileContents);

if(count($lines) > $maxLines) {
$newText substr($fileContentsstrpos($fileContents"\n") + 1);
$handle fopen($chatPath"w");

fputs($handle$newText);
fclose($handle);

if($historyPath !== '')
{
// History
$oldText substr($fileContents0strpos($fileContents"\n") + 1);
$handle fopen($historyPath"a");
fputs($handle$oldText);
fclose($handle);
}
}
}

function 
writeLine($writeText,$chatPath) {
$handle fopen($chatPath"a");
if($handle===false) die('File error (writeLine); aborted');
$failcount=0;
while( !flock($handleLOCK_EX) ) // just IN CASE two shouts happen simultaneously
{
usleep(50000);
$failcount++;
if($failcount 20) die('Write error (writeLine); aborted'); // one second
}
fwrite($handle$writeText);
flock($handleLOCK_UN);
fclose($handle);
}

// utility functions for reading shouts
function processChats($chatText$user=false) {
if($user===false)
global $user;
if(!isMod($user) || isset($_COOKIE['yShout_hideadmlinks']))
$chatText preg_replace('/<span class="shout-adminlinks".+?<\/span>/','',$chatText);
if(!isMod($user))
$chatText preg_replace('/<span class="shout-timestamp" title="(\d+) \| [0-9\.]+">/','<span class="shout-timestamp" title="\\1 | logged">',$chatText);
global $sc;
if(isMod($user))
$chatText preg_replace('/<sesc>/',$sc,$chatText);
$chatText=preg_replace_callback("/<timeval=(\d+)>/","preg_timeformat",$chatText);
return $chatText;
}

function 
readChat($chatPath=false$force=false) {
global $user,$reverseShouts;
if($chatPath === false)
global $chatPath;
if(isset($_SESSION['readingCmd']) && !$force)
{
$c=$_SESSION['readingCmd'];
if($c[0]=='/'// it's a command, redo command to retain the message
{
if(isMod()) processCommand($c);
else processUserCommand($c);
}
else
echo $c;
return ' ';
}
$chatText "";

if(file_exists($chatPath))
$chatText file_get_contents($chatPath);
$chatText=processChats($chatText,$user);
if($reverseShouts)
$chatText=implode("\n"array_reverse(explode("\n"$chatText)));
return $chatText.' '// hack: totally empty responses can break some browsers
}

function 
refreshChats($forceRefresh=false) {
global $chatPath,$user,$maxLines,$gzipCompression,$updateTimeout,$updatePeriod;
if(!file_exists($chatPath))
writeLine('',$chatPath);
$time=filemtime($chatPath);
$start_time=time();
$heartBeatSent=false;
if(!$forceRefresh)
{
session_write_close(); // so that future session requests succeed
while((time() - $start_time $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
@session_start(); // restart session, so updates to $_SESSION are applied
}
if($gzipCompression && !$heartBeatSentob_start("ob_gzhandler");
echo readChat();
if($gzipCompression && !$heartBeatSentob_end_flush();
}

// help and history handlers
function help($command='')
{
global $user,$defaultEncoding,$txt;
$cmdlist=$txt['yshout_cmdlist'];

$cmdlistadmin=$txt['yshout_cmdlistadmin'];
if(isMod())
$cmdlist=array_merge($cmdlist,$cmdlistadmin);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=<?php echo $defaultEncoding ?>" />
<title><?php echo $txt['yshout_cmd_reference']; ?></title>
<style type="text/css">
/*<![CDATA[*/
.meaction {
color: red;
}
/*]]>*/
</style>
</head>
<body>
<?php
if($command=='')
{
echo '<h1>',$txt['yshout_shoutbox'],' ',$txt['yshout_commands'],'</h1><div>';
foreach($cmdlist as $cmd=>$desc)
{
echo "$cmd$desc<br />\n";
}
echo '</div>';
}
else
{
echo '<div>';
if(isset($cmdlist[$command])) echo "$command{$cmdlist[$command]}<br />\n";
else echo "$command not found";
echo '</div>';
}
?>

</body>
</html>
<?php
}

function 
history()
{
global $chatPath,$historyPath,$boardurl,$gzipCompression,$defaultEncoding,$txt;

$n=250;
if(isset($_GET['n'])) $n=intval($_GET['n']); // integers only!
if($gzipCompressionob_start("ob_gzhandler");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<base href="<?php echo $boardurl,'/'?>" />
<meta http-equiv="content-type" content="text/html; charset=<?php echo $defaultEncoding ?>" />
<title><?php echo $txt['yshout_shoutbox'],' ',$txt['yshout_history']; ?></title>
<script type="text/javascript">
//<![CDATA[
function ajaxGet(args) {
window.location=window.location+'&'+args+'&'+'sesc=<?php global $sc; echo $sc?>';
}
//]]>
</script>
<style type="text/css">
/*<![CDATA[*/
/* form and toollink CSS omitted */
#yshout {
font-size: 10px;
overflow: hidden;
}
#yshout #shouts { /* main shouts area */
color: #000000;
}
#yshout .shout { /* one shout */
margin: 0 0 0; /* Top Bottom Linespacing */
line-height: 1;
}
#yshout .shout-timestamp {
font-style: normal;
font-weight: normal;
color: #000000;
}
#yshout .shout-adminlinks { /* del and ban buttons */
font-size: 6pt;
color: #141414;
}
/* from default theme */
.meaction {
color: red;
}
a:link {
color: #476C8E;
}
/*]]>*/
</style>
</head>
<body>
<h1><?php echo $txt['yshout_shoutbox'],' ',$txt['yshout_history']; ?></h1>
<div id="yshout">
<div id="shouts">
<?php
$text='';
if($historyPath !== '')
{
global $user;
require_once("class.tail.php");
$mytail = new tail($historyPath);
$mytail->setGrep(".*");
$mytail->setNumberOfLines($n);
$text=$mytail->output(PLAIN);
}
$text.=file_get_contents($chatPath);
echo processChats($text,$user);
?>

</div>
</div>
</body>
</html>
<?php
if(
$gzipCompressionob_end_flush();
exit;
}
?>

Ohhh, sorry I meant Index.template.php.

Quexinos

So am I the only one who can't get a fixed height on this thing?

_Anthony_

Quote from: Quexinos on January 24, 2009, 03:11:05 AM
So am I the only one who can't get a fixed height on this thing?
You edit the edit the yshout #shouts css code for height:Xpx then upload, then ctrl+f5

Quexinos

#4977
... I'm not entirely sure what you said there but I think I can figure it out, thanks ^_^..

actually what file am I supposed to edit?
NM found it, thanks.

One last question
What happens if I did the scroll bar thing and a scroll bar didn't show up at all ? O_o

_Anthony_

Quote from: Quexinos on January 24, 2009, 04:16:41 AM
... I'm not entirely sure what you said there but I think I can figure it out, thanks ^_^..

actually what file am I supposed to edit?
NM found it, thanks.

One last question
What happens if I did the scroll bar thing and a scroll bar didn't show up at all ? O_o
Try to set the Max Lines higher in yshout/settings.php

changaroo


Advertisement: