email topic to friend - Falsche Verlinkung

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Samariel
Mitglied
Beiträge: 214
Registriert: 04.04.2004 11:50
Kontaktdaten:

email topic to friend - Falsche Verlinkung

Beitrag von Samariel »

Hier die Anleitung:
###############################################
## Mod Title: Email topic to friend
## Mod Version: 0.2
## Author: Vincent Grouls (macology@gmx.net)
## Description: This MOD allows you to send a friend of yours a topic of the board that
## you find interesting for him. It is also very handy in this way that you
## can email other members with interesting topics, while they are offline
## for a long time (like when they are one vacation).
##
## This mod works for phpBB2 v2.0.3
##
##
## Installation Level: Easy
## Installation Time: 5 Minutes
##
## Files To Edit: 2
## viewtopic.php
## includes/contants.php
## language/lang_english/lang_main.php
## templates/subSilver/viewtopic_body.tpl
##
## Included Files: 4
## db_update.php
## email_topic_body.tpl
## email_topic.php
## email_topic.tpl
##
## Author Notes:
## If you have email topic to friend 0.1, simply replace the file "email_topic.php"
## to fix the bug.
##
## History
## 0.2: Fixed a little bug, where the idrinkbox (another mod of me) function was
## called from the php page.
##
###############################################
## This MOD is released under the GPL License.
## Intellectual Property is retained by the MOD Author(s) listed above
###############################################

#
#-----[ COPY ]--------------------------------------------
#
# (this file should go in the root directory of your forum.
# Run it before using the MOD, and delete it immediately after that)
#
db_update.php

#
#-----[ COPY ]--------------------------------------------
#
# (this file should go in your templates directory)
# ./templates/subSilver/
#
email_topic_body.tpl

#
#-----[ COPY ]--------------------------------------------
#
# (this file should go in the root directory of your forum)
#
email_topic.php

#
#-----[ COPY ]--------------------------------------------
#
# (this file should go in the email directory in your
# language directory)
# ./language/lang_english/email/
#
email_topic.tpl

#
#-----[ OPEN ]--------------------------------------------
#
./viewtopic.php

#
#-----[ FIND ]--------------------------------------------
#
//
// If we've got a hightlight set pass it on to pagination,
// I get annoyed when I lose my highlight after the first page.
//

#
#-----[ BEFORE, ADD ]-------------------------------------
#
//
// Add the email topic to friend
//
$s_email_topic = '';
if ( $userdata['session_logged_in'] )
{
$action = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id&start=$start";
$s_email_topic = '<a href="' . append_sid("email_topic.$phpEx?$action") . '">' . $lang['Email_topic'] . '</a>';
}

#
#-----[ FIND ]--------------------------------------------
#
'S_WATCH_TOPIC' => $s_watching_topic,

#
#-----[ AFTER, ADD ]--------------------------------------
#
'S_EMAIL_TOPIC' => $s_email_topic,

#
#-----[ OPEN ]--------------------------------------------
#
./includes/constants.php

#
#-----[ FIND ]--------------------------------------------
#
define('TOPICS_TABLE', $table_prefix.'topics');

#
#-----[ AFTER, ADD ]--------------------------------------
#
define('TOPICS_EMAIL_TABLE', $table_prefix.'topics_email');

#
#-----[ OPEN ]--------------------------------------------
#
./language/lang_english/lang_main.php

#
#-----[ FIND ]--------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------

#
#-----[ BEFORE, ADD ]-------------------------------------
#
# (make sure to edit this file for every language)
#
//
// Email topic to friend
//
$lang['Email_topic'] = 'Email topic to a friend';
$lang['Email_topic_settings'] = 'Email topic information';
$lang['Friend_name'] = 'Friend\'s name';
$lang['Friend_email'] = 'Friend\'s email';
$lang['Email_max_exceeded'] = 'Sorry, but you have already sent 5 emails in the past 24 hours';
$lang['No_friend_specified'] = 'No friend\s name/email specified';

#
#-----[ OPEN ]--------------------------------------------
#
# (make sure to edit this file for every template)
#
./templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]--------------------------------------------
#
{S_WATCH_TOPIC}

#
#-----[ AFTER, ADD ]--------------------------------------
#
<br />{S_EMAIL_TOPIC}

#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#
Nun habe ich aber das Problem, dass wenn ich auf den Link gehe, dass ich jenes Thema mailen will, dort immer http://..../email_topic.php?p=0 steht. Logisch, dass ich dann die Meldung erhalte, dass das Thema nicht verfügbar ist. Wie kann ich das ändern?

Und ausserdem würde ich auch gerne die Anzahl ändern, bzw. den Zeitraum zum versenden der Mails. Nicht 5 innerhalb von 24 H. Dann lieber einen kürzeren zeitraum einfügen, so dass man zwar einige mehr abschicken kann, jedoch in einem etwas größeren Abstand.


Vielen Dank im Vorraus.


MfG, Samariel ;)
Zuletzt geändert von Samariel am 30.09.2004 16:08, insgesamt 1-mal geändert.
Seltsam erscheint unsere Lage auf dieser Erde. Jeder von uns erscheint da unfreiwillig
und ungebten zu kurzem Aufenthalt, ohne zu wissen, warum und wozu.

[Albert Einstein]
Samariel
Mitglied
Beiträge: 214
Registriert: 04.04.2004 11:50
Kontaktdaten:

Beitrag von Samariel »

Hm, so schwer? Dürfte es nicht nur eine kleine Änderung sein, damit die "0" in http://..../email_topic.php?p=0 immer durch die aktuelle ID ersetzt wird?

Ich wüsste allerdings nicht einmal wo ich diese Änderung suchen und testen könnte...
Seltsam erscheint unsere Lage auf dieser Erde. Jeder von uns erscheint da unfreiwillig
und ungebten zu kurzem Aufenthalt, ohne zu wissen, warum und wozu.

[Albert Einstein]
Samariel
Mitglied
Beiträge: 214
Registriert: 04.04.2004 11:50
Kontaktdaten:

Beitrag von Samariel »

hier die email_topic.php:
<?php

define ('IN_PHPBB', true);
$phpbb_root_path = "./";
include ($phpbb_root_path . 'extension.inc');
include ($phpbb_root_path . 'common.'.$phpEx);


//
// Parameters
//
$friend_name = (isset ($HTTP_POST_VARS['friend_name'])) ? trim(strip_tags($HTTP_POST_VARS['friend_name'])) : '';
$friend_email = (isset ($HTTP_POST_VARS['friend_email'])) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['friend_email']))) : '';

$post_id = (isset ($HTTP_GET_VARS[POST_POST_URL])) ? $HTTP_GET_VARS[POST_POST_URL] : ((isset($HTTP_POST_VARS[POST_POST_URL])) ? $HTTP_POST_VARS[POST_POST_URL] : 0);
$topic_id = (isset ($HTTP_GET_VARS[POST_TOPIC_URL])) ? $HTTP_GET_VARS[POST_TOPIC_URL] : ((isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? $HTTP_POST_VARS[POST_TOPIC_URL] : 0);
$start = (isset ($HTTP_GET_VARS['start'])) ? $HTTP_GET_VARS['start'] : ((isset($HTTP_POST_VARS['start'])) ? $HTTP_POST_VARS['start'] : 0);
$submit = (isset ($HTTP_POST_VARS['submit'])) ? TRUE : 0;

if (!$topic_id && !$post_id) {
message_die (GENERAL_MESSAGE, 'Topic_post_not_exist');
}

$redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id&start=$start";


//
// Start session management
//
$userdata = session_pagestart ($user_ip, PAGE_PROFILE);
init_userprefs ($userdata);
//
// End session management
//


if (!$userdata['session_logged_in']) {
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
header($header_location . append_sid("login.$phpEx?redirect=email_topic.$phpEx&$redirect", true));
exit;
}


$sql = "SELECT t.topic_id, t.topic_title, t.forum_id
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.topic_id = $topic_id
OR (p.post_id = $post_id
AND t.topic_id = p.topic_id)";
if (!$result = $db->sql_query ($sql)) {
message_die (GENERAL_ERROR, 'Could not obtain topic information', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow ($result);
$topic_title = $row['topic_title'];
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];


//
// Uncomment the following lines to make a limit for the users.
// $email_limit sets the maximum number of emails.
// $email_time sets the time window for the limit (in hours).
//
/*
$email_limit = 5;
$email_time = 24;
$current_time = time ();
$sql = "SELECT COUNT(user_id) AS total
FROM " . TOPICS_EMAIL_TABLE . "
WHERE user_id = " . $userdata['user_id'] . "
AND time >= " . ($current_time - ($drink_time * 3600));
if (!$result = $db->sql_query ($sql)) {
message_die (GENERAL_ERROR, 'Could not obtain user\'s email informaton', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow ($result);
if ($row['total'] >= $drink_limit) {
message_die (GENERAL_MESSAGE, $lang['Email_max_exceeded']);
}
*/

if ($submit) {
//
// Add record to database
//
if (!$friend_name || !$friend_email) {
message_die (GENERAL_MESSAGE, $lang['No_friend_specified']);
}

$sql = "INSERT INTO " . TOPICS_EMAIL_TABLE . " VALUES (" . $userdata['user_id'] . ", '" . str_replace("\'", "''", $friend_name) . "', '" . str_replace ("\'", "''", $friend_email) . "', $topic_id, '$current_time')";
if (!$result = $db->sql_query ($sql)) {
message_die (GENERAL_ERROR, 'Could not insert topic email data', __LINE__, __FILE__, $sql);
}

$server_url = "http://" . $board_config['server_name'];
$server_url .= ($board_config['server_port'] == 80) ? '' : ':' . $board_config['server_port'];
$server_url .= $board_config['script_path'];

$email_headers = 'From: ' . $userdata['user_email'] . "\nReturn-Path: " . $userdata['user_email'] . "\n";

include ($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer ($board_config['smtp_delivery']);
$emailer->use_template ('email_topic', $userdata['user_lang']);
$emailer->email_address ($friend_email);
$emailer->set_subject ();//$lang['Email_topic']
$emailer->extra_headers ($email_headers);
$emailer->assign_vars (
array (
'SITENAME' => $board_config['sitename'],
'USERNAME' => $userdata['username'],
'FRIEND_NAME' => $friend_name,
'TOPIC' => $topic_title,

'BOARD_EMAIL' => $board_config['board_email'],
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $userdata['username']),

'U_TOPIC' => $server_url . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"
)
);
$emailer->send();
$emailer->reset();

$redirect .= ($post_id) ? "#$post_id" : "";
$template->assign_vars (
array (
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid ("viewtopic.$phpEx?$redirect") . '">'
)
);

$msg = $lang['Email_sent'] . '<br /><br />' . sprintf ($lang['Click_return_topic'], '<a href="' . append_sid ("viewtopic.$phpEx?$redirect") . '">', '</a>') . '<br /><br />' . sprintf ($lang['Click_return_index'], '<a href="' . append_sid ("index.$phpEx") . '">', '</a>');
message_die (GENERAL_MESSAGE, $msg);
}


//
// Default page
//
$page_title = $lang['Email_topic'];
include ($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames (
array (
'body' => 'email_topic_body.tpl'
)
);

make_jumpbox('viewforum.'.$phpEx, $forum_id);

$s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '">';
$s_hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '">';
$s_hidden_fields .= '<input type="hidden" name="start" value="' . $start . '">';

$template->assign_vars (
array (
'L_TITLE' => $lang['Email_topic_settings'],

'L_FRIEND_NAME' => $lang['Friend_name'],
'L_FRIEND_EMAIL' => $lang['Friend_email'],
'L_SUBJECT' => $lang['Subject'],
'L_SUBMIT' => $lang['Submit'],

'TOPIC_TITLE' => $topic_title,

'S_EMAIL_ACTION' => append_sid ("email_topic.$phpEx"),
'S_HIDDEN_FIELDS' => $s_hidden_fields
)
);

$template->pparse ('body');
include ($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
Die Stelle, wo man Anzahl und Zeitraum ändern kann hab ichs chon gefunden. Nur, wie gesagt, wird noch immer zu "Thema 0" verlinkt.
Seltsam erscheint unsere Lage auf dieser Erde. Jeder von uns erscheint da unfreiwillig
und ungebten zu kurzem Aufenthalt, ohne zu wissen, warum und wozu.

[Albert Einstein]
Benutzeravatar
kratzer54847
Mitglied
Beiträge: 3065
Registriert: 20.01.2003 16:34
Wohnort: Düsseldorf/Hannover/Berlin
Kontaktdaten:

Beitrag von kratzer54847 »

hast du mal einen Link zum Mod?
Knowledge Base | MOD Datenbank | Boardsuche | HTML | PHP

Durch die richtige Verwendung dieser Links können viele Fragen beantwortet werden ;-)
Samariel
Mitglied
Beiträge: 214
Registriert: 04.04.2004 11:50
Kontaktdaten:

Beitrag von Samariel »

Seltsam erscheint unsere Lage auf dieser Erde. Jeder von uns erscheint da unfreiwillig
und ungebten zu kurzem Aufenthalt, ohne zu wissen, warum und wozu.

[Albert Einstein]
Samariel
Mitglied
Beiträge: 214
Registriert: 04.04.2004 11:50
Kontaktdaten:

Beitrag von Samariel »

Schon weiter gekommen dadurch oder zumindest eine kleine Idee?
Seltsam erscheint unsere Lage auf dieser Erde. Jeder von uns erscheint da unfreiwillig
und ungebten zu kurzem Aufenthalt, ohne zu wissen, warum und wozu.

[Albert Einstein]
Antworten

Zurück zu „phpBB 2.0: Mod Support“