here is working code:
<?php // PLUGIN_TITLE: Shoutbox Admin
/*************************************\
** **
** Shoutbox Mod for 4images **
** Version: v1.0(Beta) **
** By: f1do **
** Email: f1do.987@gmail.com **
** Web: http://f1do.uni.cc **
** **
\*************************************/
$nozip = 1;
define('IN_CP', 1);
$root_path = (!eregi("\/plugins\/", $HTTP_SERVER_VARS['PHP_SELF'])) ? "./../" : "./../../";
define('ROOT_PATH', $root_path);
require(ROOT_PATH.'admin/admin_global.php');
define('SHOUTBOX_TABLE', $table_prefix.'shoutbox');
function get_num_words ($text) {
$text_words = explode (" ", $text);
$text_words = sizeof ($text_words);
return $text_words;
}
show_admin_header();
if ($action == "") {
$action = "main";
}
//---------------------------------------------------
//--- Instalation -----------------------------------
//---------------------------------------------------
if ($action == "installshoutbox") {
$active = un_htmlspecialchars(trim($HTTP_POST_VARS['active']));
$allowguests = un_htmlspecialchars(trim($HTTP_POST_VARS['allowguests']));
$usr_lgth = un_htmlspecialchars($HTTP_POST_VARS['usr_lgth']);
$msg_lgth = un_htmlspecialchars($HTTP_POST_VARS['msg_lgth']);
$sh_wordwrap = un_htmlspecialchars(trim($HTTP_POST_VARS['sh_wordwrap']));
$bbcode = trim($HTTP_POST_VARS['bbcode']);
$bbimg = trim($HTTP_POST_VARS['bbimg']);
$html = htmlspecialchars(trim($HTTP_POST_VARS['html']));
$shouts = un_htmlspecialchars(trim($HTTP_POST_VARS['shouts']));
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$active.",'sh_active')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$allowguests.",'sh_allow_guests')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$usr_lgth.",'sh_usr_lgth')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$msg_lgth.",'sh_msg_lgth')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$sh_wordwrap.",'sh_wordwrap')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$bbcode.",'sh_bbcode')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$bbimg.",'sh_bbimg')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$html.",'sh_html')";
$result = $site_db->query($sql);
$sql = "INSERT INTO ".SETTINGS_TABLE."(setting_value,setting_name) VALUES(".$shouts.",'sh_msg_display')";
$result = $site_db->query($sql);
$sql = 'CREATE TABLE `4images_shoutbox` ('
. ' `id` INT NOT NULL AUTO_INCREMENT, '
. ' `name` VARCHAR(50) NOT NULL, '
. ' `message` TEXT NOT NULL, '
. ' `date` VARCHAR(15) NOT NULL,'
. ' `ip` VARCHAR(15) NOT NULL,'
. ' `usrid` INT(11) NOT NULL,'
. ' PRIMARY KEY (`id`)'
. ' )'
. ' TYPE = myisam';
$result = $site_db->query($sql);
if ($result) {
echo $lang['sh_installed'];
show_text_link($lang['sh_back'], "shoutbox_admin.php?action=main");
}
else {
echo $lang['sh_not_installed'];
show_text_link($lang['sh_back'], "shoutbox_admin.php?action=main");
}
}
unset ($active);
unset ($allowguests);
unset ($usr_lgth);
unset ($msg_lgth);
unset ($sh_wordwrap);
unset ($bbcode);
unset ($bbimg);
unset ($html);
unset ($shouts);
if (!isset($config['sh_active']) && $action != "installshoutbox") {
$action = "cfginstallshoutbox";
}
if ($action == "cfginstallshoutbox") {
show_form_header('shoutbox_admin.php','installshoutbox');
show_table_header($lang['sh_cfg']);
show_radio_row($lang['sh_activate'], "active");
show_radio_row($lang['sh_allow_guests'], "allowguests");
show_input_row($lang['sh_usr_lgth'],"usr_lgth","15");
show_input_row($lang['sh_msg_lgth'],"msg_lgth","50");
show_input_row($lang['sh_wordwrap'],"sh_wordwrap","30");
show_radio_row($lang['sh_bbcode'], "bbcode");
show_radio_row($lang['sh_bbimg'], "bbimg", 0);
show_radio_row($lang['sh_html'], "html");
show_input_row($lang['sh_msg_display'],"shouts","20");
show_table_footer();
show_form_footer($lang['sh_install'], "", 2);
}
//---------------------------------------------
//-------- Admin ------------------------------
//---------------------------------------------
if ($action == "main") {
$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 > 20) {
$num_shouts = 20;
}
if ($num_shouts > 0) {
show_form_header('shoutbox_admin.php','deleteshout');
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n<tr>\n<td class=\"tableborder\">\n<table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\">\n";
echo "<tr class=\"tableseparator\">\n<td class=\"tableseparator\" width=\"40\"><input name=\"allbox\" type=\"checkbox\" onClick=\"CheckAll()\" /></td>\n";
echo "<td class=\"tableseparator\" width=\"40\">".$lang['sh_number']."</td>\n";
echo "<td class=\"tableseparator\" width=\"70\">".$lang['sh_name']."</td>\n";
echo "<td class=\"tableseparator\">".$lang['sh_message']."</td>\n";
echo "<td class=\"tableseparator\" width=\"100\">".$lang['sh_date']."</td>\n";
echo "<td class=\"tableseparator\" width=\"80\">".$lang['sh_options']."</td></tr>\n";
for ($i = 0; $i < $num_shouts; $i++) {
echo "<tr class=\"".get_row_bg()."\">\n";
echo "<td><input type=\"checkbox\" name=\"shout_delete[]\" value=\"".$shouts[$i]['id']."\"></td>\n";
echo "<td>".$shouts[$i]['id']."</td>\n";
echo "<td>".$shouts[$i]['name']."</td>\n";
echo "<td>".$shouts[$i]['message']."</td>\n";
echo "<td>".date('d.m.Y H:i:s', $shouts[$i]['date'])."</td>\n";
echo "<td><a href=\"".ROOT_PATH."shout_editor.php?action=edit&shout_id=".$shouts[$i]['id']."\" target=\"_blank\" onClick=\"return popup(this,'edit_shout')\">".$lang['edit']."</a> <a href=\"".ROOT_PATH."shout_editor.php?action=delete&shout_id=".$shouts[$i]['id']."\" target=\"_blank\" onClick=\"return popup(this,'delete_shout')\">".$lang['delete']."</a></td>\n";
}
show_form_footer($lang['sh_delete'], "", 6);
}
show_form_header('shoutbox_admin.php','editconfig');
show_table_header($lang['sh_cfg']);
show_radio_row($lang['sh_activate'], "active",$config['sh_active']);
show_radio_row($lang['sh_allow_guests'], "allowguests",$config['sh_allow_guests']);
show_input_row($lang['sh_usr_lgth'],"usr_lgth",$config['sh_usr_lgth']);
show_input_row($lang['sh_msg_lgth'],"msg_lgth",$config['sh_msg_lgth']);
show_input_row($lang['sh_wordwrap'],"sh_wordwrap",$config['sh_wordwrap']);
show_radio_row($lang['sh_bbcode'], "bbcode",$config['sh_bbcode']);
show_radio_row($lang['sh_bbimg'], "bbimg",$config['sh_bbimg']);
show_radio_row($lang['sh_html'], "html",$config['sh_html']);
show_input_row($lang['sh_msg_display'],"shouts",$config['sh_msg_display']);
show_table_footer();
show_form_footer($lang['sh_update'], "", 2);
}
if ($action == "deleteshout") {
if (isset($HTTP_POST_VARS['shout_delete'])){
$shout_delete = $HTTP_POST_VARS['shout_delete'];
$num_shout_delete = sizeof ($shout_delete);
for ($i = 0; $i <= $num_shout_delete; $i++) {
$sql = "DELETE FROM ".SHOUTBOX_TABLE." WHERE id='".$shout_delete[$i]."'";
$result = $site_db->query($sql);
}
echo $lang['sh_deleted'];
}
show_text_link($lang['sh_back'], "shoutbox_admin.php?action=main");
}
if ($action == "editconfig") {
$active = un_htmlspecialchars(trim($HTTP_POST_VARS['active']));
$allowguests = un_htmlspecialchars(trim($HTTP_POST_VARS['allowguests']));
$usr_lgth = un_htmlspecialchars($HTTP_POST_VARS['usr_lgth']);
$msg_lgth = un_htmlspecialchars($HTTP_POST_VARS['msg_lgth']);
$sh_wordwrap = un_htmlspecialchars(trim($HTTP_POST_VARS['sh_wordwrap']));
$bbcode = trim($HTTP_POST_VARS['bbcode']);
$bbimg = trim($HTTP_POST_VARS['bbimg']);
$html = trim($HTTP_POST_VARS['html']);
$shouts = un_htmlspecialchars(trim($HTTP_POST_VARS['shouts']));
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$active." WHERE setting_name = 'sh_active'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$allowguests." WHERE setting_name = 'sh_allow_guests'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$usr_lgth." WHERE setting_name = 'sh_usr_lgth'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$msg_lgth." WHERE setting_name = 'sh_msg_lgth'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$sh_wordwrap." WHERE setting_name = 'sh_wordwrap'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$bbcode." WHERE setting_name = 'sh_bbcode'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$bbimg." WHERE setting_name = 'sh_bbimg'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$html." WHERE setting_name = 'sh_html'";
$result = $site_db->query($sql);
$sql = "UPDATE ".SETTINGS_TABLE." SET setting_value = ".$shouts." WHERE setting_name = 'sh_msg_display'";
$result = $site_db->query($sql);
if ($result) {
echo $lang['sh_updated'];
show_text_link($lang['sh_back'], "shoutbox_admin.php?action=main");
} else {
echo $lang['sh_not_updated'];
show_text_link($lang['sh_back'], "shoutbox_admin.php?action=main");
}
unset ($active);
unset ($allowguests);
unset ($usr_lgth);
unset ($msg_lgth);
unset ($sh_wordwrap);
unset ($bbcode);
unset ($bbimg);
unset ($html);
unset ($shouts);
}
show_admin_footer();
?>