Помогите понять, что с модом New Post Email Notification

Ответы на вопросы, связанные с модами для phpBB 2.0.x, кроме относящихся к форуму Для авторов (phpBB 2.0.x).
Аватара пользователя
Сергей Секирин
phpBB 2.0.0
Сообщения: 244
Стаж: 20 лет 6 месяцев

Помогите понять, что с модом New Post Email Notification

Сообщение Сергей Секирин »

Не могу понять - почему не работает этот мод. Вроде простой... После установки что есть что нет - ничего. Значения переменных ставил правильно, свои. Помогите, кто понимает!
Вот весь мод:

Код: Выделить всё

#
#-----[ Open ]------------------------------------------
#
  includes/functions_post.php 
#
#-----[ Find ]------------------------------------------
#
	if ($mode != 'editpost')
	{
		$post_id = $db->sql_nextid();
	}
#
#-----[ Add After ]------------------------------------------
#

// email post - BEGIN
      $forumURL      = "http://www.yourdomain.com/forums";
      $adminEmail = "admin@yourdomain.com";
      $subject      = "New Post Notification";
      $headers    = "From: Yourdomain.com Forums Admin <contact01@yourdomain.com>\r\n";
      $message    = "A new post was made to your forum, click on the link below to view the topic:\n\nLink: $forumURL/viewtopic.php?p=$post_id";
      @mail ( $adminEmail, $subject, $message, $headers);
// email post - END
Апология здравомыслия - странное занятие Православия:-)
Xpert
phpBB Guru
phpBB Guru
Сообщения: 5484
Стаж: 21 год 5 месяцев
Поблагодарили: 2 раза

Сообщение Xpert »

Мда. В мусорку такие творения...
Не разбирайтесь с ним, найдите что-нибудь другое.
Эксперт - это человек, который избегает мелких ошибок на пути к грандиозному провалу.
Любая более-менее сложная задача имеет несколько простых, изящных, лёгких для понимания неправильных решений
Аватара пользователя
Сергей Секирин
phpBB 2.0.0
Сообщения: 244
Стаж: 20 лет 6 месяцев

Сообщение Сергей Секирин »

Люблю простые моды, настраиваемые в скрипте. Разве ничем нельзя ему помочь?

Добавлено спустя 1 час 45 минут 29 секунд:

Пришлось изменить более сложный мод StefanKausL. Если кому интересно - вот что получилось:

Код: Выделить всё

##############################################################
## MOD Title: Easy Admin Topic Notifier (изменён Секириным Сергеем)
## MOD Author: StefanKausL < stefan@kuhlins.de > (Stefan Kuhlins) http://kuhlins.de/
## MOD Description: This simple MOD notifies admins by email of new topics.
## MOD Version: 1.0.4
##
//
//Внимание!!! - >   
//	1) Мод переделан: не тему, а при любом посте он шлёт письмо.
//	2) Не работает на локальном сайте, т.к. почтовик даёт ошибку, поэтому в локальной версии functions_post.php ЗАКОММЕНТИРОВАНА строка: sk_send_mail_to_admins($post_id);
//

## Installation Level:	Easy
## Installation Time:	1 Minute
## Files To Edit: includes/functions_post.php
##
## Included Files: easy_admin_topic_notifier.tpl
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ 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/
##############################################################
## Author Notes:
##
## This MOD is especially useful for seldom used forums.
##
## The template for the email is copied to the English directory.
## If you want to support different languages change the statement
## $emailer->use_template('easy_admin_topic_notifier', 'english');
## to
## $emailer->use_template('easy_admin_topic_notifier', $row['user_lang']);
## and copy localized versions of the template file
## easy_admin_topic_notifier.tpl in every language directory.
##############################################################
## MOD History:
##
##   2004-09-06 - Version 1.0.4
##	  - Added directory for file
##
##   2004-08-22 - Version 1.0.3
##	  - Needed a new version number
##
##   2004-08-22 - Version 1.0.2
##	  - Corrected typo
##
##   2004-08-21 - Version 1.0.1
##	  - Added COPY action
##
##   2004-08-18 - Version 1.0.0
##	  - Initial version
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ COPY ]---------------------------------------------
#
copy easy_admin_topic_notifier.tpl to language/lang_english/email/easy_admin_topic_notifier.tpl

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

#
#-----[ FIND ]---------------------------------------------
#
			$post_id = $db->sql_nextid();

#
#-----[ AFTER, ADD ]---------------------------------------------
#
//Мод Easy Admin Topic Notifier BEGIN

			sk_send_mail_to_admins($post_id);

//Мод Easy Admin Topic Notifier END
#
#-----[ FIND ]---------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------
#

//Мод Easy Admin Topic Notifier BEGIN
function sk_send_mail_to_admins($post_id) {
	global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
	include($phpbb_root_path . 'includes/emailer.'.$phpEx);
	$emailer = new emailer($board_config['smtp_delivery']);

	$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
	$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
	$server_name = trim($board_config['server_name']);
	$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
	$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';

	$sql = "SELECT user_email, user_lang FROM " . USERS_TABLE . " WHERE user_level = " . ADMIN;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
	}

	while ($row = $db->sql_fetchrow($result))
	{
		$emailer->email_address(trim($row['user_email']));
		$emailer->use_template('easy_admin_topic_notifier', $row['user_lang']);  // See Notes!
		$emailer->from($board_config['board_email']);
		$emailer->set_subject($lang['New_post']);
		$emailer->assign_vars(array(
			'U_POST' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id"));
		$emailer->send();
		$emailer->reset();
	}
	$db->sql_freeresult($result);
}
//Мод Easy Admin Topic Notifier END


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
И шаблон к нему:

Код: Выделить всё

Subject: New post at (название сайта)
Charset: iso-8859-1

New post was published: 
{U_POST}
Апология здравомыслия - странное занятие Православия:-)
Xpert
phpBB Guru
phpBB Guru
Сообщения: 5484
Стаж: 21 год 5 месяцев
Поблагодарили: 2 раза

Сообщение Xpert »

Сергей Секирин
Этот мод противоречит всем правилам написания модов. Я ще понимаю когда такое пишется на очень скорую руку и только для себя, но выкладывать в паблик такое нельзя. Что же касается
Сергей Секирин писал(а):Easy Admin Topic Notifier
... это судя по всему отличное решение вашей задачи.
Эксперт - это человек, который избегает мелких ошибок на пути к грандиозному провалу.
Любая более-менее сложная задача имеет несколько простых, изящных, лёгких для понимания неправильных решений

Вернуться в «Поддержка модов для phpBB 2.0.x»