|
From: Selven <sel...@us...> - 2007-06-21 18:21:17
|
Update of /cvsroot/mxbb/mx_shoutbox In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27703 Added Files: Shoutbox.pak db_install.php db_uninstall.php db_upgrade.php index.html mx_shoutbox.php Log Message: First Upload --- NEW FILE: index.html --- --- NEW FILE: db_uninstall.php --- <?php // ------------------------------------------------------------- // // // FILENAME : db_uninstall.php // COPYRIGHT : © 2002, 2003 apegaming.net // WWW : http://www.blame-the-french.com.com/ // LICENCE : GPL vs2.0 [ see /docs/COPYING ] // // ------------------------------------------------------------- define('IN_PORTAL', true); if ( !defined('IN_ADMIN') ) { $mx_root_path = '../../'; include($mx_root_path . 'extension.inc'); include($mx_root_path . 'common.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); mx_init_userprefs($userdata); if( !$userdata['session_logged_in'] ) { die("Hacking attempt(3)"); } if( $userdata['user_level'] != ADMIN ) { die("Hacking attempt(4)"); } // // End session management // } $sql = array( "DROP TABLE ".$mx_table_prefix."shoutbox_config", "DROP TABLE ".$mx_table_prefix."shoutbox" ); $n = 0; $message = "<b>This list is a result of the SQL queries needed for KB module</b><br /><br />"; while($sql[$n]) { $message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br />' : ''; if(!$result = $db->sql_query($sql[$n])) { $message .= '<b><font color=#FF0000>[Error, Already deleted or updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } else { $message .='<b><font color=#0000fF>[Deleted/Updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } $n++; } $message .= '<br /> If you get some Error, Already Deleted or Updated, relax, this is normal ;)'; echo "<br /><br />"; echo "<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Uninstallation Information</th></tr>"; echo "<tr><td class=\"row1\" align=\"center\"><span class=\"gen\">" . $message . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: db_upgrade.php --- <?php // ------------------------------------------------------------- // // // FILENAME : db_upgrade.php // COPYRIGHT : © 2002, 2003 apegaming.net // WWW : http://www.blame-the-french.com.com/ // LICENCE : GPL vs2.0 [ see /docs/COPYING ] // // ------------------------------------------------------------- if ( !defined('IN_ADMIN') ) { define('IN_PORTAL', true); $mx_root_path = '../../'; include($mx_root_path . 'extension.inc'); include($mx_root_path . 'common.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); mx_init_userprefs($userdata); // // End session management // } $mx_module_version = '2.3.0'; $mx_module_copy = 'Original mxBB <i>Shoutbox</i> module by <a href="http://phpms.sourceforge.net" target="_blank">Selven</a>'; $sql=array( "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'", "DROP TABLE IF EXISTS " . $mx_table_prefix . "shoutbox_config", "CREATE TABLE " . $mx_table_prefix . "shoutbox_config ( config_name varchar(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', PRIMARY KEY (config_name) ) TYPE=MyISAM", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('config_id', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('list_index', '5')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_guest', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_member_del', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_member_edit', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_bbcode', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('shout_size', '75')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('static_box', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('static_box_height', '75')", ); $n = 0; $message = "<b>This list is a result of the SQL queries needed for Shoutbox Addon</b><br/><br/> Please delete this file after a successfull update!<br /><br />"; while($sql[$n]) { $message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br/>' : ''; if(!$result = $db->sql_query($sql[$n])) { $message .= '<b><font color=#FF0000>[Error or Already added]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } else { $message .='<b><font color=#0000fF>[Added/Updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } $n++; } mx_message_die(GENERAL_MESSAGE, $message); ?> --- NEW FILE: db_install.php --- <?php // ------------------------------------------------------------- // // // FILENAME : db_install.php // COPYRIGHT : © 2002, 2003 apegaming.net // WWW : http://www.blame-the-french.com.com/ // LICENCE : GPL vs2.0 [ see /docs/COPYING ] // // ------------------------------------------------------------- if ( !defined('IN_ADMIN') ) { define('IN_PORTAL', true); $mx_root_path = '../../'; include($mx_root_path . 'extension.inc'); include($mx_root_path . 'common.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); mx_init_userprefs($userdata); // // End session management // } $mx_module_version = '2.3.0'; $mx_module_copy = 'Original mxBB <i>Shoutbox</i> module by <a href="http://phpms.sourceforge.net" target="_blank">Selven</a>'; $sql=array( "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'", "DROP TABLE IF EXISTS " . $mx_table_prefix . "shoutbox", "CREATE TABLE " . $mx_table_prefix . "shoutbox ( id int(11) NOT NULL auto_increment, name_id mediumint(8) NOT NULL default '0', name varchar(25) NOT NULL default '', text text NOT NULL, time int(11) NOT NULL default '0', bbcode_uid varchar(10) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM", "INSERT INTO " . $mx_table_prefix . "shoutbox (id,name_id,name,text,time,bbcode_uid) VALUES ('1', '-1', 'MX Shoutbox Installer', 'The MX Shoutbox has been installed correctly!', '1049679815', '0')", "DROP TABLE IF EXISTS " . $mx_table_prefix . "shoutbox_config", "CREATE TABLE " . $mx_table_prefix . "shoutbox_config ( config_name varchar(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', PRIMARY KEY (config_name) ) TYPE=MyISAM", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('config_id', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('list_index', '5')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_guest', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_member_del', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_member_edit', '1')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('allow_bbcode', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('shout_size', '75')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('static_box', '0')", "INSERT INTO " . $mx_table_prefix . "shoutbox_config (config_name, config_value) VALUES ('static_box_height', '75')", ); $n = 0; $message = "<b>This list is a result of the SQL queries needed for Shoutbox Addon</b><br/><br/>"; while($sql[$n]) { $message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br/>' : ''; if(!$result = $db->sql_query($sql[$n])) { $message .= '<b><font color=#FF0000>[Error or Already added]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } else { $message .='<b><font color=#0000FF>[Added/Updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } $n++; } $message .= '<br /><br />If everything was successful, please delete this file for security reasons!'; mx_message_die(GENERAL_MESSAGE, $message); ?> --- NEW FILE: Shoutbox.pak --- module=+:52=+:Shoutbox=+:modules/mx_shoutbox/=+:Shoutbox=+:1 New_function=+:---------------------------=+:0=+:0=+:0=+:0=+:0 function=+:52=+:54=+:Shoutbox=+:Shoutbox=+:mx_shoutbox.php=+: parameter=+:0=+:0=+:0=+:endoflist=+:0=+:0 block=+:=+:Demo - Shoutbox=+:Demo block=+:54=+:0=+:5=+:0=+:0=+:0=+:0=+:1=+:1 function=+:0=+:0=+:0=+:endoflist=+:0=+:0 --- NEW FILE: mx_shoutbox.php --- <?php // ------------------------------------------------------------- // // // FILENAME : mx_shoutbox.php // COPYRIGHT : © 2002, 2003 apegaming.net // WWW : http://www.blame-the-french.com.com/ // LICENCE : GPL vs2.0 [ see /docs/COPYING ] // // ------------------------------------------------------------- if( !isset($HTTP_POST_VARS) ) { $HTTP_POST_VARS = &$_POST; $HTTP_GET_VARS = &$_GET; $HTTP_SESSION_VARS = &$_SESSION; $HTTP_SERVER_VARS = &$_SERVER; } if ($_GET[page]) { $page = "page=".$_GET[page]."&"; } if ( defined('IN_PORTAL') ) { include($module_root_path . 'includes/constants.' . $phpEx); include($module_root_path . 'includes/functions.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_post.' . $phpEx); /**************************** Read language definition *****************************/ if ( !file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_main.'.$phpEx ); } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ); } /**************************** Get config data *****************************/ $sql = "SELECT * FROM " . SHOUTBOX_CONFIG_TABLE; if(!$result = $db->sql_query($sql)) { mx_message_die(CRITICAL_ERROR, 'Could not query config information in mx shoutbox', '', __LINE__, __FILE__, $sql); } else { while( $row = $db->sql_fetchrow($result) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $shout_config[$config_name] = $config_value; } } $page_limit = $shout_config['list_index']; /******************************* Get mode from passed arguments ********************************/ if( isset($HTTP_POST_VARS['sbmode']) || isset($HTTP_GET_VARS['sbmode']) ) { $mode = ( isset($HTTP_POST_VARS['sbmode']) ) ? $HTTP_POST_VARS['sbmode'] : $HTTP_GET_VARS['sbmode']; } else { $mode = ""; } switch ($mode) { case 'add': $username = ( !empty($HTTP_POST_VARS['username']) ) ? prepare_message(trim($HTTP_POST_VARS['username']), 0, 0, 0, 0) : $lang['guest']; $user_id = ( isset($HTTP_POST_VARS['user_id']) ) ? $HTTP_POST_VARS['user_id'] : $HTTP_GET_VARS['user_id']; $message = ( isset($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : $HTTP_GET_VARS['message']; $bbcode_on = ( isset($HTTP_POST_VARS['bbcode']) ) ? $HTTP_POST_VARS['bbcode'] : $HTTP_GET_VARS['bbcode']; $time = time(); $bbcode_uid = make_bbcode_uid(); $message = prepare_message(trim($message), 0, $bbcode_on, 1, $bbcode_uid); // remove images from bbcode $message = preg_replace("#\[img:$bbcode_uid\](.*?)\[/img:$bbcode_uid\]#si", '', $message); $sql = "INSERT INTO " . SHOUTBOX_TABLE . " (name_id,name,text,time,bbcode_uid) VALUES ('$user_id','" . substr($username,0,20) . "','$message','$time', '$bbcode_uid')"; if ( !($result = $db->sql_query($sql)) ) { shout_msg('Could not enter shout into database.'); } $message = $lang['Shout_message_add'] . '<br />'; shout_msg($message); break; case 'delete': $id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; if ( empty($id)) { shout_msg($lang['Shout_delete_error']); break; } $sql = "DELETE FROM " . SHOUTBOX_TABLE . " WHERE id='$id'"; if ( !($result = $db->sql_query($sql)) ) { shout_msg('Could not delete shout.'); } $message = $lang['Shout_message_delete'] . '<br />'; shout_msg($message); break; case 'edit': $id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; if ( empty($id) ) { shout_msg($lang['Shout_edit_error']); break; } $sql = "SELECT * FROM ". SHOUTBOX_TABLE ." WHERE id = '$id'"; if( !($result = $db->sql_query($sql)) ) { shout_msg('Could not query shout information'); break; } $thisshout = $db->sql_fetchrow($result); $shoutnameid = $thisshout['name_id']; if ($userdata['user_level'] == ADMIN || $shoutnameid == $userdata['user_id']) { $shout_text = $thisshout['text']; if ($shout_config['static_box']==1) { $box_height = " style=\"overflow:auto; height:".$shout_config['static_box_height']."px;\""; } else { $box_height = ""; } $template->set_filenames(array( 'body' => 'mx_shout_edit.tpl') ); $template->assign_vars(array( 'L_EDIT_SHOUT_INFO' => $lang['Edit_Shout_Info'], 'SHOUT_TEXT' => $thisshout['text'], 'BOX_HEIGHT' => $box_height, 'L_SUBMIT' => $lang['Submit'], 'SHOUT_SIZE' => $shout_config['shout_size'], 'SHOUT_SIZE_EXPL' => $lang['shout_size_expl'], 'S_SHOUT_ACTION' => append_sid("$_SERVER[PHP_SELF]?".$page."sbmode=edit_shout&id=$id"), ) ); $template->pparse('body'); break; } else { shout_msg($lang['Shout_edit_perm_error']); break; } break; case 'edit_shout': $id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; if ( empty($id) ) { shout_msg($lang['Shout_edit_error']); break; } $sql = "SELECT * FROM ". SHOUTBOX_TABLE ." WHERE id = '$id'"; if( !($result = $db->sql_query($sql)) ) { shout_msg('Could not query shout information'); break; } $thisshout = $db->sql_fetchrow($result); $shoutnameid = $thisshout['name_id']; if ($userdata['user_level'] == ADMIN || $shoutnameid == $userdata['user_id']) { $shout_text = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['shout_text']))); $id = intval($HTTP_GET_VARS['id']); $sql = "UPDATE ". SHOUTBOX_TABLE ." SET text = '$shout_text' WHERE id = '$id'"; if( !$result = $db->sql_query($sql) ) { $message = $lang['Shout_error'].'<br />'; shout_msg($message); break; } $message = $lang['shout_updated_successfully'].'<br />'; shout_msg($message); } else { shout_msg($lang['Shout_edit_perm_error']); break; } break; } /**************************** Set form values ****************************/ $s_form_action = append_sid($_SERVER[PHP_SELF]."?".$page); $s_hidden_fields = '<input name="sid" type="hidden" value="' . $userdata['session_id'] . '" />' .'<input name="user_id" type="hidden" value="' . $userdata['user_id'] . '" />' .'<input name="sbmode" type="hidden" value="add" />' .'<input name="bbcode" type="hidden" value="' . $shout_config['allow_bbcode'] . '" />'; if ( $userdata['session_logged_in'] ) { $s_hidden_fields .= '<input name="username" type="hidden" value="' . $userdata['username'] . '" />'; } /**************************** Get variables for paginate *****************************/ if( isset($HTTP_POST_VARS['shout_start']) || isset($HTTP_GET_VARS['shout_start']) ) { $shout_start = ( isset($HTTP_POST_VARS['shout_start']) ) ? $HTTP_POST_VARS['shout_start'] : $HTTP_GET_VARS['shout_start']; } else { $shout_start = 0; } /**************************** Count the number of total shouts *****************************/ $sql = "SELECT COUNT(id) AS total FROM " . SHOUTBOX_TABLE; if ( !($result = $db->sql_query($sql)) ) { shout_msg('Could not query shoutbox counts'); } $count = $db->sql_fetchrow($result); if ($page_limit == 0) { $page_limit = $count['total']; } $pagination = ( !empty($shout_config) ) ? eregi_replace('&start', 'shout_start',generate_pagination($mx_root_path.'index.'.$phpEx.'?', $count['total'], $page_limit, $shout_start, FALSE)) : ""; if ($shout_config['static_box']==1) { $box_height = " style=\"overflow:auto; height:".$shout_config['static_box_height']."px;\""; } else { $box_height = ""; } if ($shout_config['shout_size']!="") { $shout_size = $shout_config['shout_size']; $shout_size_lang = $lang['shout_size_expl']; } else { $shout_size=""; $shout_size_lang = ""; } /**************************** Start page proper *****************************/ $template->set_filenames(array( 'body_shoutbox' => 'mx_shoutbox.tpl' )); $template->assign_vars(array( 'SHOUT_PAGE' => $pagination, 'BOX_HEIGHT' => $box_height, 'L_TITLE' => $lang['Shout_title'], 'L_FORM_ERROR' => $lang['Shout_form_error'], 'L_EMOTICONS' => $lang['Shout_emoticons'], 'L_SUBMIT' => $lang['Shout_submit'], 'L_LOGIN' => $lang['Shout_log_on'], 'L_NAME' => $lang['Shout_username'], 'SHOUT_SIZE' => $shout_size, 'SHOUT_SIZE_EXPL' => $shout_size_lang, 'U_EMOTICONS' => append_sid($phpbb_root_path . 'posting.php?mode=smilies'), 'S_FORM_ACTION' => $s_form_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'SH_VERSION' => SH_VERSION )); /**************************** Fetch the shouts, and filter any naughty words, if need so *****************************/ $sql = "SELECT * FROM " . SHOUTBOX_TABLE . " ORDER BY id DESC LIMIT $shout_start,$page_limit"; if ( !($result = $db->sql_query($sql)) ) { shout_msg('Could not query shoutbox information'); } $mxshout = array(); $mxshout = $db->sql_fetchrowset($result); if ($mxshout) { $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); /**************************** Now it's time for the loop ;) *****************************/ for($i = 0; $i < count($mxshout); $i++) { $bbcode_uid = $mxshout[$i]['bbcode_uid']; $mxshout[$i]['text'] = mx_decode( $mxshout[$i]['text'], $bbcode_uid ); $shoutid = $mxshout[$i]['id']; $shoutnameid = $mxshout[$i]['name_id']; $shoutname = $mxshout[$i]['name']; if (count($orig_word)) { $mxshout[$i]['text'] = preg_replace($orig_word, $replacement_word, $mxshout[$i]['text']); } // Is user a guest/anon? Ignore profile URL if it is. if ( $shoutnameid == ANONYMOUS ) { $userurl = $shoutname; } else { $userurl = '<a href="' . append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&u=" . $shoutnameid) . '" class="gen">' . $shoutname . '</a>'; } // Can delete? if ( $userdata['session_logged_in'] ) { $delurl_tmp = append_sid("$_SERVER[PHP_SELF]?".$page."sbmode=delete&id=$shoutid&sid=" . $userdata['session_id']); $delimg_tmp = '<img src="' . $images['icon_delpost'] . '" align="right" border="0" alt="' . $lang['alt_delete'] . '" />'; $edturl_tmp = append_sid("$_SERVER[PHP_SELF]?".$page."sbmode=edit&id=$shoutid&sid=" . $userdata['session_id']); $edtimg_tmp = '<img src="' . $images['icon_edit'] . '" align="right" border="0" alt="' . $lang['alt_edit'] . '" />'; if ($userdata['user_level'] == ADMIN) { $delurl = $delurl_tmp; $delimg = $delimg_tmp; $edturl = $edturl_tmp; $edtimg = $edtimg_tmp; } else if ($shoutnameid == $userdata['user_id']) { if ($shout_config['allow_member_del']) { $delurl = $delurl_tmp; $delimg = $delimg_tmp; } else { $delurl = ''; $delimg = ''; } if ($shout_config['allow_member_edit']) { $edturl = $edturl_tmp; $edtimg = $edtimg_tmp; } else { $edturl = ''; $edtimg = ''; } } else { $delurl = ''; $delimg = ''; $edturl = ''; $edtimg = ''; } } // Change row colors $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('postrow', array( 'ROW' => $row_class, 'MESSAGE' => $mxshout[$i]['text'], 'DATETIME' => create_date($board_config['default_dateformat'], $mxshout[$i]['time'], $board_config['board_timezone']), 'DEL_IMG' => $delimg, 'EDT_IMG' => $edtimg, 'U_DELETE' => $delurl, 'U_EDIT' => $edturl, 'U_USER_PROFILE' => $userurl, 'L_CONFIRM_DELETE' => $lang['Shout_delete_shout'] )); } // loop } // if ($mxshout) /**************************** Can user shout? if so, display form, else display message ****************************/ if ( !$userdata['session_logged_in'] ) { if ( $shout_config['allow_guest'] != 0 ) { $template->assign_block_vars('switch_logged_in', array()); $template->assign_block_vars('switch_logged_in.switch_guest_namebox', array()); } else { $template->assign_block_vars('switch_logged_out', array()); } } else { $template->assign_block_vars('switch_logged_in', array()); } /**************************** Start output to page ****************************/ $template->pparse("body_shoutbox"); $template->destroy(); } ?> |