1
Mods & Plugins (Releases & Support) / Re: [MOD] Shoutbox
« on: May 09, 2010, 09:14:21 PM »
meine shout.php
Code: [Select]
<?php
/*************************************\
** **
** Shoutbox Mod for 4images **
** Version: v1.0 **
** By: f1do **
** Email: f1do.987@gmail.com **
** Web: http://f1do.uni.cc **
** **
\*************************************/
define('SHOUTBOX_TABLE', $table_prefix.'shoutbox');
function get_num_words ($text) {
$text_words = explode (" ", $text);
$text_words = sizeof ($text_words);
return $text_words;
}
//--------------------------------------------------------------------------
//---------------Save Shouts------------------------------------------------
//--------------------------------------------------------------------------
$shout = $HTTP_POST_VARS['shout'];
if ($shout == "shout it!") {
$shout_user = $HTTP_POST_VARS['shout_user'];
$shout_message = $HTTP_POST_VARS['shout_message'];
$shout_message = trim ($shout_message);
$shout_date = time();
$shout_ip = $session_info['session_ip'];
if ($session_info['session_user_id']) {
$shout_user_id = $user_info['user_id'];
}
$errormsg = "";
if (empty($shout_message)) {
$errormsg = $lang['sh_e_nomessage'];
}
elseif (empty($shout_user)) {
$errormsg = $lang['sh_e_nouser'];
}
elseif (strlen($shout_user) > $config['sh_usr_lgth']) {
$errormsg = $lang['sh_e_usrlgth'];
}
elseif (get_num_words ($shout_message) > $config['sh_msg_lgth']) {
$errormsg = $lang['sh_e_msglgth'];
}
elseif (!$config['sh_active']) {
$errormsg = $lang['sh_e_inactive'];
}
else {
$shout_message = safe_htmlspecialchars($shout_message);
$sql = "INSERT INTO ".SHOUTBOX_TABLE."(name,message,date,ip,usrid) VALUES('$shout_user','$shout_message','$shout_date','$shout_ip','$shout_user_id')";
$result = $site_db->query($sql);
}
$site_template->register_vars(array("errormsg"=>$errormsg));
}
unset ($errormsg);
//----------------------------------------------------------------------------
//---------------Show Shouts--------------------------------------------------
//----------------------------------------------------------------------------
$shouts = array();
$sql = "SELECT * FROM ".SHOUTBOX_TABLE." ORDER BY id DESC";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$shouts[] = $row;
}
$num_shouts = sizeof ($shouts);
if ($num_shouts > $config['sh_msg_display']) {
$num_shouts = $config['sh_msg_display'];
}
$shoutings = "";
for ($i = 0; $i < $num_shouts; $i++) {
$message = $shouts[$i]['message'];
$message = un_htmlspecialchars($message);
$message = format_text($message, $config['sh_html'], $config['sh_wordwrap'], $config['sh_bbcode'], $config['sh_bbimg']);
$message = replace_url($message);
$admin_shout = "";
if ($session_info['session_user_id'] != -1) {
if (($user_info['user_id'] == $shouts[$i]['usrid']) || ($user_info['user_level'] == ADMIN)){
$admin_shout = "<a href=\"".$site_sess->url(ROOT_PATH."shout_editor.php?action=edit&shout_id=".$shouts[$i]['id'])."\" target=\"_blank\" onClick=\"return popup(this,'edit_shout')\">[Bearbeiten]</a><a href=\"".$site_sess->url(ROOT_PATH."shout_editor.php?action=delete&shout_id=".$shouts[$i]['id'])."\" target=\"_blank\" onClick=\"return popup(this,'delete_shout')\">[Löschen]</a>";
}
}
if ($shouts[$i]['usrid'] != GUEST) {
$prof_linka = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$shouts[$i]['usrid'])."\">";
$prof_linkb = "</a>";
}
else {
unset ($prof_linka, $prof_linkb);
}
$site_template->register_vars(array(
"prof_linka"=>$prof_linka,
"prof_linkb"=>$prof_linkb,
"shoutusr"=>$shouts[$i]['name'],
"shoutdate"=>date('j.n.Y / G:i', $shouts[$i]['date']),
"shoutmsg"=>$message,
"admin_shout"=>$admin_shout
));
$shoutings .= $site_template->parse_template("shout_bit");
}
unset ($admin_shout);
$shout_form = "";
if ($config['sh_allow_guests'] || $session_info['session_user_id']) {
$site_template->register_vars(array(
"name"=>$user_info['user_name'],
"lang_sh_name"=>$lang['sh_name'],
"lang_sh_message"=>$lang['sh_message']
));
$shout_form .= $site_template->parse_template("shout_form");
}
$site_template->register_vars(array(
"shout_form"=>$shout_form,
"shoutings"=>$shoutings,
"lang_shoutbox"=>$lang['shoutbox']
));
if (!$config['sh_allow_guests'] && $session_info['session_user_id'] == GUEST) {
$site_template->register_vars(array("shout_form"=>$lang['sh_e_register']));
}
unset ($shout_form);
unset ($shoutings);
?>