- Code: Select all
##############################################################
## MOD Title: Favorites Mod
## MOD Author: DanielT < mods@danielt.com > (Daniel Taylor) http://www.danielt.com
## MOD Description: Allows users the build a favorite topics list
## MOD Version: 1.0.2
##
## Installation Level: moderate
## Installation Time: 5 Minutes
## Files To Edit: viewtopic.php
## includes/page_header.php
## templates/subSilver/overall_header.tpl
## templates/subSilver/viewtopic_body.tpl
## language/lang_english/lang_main.php
## Included Files: favorites.php, fav_body.tpl
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
## Author Notes: Updates From 1.0.1:
## Added Simple Post Icon
## Added 'Views and 'Replies'
## Stoped double 'fav adding'
##
## How to update from 101 to 102:
## Re-upload:
## favorites.php
## fav_body.tpl
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
#Where 'phpbb_' is your table prefix
CREATE TABLE `phpbb_favorites` (
`fav_id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL default '0',
`topic_id` int(11) NOT NULL default '0',
PRIMARY KEY (`fav_id`)
)
#
#-----[ COPY ]------------------------------------------
#
copy favorites.php TO favorites.php
copy fav_body.tpl TO templates/subSilver/fav_body.tpl
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//Fav Mod
$lang['remove_fav_data'] = 'Could not remove data from favorites table';
$lang['insert_fav_data'] = 'Could not insert data into favorites table';
$lang['no_fav_topic'] = 'No topic to set as favorite was set';
$lang['favorites'] = 'Favorites';
$lang['add_fav'] = 'Add To Favorites';
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'U_FAV' => append_sid("favorites.$phpEx?t=" . $topic_id . "&mode=add"),
'L_FAV' => $lang['add_fav'],
#
#-----[ OPEN ]------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------
#
'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'),
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_FAV' => $lang['favorites'],
#
#-----[ FIND ]------------------------------------------
#
'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),
#
#-----[ AFTER, ADD ]------------------------------------------
#
'U_FAV' => append_sid('favorites.'.$phpEx),
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
<img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<a href="{U_FAV}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_FAV}" hspace="3" />{L_FAV}</a>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
{S_WATCH_TOPIC}
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<br><a href="{U_FAV}">{L_FAV}</a>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
favorites.php:
- Code: Select all
<?php
/***************************************************************************
* favorites.php
* -------------------
* begin : Monday, Jan 20, 2003
* copyright : (C) 2003 Daniel Taylor
* email : danielt@hackermail.com
* $Id: favorites.php,v 1.0.2 2003/01/30 17:24:17 danielt Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
if( !$userdata['session_logged_in'] )
{
header("Location: " . append_sid($phpbb_script_path . "login." . $phpEx . "?redirect=" . $PHP_SELF));
exit;
}
if ( isset($HTTP_GET_VARS['mode']) )
{
$mode = ($HTTP_GET_VARS['mode']);
if ( $mode == 'add' )
{
if ( isset($HTTP_GET_VARS['t']))
{
$topic_id = ($HTTP_GET_VARS['t']);
$user_id = ($userdata['user_id']);
//START // 1.0.2 update // Check For Attepmted Double Fav Adding
$sql = "SELECT * FROM " . $table_prefix . "favorites WHERE user_id = '" . $user_id . "' AND topic_id = '" . $topic_id ."'";
$result = $db->sql_query($sql);
$num_row = $db->sql_numrows($result);
if ($num_row <= "0" ) {
$sql = "INSERT INTO " . $table_prefix . "favorites (fav_id, user_id, topic_id) VALUES (NULL, '$user_id', '$topic_id')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['insert_fav_data'], '', __LINE__, __FILE__, $sql);
}
}
else {
message_die(GENERAL_ERROR, $lang['exist_fav']);
}
//END // 1.0.2 update // Check For Attepmted Double Fav Adding
}
if ( !(isset($HTTP_GET_VARS['t'])) )
{
message_die(GENERAL_MESSAGE, 'fav_no_topic');
exit;
}
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
header($header_location . append_sid("favorites." . $phpEx, true));
exit;
}
if ( $mode == 'remove' )
{
if ( isset($HTTP_GET_VARS['t']))
{
$topic_id = (intval($HTTP_GET_VARS['t']));
$user_id = ($userdata['user_id']);
$sql = "DELETE FROM " . $table_prefix . "favorites WHERE user_id = '$user_id' AND topic_id = '$topic_id'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['remove_fav_data'], '', __LINE__, __FILE__, $sql);
}
}
if ( !(isset($HTTP_GET_VARS['t'])) )
{
message_die(GENERAL_MESSAGE, $lang['no_fav_topic']);
exit;
}
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
header($header_location . append_sid("favorites." . $phpEx, true));
exit;
}
}
else
{
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$user_id = ($userdata['user_id']);
$template->set_filenames(array(
'body' => 'fav_body.tpl')
);
$template->assign_vars(array(
'L_TOPIC' => $lang['Topic'],
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => $lang['Index'],
'L_REPLIES' => $lang['Replies'],
'L_LASTPOST' => $lang['Last_Post'],
'L_AUTHOR' => $lang['Author'],
'L_VIEWS' => $lang['Views'],
'L_DELETE' => $lang['Delete'])
);
$sql = "SELECT " . $table_prefix . "favorites.topic_id, " . $table_prefix . "topics.*
FROM " . $table_prefix . "favorites LEFT JOIN " . $table_prefix . "topics
ON " . $table_prefix . "favorites.topic_id = " . $table_prefix . "topics.topic_id
WHERE " . $table_prefix . "favorites.user_id = '" . $userdata['user_id'] . "'";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
//START // 1.0.2 update // Simple Post Icon
if( $row['topic_type'] == POST_ANNOUNCE )
{
$folder = $images['folder_announce'];
//$folder_new = $images['folder_announce_new'];
$folder_alt = $lang['Post_Announcement'];
$folder_text = $lang['Topic_Announcement'];
}
else if( $row['topic_type'] == POST_STICKY )
{
$folder = $images['folder_sticky'];
//$folder_new = $images['folder_sticky_new'];
$folder_alt = $lang['Post_Sticky'];
$folder_text = $lang['Topic_Sticky'];
}
else {
$folder = $images['folder'];
$folder_new = $images['folder_new'];
$folder_alt = $lang['Post_Normal'];
$folder_text = "";
}
if( $row['topic_status'] == 1 )
{
$folder = $images['folder_locked'];
//$folder_new = $images['folder_locked_new'];
$folder_alt = $lang['Topic_locked'];
$folder_text = "";
}
//END // 1.0.2 update // Simple Post Icon
$template->assign_block_vars('topicrow', array(
'S_FOLDER' => $folder,
'S_FOLDER_ALT' => $folder_alt,
'S_FOLDER_TEXT' => $folder_text,
'L_TOPIC_TITLE' => $row['topic_title'],
'VIEWS' => $row['topic_views'],
'REPLIES' => $row['topic_replies'],
'U_TOPIC_TITLE' => append_sid("viewtopic.$phpEx?t=" . $row['topic_id']),
'L_REMOVE' => $lang['Delete'],
'U_REMOVE' => append_sid("favorites.$phpEx?mode=remove&t=" . $row['topic_id']))
);
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
?>
how to change viewtopic.php?t=1 to topic-title-vtxx.html

English |
French

