Нужен попап для определенного IP

Идеи для расширения функциональности phpBB 2.0.x
Аватара пользователя
[R: R@m$e$ :U]
phpBB Maniac
Сообщения: 1464
Зарегистрирован: 20 лет 3 месяца
Откуда: Novosibirsk,RU

Сообщение [R: R@m$e$ :U] »

Alexgraf
Если я PhpMyAdmin удаляю все записи в MSGIP_TABLE, то при добавлении новой записи, ей присваивается значение не 1, а большее того, которое было последним при удалении...
настройка таблицы mysql 'auto_increment'... в phpmyadmin открой таблицу 'msqip_table'... далее 'операции'... в самом низу настройка... ;)
Кроме этого, запись user_message всегда остаётся пустой. Я добавил её и в таблицу phpbb_users и в таблицу которая используется на моём форуме...
стрянно.... в принципе должна заполнятся единицей при входе... и нулем при создании сессии... попробуй это...

Update from 1.0.3 to 1.1.0.txt

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

############################################################## 
## MOD Title: Message for IP [Update from 1.0.3 to 1.1.0]
## MOD Author: [R: R@m$e$ :U] < Ramses@FromRU.com > (Ramses) http://www.phpbbguru.net
## MOD Description: Displays a message for defined IP
## MOD Version: 1.1.0 
## 
## Installation Level: Easy
## Installation Time: ~3 Minutes 
## Files To Edit: 
##      includes/page_header.php
##      includes/sessions.php
## Included Files: 
##      db_update_103_to_110.php
############################################################## 
## For Security Purposes, Please Check: http://www.phpbbguru.net/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. 
############################################################## 
## Author Notes: 
##      Find bug? Please write me...
## 
##      Run SQL-commands in phpMyAdmin or execute db_update_103_to_110.php
## 
############################################################## 
## MOD History: 
## 
##   2005-03-10 - Version 1.1.0 
##      - Kill function from 1.0.2 =) and more advanced check for one message ;)
##      - Fix install for phpBB Mods DB... =)
##
##   2005-03-10 - Version 1.0.3 
##      - Fix possible error with already sent headers
##
##   2005-03-09 - Version 1.0.2 
##      - Only one message in from logging + 1 minute...
##
##   2005-03-08 - Version 1.0.1 
##      - Remake install 
## 
##   2005-03-08 - Version 1.0.0 
##      - First release... =))) 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ SQL ]------------------------------------------ 
# 

ALTER TABLE `phpbb_users` ADD `user_message` VARCHAR( 25 ) NOT NULL ;

# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/page_header.php

# 
#-----[ FIND ]------------------------------------------ 
# 

// [start] Message for IP 1.0.3
$msgiptime = time() - 60;
if ($msgiptime < $userdata['user_lastvisit'] && !($gen_simple_header))
{
	$sql = "SELECT *
		FROM " . MSGIP_TABLE . "
		WHERE msg_ip = '" . encode_ip($client_ip) . "'";
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	if ( !empty($row['msg_ip']) )
	{
		$template->assign_block_vars('switch_enable_msgip_popup', array());
	}
}
// [end] Message for IP 1.0.3

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

// [start] Message for IP 1.1.0
if (($userdata['user_message'] == 0) && ($userdata['user_id'] != ANONYMOUS) && !($gen_simple_header))
{
	$sql = "SELECT *
		FROM " . MSGIP_TABLE . "
		WHERE msg_ip = '" . encode_ip($client_ip) . "'";
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	// Disable message for this session
	$sql = "UPDATE " . USERS_TABLE . "
		SET user_message = 1
		WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not update user information", '', __LINE__, __FILE__, $sql);
	}
	if ( !empty($row['msg_ip']) )
	{
		$template->assign_block_vars('switch_enable_msgip_popup', array());
	}
}
// [end] Message for IP 1.1.0


# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/sessions.php

# 
#-----[ FIND ]------------------------------------------ 
# 

		$sql = "UPDATE " . USERS_TABLE . " 
			SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
			WHERE user_id = $user_id";

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

		// [start] Message for IP 1.1.0

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

		// [end] Message for IP 1.1.0

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 

, user_lastvisit = $last_visit

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 

, user_message = 0

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
db_update_103_to_110.php

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

<? 
######################################################### 
## SQL commands to phpBB2 
## Author: Niels Chr. Rшd 
## Nickname: Niels Chr. Denmark 
## Email: ncr@db9.dk 
## 
## Ver 1.0.7 
## 
## phpBB2 database update script for mods 
## this file is intended to use with phpBB2, when installing mods 
## after so you may delete this file, but only admin can use so it really doesen't matter 
## The script will look what prefix you are using, and use the existing DB defined by congig.php 
## The execution of this script's included SQL is harmless, so you can run it as meny times you like 
## note, though that the users last visit, will be set back to his/her last login, 
## but that is a minor cosmetic isue, that will correct it self next time the use  logs in 
## 
## the following example are from my mods, and you can add some self, for other mods if you like 
## you will after execution get a list over those commands that are run with succes and those with warnings ! 
## delete the sample lines if you are using it only for other mods 
## 
######################################################### 

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

################################################################################################### 
## 
## put the SQL commands below here, the SQL commands listed below are only exampels, substitude them with the one you need ## 
## 
################################################################################################### 
$sql=array( 
'ALTER TABLE ' . USERS_TABLE . ' ADD `user_message` VARCHAR( 25 ) NOT NULL'
); 

$mods = array ( 
'Message for IP [Update from 1.0.3 to 1.1.0]'

); 

############################################### Do not change anything below this line ####################################### 

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

if ($userdata['user_level']!=ADMIN) 
      message_die(GENERAL_ERROR, "You are not Authorised to do this"); 
$n=0; 
$message="<b>This list is a result of the SQL queries needed for mod</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>[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_die(GENERAL_MESSAGE, $message); 
?>

Update from 1.0.2 to 1.1.0.txt

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

############################################################## 
## MOD Title: Message for IP [Update from 1.0.2 to 1.1.0]
## MOD Author: [R: R@m$e$ :U] < Ramses@FromRU.com > (Ramses) http://www.phpbbguru.net
## MOD Description: Displays a message for defined IP
## MOD Version: 1.1.0 
## 
## Installation Level: Easy
## Installation Time: ~3 Minutes 
## Files To Edit: 
##      includes/page_header.php
##      includes/sessions.php
## Included Files: 
##      db_update_102_to_110.php
############################################################## 
## For Security Purposes, Please Check: http://www.phpbbguru.net/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. 
############################################################## 
## Author Notes: 
##      Find bug? Please write me...
## 
##      Run SQL-commands in phpMyAdmin or execute db_update_102_to_110.php
## 
############################################################## 
## MOD History: 
## 
##   2005-03-10 - Version 1.1.0 
##      - Kill function from 1.0.2 =) and more advanced check for one message ;)
##      - Fix install for phpBB Mods DB... =)
##
##   2005-03-10 - Version 1.0.3 
##      - Fix possible error with already sent headers
##
##   2005-03-09 - Version 1.0.2 
##      - Only one message in from logging + 1 minute...
##
##   2005-03-08 - Version 1.0.1 
##      - Remake install 
## 
##   2005-03-08 - Version 1.0.0 
##      - First release... =))) 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ SQL ]------------------------------------------ 
# 

ALTER TABLE `phpbb_users` ADD `user_message` VARCHAR( 25 ) NOT NULL ;

# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/page_header.php

# 
#-----[ FIND ]------------------------------------------ 
# 

// [start] Message for IP 1.0.2
$msgiptime = time() - 60;
if ($msgiptime < $userdata['user_lastvisit'])
{
	$sql = "SELECT *
		FROM " . MSGIP_TABLE . "
		WHERE msg_ip = '" . encode_ip($client_ip) . "'";
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	if ( !empty($row['msg_ip']) )
	{
		$template->assign_block_vars('switch_enable_msgip_popup', array());
	}
}
// [start] Message for IP 1.0.2

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

// [start] Message for IP 1.1.0
if (($userdata['user_message'] == 0) && ($userdata['user_id'] != ANONYMOUS) && !($gen_simple_header))
{
	$sql = "SELECT *
		FROM " . MSGIP_TABLE . "
		WHERE msg_ip = '" . encode_ip($client_ip) . "'";
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	// Disable message for this session
	$sql = "UPDATE " . USERS_TABLE . "
		SET user_message = 1
		WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not update user information", '', __LINE__, __FILE__, $sql);
	}
	if ( !empty($row['msg_ip']) )
	{
		$template->assign_block_vars('switch_enable_msgip_popup', array());
	}
}
// [end] Message for IP 1.1.0


# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/sessions.php

# 
#-----[ FIND ]------------------------------------------ 
# 

		$sql = "UPDATE " . USERS_TABLE . " 
			SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
			WHERE user_id = $user_id";

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

		// [start] Message for IP 1.1.0

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

		// [end] Message for IP 1.1.0

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 

, user_lastvisit = $last_visit

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 

, user_message = 0

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
db_update_102_to_110.php

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

<? 
######################################################### 
## SQL commands to phpBB2 
## Author: Niels Chr. Rшd 
## Nickname: Niels Chr. Denmark 
## Email: ncr@db9.dk 
## 
## Ver 1.0.7 
## 
## phpBB2 database update script for mods 
## this file is intended to use with phpBB2, when installing mods 
## after so you may delete this file, but only admin can use so it really doesen't matter 
## The script will look what prefix you are using, and use the existing DB defined by congig.php 
## The execution of this script's included SQL is harmless, so you can run it as meny times you like 
## note, though that the users last visit, will be set back to his/her last login, 
## but that is a minor cosmetic isue, that will correct it self next time the use  logs in 
## 
## the following example are from my mods, and you can add some self, for other mods if you like 
## you will after execution get a list over those commands that are run with succes and those with warnings ! 
## delete the sample lines if you are using it only for other mods 
## 
######################################################### 

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

################################################################################################### 
## 
## put the SQL commands below here, the SQL commands listed below are only exampels, substitude them with the one you need ## 
## 
################################################################################################### 
$sql=array( 
'ALTER TABLE ' . USERS_TABLE . ' ADD `user_message` VARCHAR( 25 ) NOT NULL'
); 

$mods = array ( 
'Message for IP [Update from 1.0.2 to 1.1.0]'

); 

############################################### Do not change anything below this line ####################################### 

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

if ($userdata['user_level']!=ADMIN) 
      message_die(GENERAL_ERROR, "You are not Authorised to do this"); 
$n=0; 
$message="<b>This list is a result of the SQL queries needed for mod</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>[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_die(GENERAL_MESSAGE, $message); 
?>

Update from 1.0.0 to 1.1.0.txt

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

############################################################## 
## MOD Title: Message for IP [Update from 1.0.0 to 1.1.0]
## MOD Author: [R: R@m$e$ :U] < Ramses@FromRU.com > (Ramses) http://www.phpbbguru.net
## MOD Description: Displays a message for defined IP
## MOD Version: 1.1.0 
## 
## Installation Level: Easy
## Installation Time: ~3 Minutes 
## Files To Edit: 
##      includes/page_header.php
##      includes/sessions.php
## Included Files: 
##      db_update_100_to_110.php
############################################################## 
## For Security Purposes, Please Check: http://www.phpbbguru.net/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. 
############################################################## 
## Author Notes: 
##      Find bug? Please write me...
## 
##      Run SQL-commands in phpMyAdmin or execute db_update_100_to_110.php
## 
############################################################## 
## MOD History: 
## 
##   2005-03-10 - Version 1.1.0 
##      - Kill function from 1.0.2 =) and more advanced check for one message ;)
##      - Fix install for phpBB Mods DB... =)
##
##   2005-03-10 - Version 1.0.3 
##      - Fix possible error with already sent headers
##
##   2005-03-09 - Version 1.0.2 
##      - Only one message in from logging + 1 minute...
##
##   2005-03-08 - Version 1.0.1 
##      - Remake install 
## 
##   2005-03-08 - Version 1.0.0 
##      - First release... =))) 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ SQL ]------------------------------------------ 
# 

ALTER TABLE `phpbb_users` ADD `user_message` VARCHAR( 25 ) NOT NULL ;

# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/page_header.php

# 
#-----[ FIND ]------------------------------------------ 
# 

// [start] Message for IP
$sql = "SELECT *
	FROM " . MSGIP_TABLE . "
	WHERE msg_ip = '" . encode_ip($client_ip) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ( !empty($row['msg_ip']) )
{
	$template->assign_block_vars('switch_enable_msgip_popup', array());
}
// [end] Message for IP

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

// [start] Message for IP 1.1.0
if (($userdata['user_message'] == 0) && ($userdata['user_id'] != ANONYMOUS) && !($gen_simple_header))
{
	$sql = "SELECT *
		FROM " . MSGIP_TABLE . "
		WHERE msg_ip = '" . encode_ip($client_ip) . "'";
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	// Disable message for this session
	$sql = "UPDATE " . USERS_TABLE . "
		SET user_message = 1
		WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not update user information", '', __LINE__, __FILE__, $sql);
	}
	if ( !empty($row['msg_ip']) )
	{
		$template->assign_block_vars('switch_enable_msgip_popup', array());
	}
}
// [end] Message for IP 1.1.0

# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/sessions.php

# 
#-----[ FIND ]------------------------------------------ 
# 

		$sql = "UPDATE " . USERS_TABLE . " 
			SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
			WHERE user_id = $user_id";

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

		// [start] Message for IP 1.1.0

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

		// [end] Message for IP 1.1.0

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 

, user_lastvisit = $last_visit

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 

, user_message = 0

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
db_update_100_to_110.php

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

<? 
######################################################### 
## SQL commands to phpBB2 
## Author: Niels Chr. Rшd 
## Nickname: Niels Chr. Denmark 
## Email: ncr@db9.dk 
## 
## Ver 1.0.7 
## 
## phpBB2 database update script for mods 
## this file is intended to use with phpBB2, when installing mods 
## after so you may delete this file, but only admin can use so it really doesen't matter 
## The script will look what prefix you are using, and use the existing DB defined by congig.php 
## The execution of this script's included SQL is harmless, so you can run it as meny times you like 
## note, though that the users last visit, will be set back to his/her last login, 
## but that is a minor cosmetic isue, that will correct it self next time the use  logs in 
## 
## the following example are from my mods, and you can add some self, for other mods if you like 
## you will after execution get a list over those commands that are run with succes and those with warnings ! 
## delete the sample lines if you are using it only for other mods 
## 
######################################################### 

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

################################################################################################### 
## 
## put the SQL commands below here, the SQL commands listed below are only exampels, substitude them with the one you need ## 
## 
################################################################################################### 
$sql=array( 
'ALTER TABLE ' . USERS_TABLE . ' ADD `user_message` VARCHAR( 25 ) NOT NULL'
); 

$mods = array ( 
'Message for IP [Update from 1.0.0 to 1.1.0]'

); 

############################################### Do not change anything below this line ####################################### 

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

if ($userdata['user_level']!=ADMIN) 
      message_die(GENERAL_ERROR, "You are not Authorised to do this"); 
$n=0; 
$message="<b>This list is a result of the SQL queries needed for mod</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>[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_die(GENERAL_MESSAGE, $message); 
?>
Руководство пользователя | FAQ | Правила | Как устанавливать MOD'ы
ВОСПОЛЬЗУЙСЯ ПОИСКОМ, ТАМ ЕСТЬ БОЛЬШИНСТВО ОТВЕТОВ
ЕСЛИ НЕ ПОМОГЛО, ИСПОЛЬЗУЙ ШАБЛОН ЗАПРОСА, ПОМОГИ В РЕШЕНИИ ЗАДАЧИ
БЕСПЛАТНО ПОМОГУ ТОЛЬКО НА ФОРУМЕ!!! (ЛС НЕ В СЧЕТ)

Оставь благодарность, подтверди работоспособность совета.

ВСЕ ПРАВА НА МОДЫ ОТДАНЫ m157y
Alexgraf

Сообщение Alexgraf »

Всё равно беда какая-то - сообщения не удаляются, окошко выводится не всегда, весь текст в одну строчку...
Будем двигаться поступательно, начнем с удаления сообщений.
Что-то мне кажется глюк в файле admin_msgip.php
Если в браузере набрать http://www.[host].ru/forum/admin/admin_msgip.php?msg=6&delete&sid=e031144704e33568917add85b122da31
то, как я понимаю, должно появиться сообщение - Сообщение было успешно удалено . У меня вместо этого появляется

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

Текст для IP

Администрирование текста показываемого для определенного IP-адреса

----------------здесь окошко для ввода айпи и текста--------------
Внизу кнопка                 ***Изменить***
Свой файл admin_msgip.php, тот что ты выкладывал, я несколько раз перепроверил.
Выложи еще раз файл, который у тебя сейчас установлен, плиз.
Аватара пользователя
[R: R@m$e$ :U]
phpBB Maniac
Сообщения: 1464
Зарегистрирован: 20 лет 3 месяца
Откуда: Novosibirsk,RU

Сообщение [R: R@m$e$ :U] »

полную версию не выложу пока администрация не выделит места... тк выкладывать код 17 файлов это громоздко... переписал код admin_msgip.php... поэтому остался только новый... лови его... теперь таких проблем быть не должно... принцип выбора функции стал другой... все остальное вроде тоже самое... у меня такой вариант тоже работает.. у тебя надеюсь тоже будет... если нет, то будем искать причину... если да... то продолжай список проблем... будем решать...
admin/admin_msgip.php

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

<?php
/***************************************************************************
*                             admin_msgip.php
*                              -------------------
*     begin                : Tue Feb 08, 2005
*     copyright            : (C) 2005 [R: R@m$e$ :U]
*     email                : Ramses@FromRU.com
*
*     $Id: admin_msgip.php,v 1.0.2 2005/03/08 12:13:07 ramses 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);

if ( !empty($setmodules) )
{
	$filename = basename(__FILE__);
	$module['General']['Msgip'] = $filename;

	return;
}

//
// Load default header
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

//
// Get the message ID
//
if( isset($HTTP_GET_VARS['msg']) || isset($HTTP_POST_VARS['msg']) )
{
	$msg_id = ( isset($HTTP_POST_VARS['msg']) ) ? $HTTP_POST_VARS['msg'] : $HTTP_GET_VARS['msg'];

	if( $msg_id == -1 )
	{
		$msg_sql = '';
	}
	else
	{
		$msg_id = intval($msg_id);
		$msg_sql = "msg_id = $msg_id";
	}
}
else
{
	$msg_id = '';
	$msg_sql = '';
}
//
// Get a poems
//
$sql = "SELECT *
	FROM " . MSGIP_TABLE . "
	$forum_sql
	ORDER BY msg_ip ASC";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain messages', '', __LINE__, __FILE__, $sql);
}

$msgs_rows = array();
while( $row = $db->sql_fetchrow($result) )
{
	$msgs_rows[] = $row;
}

if( empty($HTTP_GET_VARS['msg']) )
{
	if ( isset($HTTP_GET_VARS['add_msg']) || isset($HTTP_POST_VARS['add_msg']) )
	{
		$template->set_filenames(array(
			'body' => 'admin/msgip_add.tpl')
		);

		//
		// Assign the template variables.
		//
		$template->assign_vars(array(
			"L_IP" => $lang['Msgip_ip'],
			"L_TEXT" => $lang['Msgip_text'],
			"L_ADD_MSG" => $lang['Msgip_add'])
		);
	}
	else if ( isset($HTTP_GET_VARS['create']) || isset($HTTP_POST_VARS['create']) )
	{
		if ( isset($HTTP_GET_VARS['msg_ip']) || isset($HTTP_POST_VARS['msg_ip']) )
		{
			$msg_ip = ( isset($HTTP_GET_VARS['msg_ip']) ) ? $HTTP_GET_VARS['msg_ip'] : $HTTP_POST_VARS['msg_ip'];
		}

		if ( isset($HTTP_GET_VARS['msg_text']) || isset($HTTP_POST_VARS['msg_text']) )
		{
			$msg_text = ( isset($HTTP_GET_VARS['msg_text']) ) ? $HTTP_GET_VARS['msg_text'] : $HTTP_POST_VARS['msg_text'];
		}

		$msg_ip = htmlspecialchars($msg_ip);
		$msg_text = htmlspecialchars($msg_text);
		$sql = "INSERT INTO " . MSGIP_TABLE . " (msg_ip, msg_text)
			VALUES('" . encode_ip(str_replace("\'", "''", $msg_ip)) . "', '" . str_replace("\'", "''", $msg_text) . "')";

		if( $sql != '' )
		{
			$result = $db->sql_query($sql);
			if( !$result )
			{
				message_die(GENERAL_ERROR, "Couldn't create message!", "", __LINE__, __FILE__, $sql);
			}
		}

		$message = $lang['Msgip_add_success'] . "

" . sprintf($lang['Click_return_msgipadmin'], "<a href=\"" . append_sid("admin_msgip.$phpEx") . "\">", "</a>") . "

" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

		message_die(GENERAL_MESSAGE, $message);	}
	else
	{
		$template->set_filenames(array(
			'body' => 'admin/msgip_body.tpl')
		);

		for($i = 0; $i < count($msgs_rows); $i++)
		{
			$id = $msgs_rows[$i]['msg_id'];
			$msg_ip = decode_ip($msgs_rows[$i]['msg_ip']);
			$msg_text = $msgs_rows[$i]['msg_text'];
			$edit = append_sid("admin_msgip.$phpEx?msg=$id&action=edit");
			$delete = append_sid("admin_msgip.$phpEx?msg=$id&delete");

			$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
			$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

			//
			// Assign the template variables.
			//
			$template->assign_block_vars("msgs", array(
				"ROW_COLOR" => "#" . $row_color,
				"ROW_CLASS" => $row_class,
				"IP" => $msg_ip,
				"TEXT" => $msg_text,
				"ID" => $id,

				"U_EDIT" => $edit,
				"U_DELETE" => $delete)
			);
		}
	}
}
else
{
	if ( isset($HTTP_GET_VARS['update']) || isset($HTTP_POST_VARS['update']) )
	{
		if ( isset($HTTP_GET_VARS['msg_ip']) || isset($HTTP_POST_VARS['msg_ip']) )
		{
			$msg_ip = ( isset($HTTP_GET_VARS['msg_ip']) ) ? $HTTP_GET_VARS['msg_ip'] : $HTTP_POST_VARS['msg_ip'];
		}

		if ( isset($HTTP_GET_VARS['msg_text']) || isset($HTTP_POST_VARS['msg_text']) )
		{
			$msg_text = ( isset($HTTP_GET_VARS['msg_text']) ) ? $HTTP_GET_VARS['msg_text'] : $HTTP_POST_VARS['msg_text'];
		}

		$msg_ip = htmlspecialchars($msg_ip);
		$msg_text = htmlspecialchars($msg_text);
		$sql = "UPDATE " . MSGIP_TABLE . " 
			SET msg_ip = '" . encode_ip(str_replace("\'", "''", $msg_ip)) . "', msg_text = '" . str_replace("\'", "''", $msg_text) . "' 
			WHERE msg_id = '" . $msg_id . "'";

		if( $sql != '' )
		{
			$result = $db->sql_query($sql);
			if( !$result )
			{
				message_die(GENERAL_ERROR, "Couldn't update message!", "", __LINE__, __FILE__, $sql);
			}
		}

		$message = $lang['Msgip_edit_success'] . "

" . sprintf($lang['Click_return_msgipadmin'], "<a href=\"" . append_sid("admin_msgip.$phpEx") . "\">", "</a>") . "

" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

		message_die(GENERAL_MESSAGE, $message);
	}
	else if ( isset($HTTP_GET_VARS['delete']) || isset($HTTP_POST_VARS['delete']) )
	{
		$sql = "DELETE 
			FROM " . MSGIP_TABLE . "
			WHERE msg_id = " . $msg_id;
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Couldn't delete message", "", __LINE__, __FILE__, $sql);
		}

		$message = $lang['Msgip_delete_success'] . "

" . sprintf($lang['Click_return_msgipadmin'], "<a href=\"" . append_sid("admin_msgip.$phpEx") . "\">", "</a>") . "

" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

		message_die(GENERAL_MESSAGE, $message);
	}
	else
	{
		$msg_id = intval($HTTP_GET_VARS['msg']);
		
		$template->set_filenames(array(
			'body' => 'admin/msgip_edit.tpl')
		);

		$action = append_sid("admin_msgip.$phpEx?msg=$msg_id");

		$sql = "SELECT msg_ip, msg_text
			FROM " . MSGIP_TABLE . "
			WHERE msg_id = " . $msg_id;
		if( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, "Couldn't get message", "", __LINE__, __FILE__, $sql);
		}

		$msg = $db->sql_fetchrow($result);

		//
		// Assign the template variables.
		//
		$template->assign_vars(array(
			"IP" => decode_ip($msg['msg_ip']),
			"TEXT" => $msg['msg_text'],

			"L_IP" => $lang['Msgip_ip'],
			"L_TEXT" => $lang['Msgip_text'],
			"L_EDIT_MSG" => $lang['Msgip_edit'])
		);
	}
}
//
// Assign the template variables.
//
$template->assign_vars(array(
	"L_MSG_TITLE" => $lang['Msgip_title'],
	"L_MSG_TEXT" => $lang['Msgip_title_text'],
	"L_ADD" => $lang['Msgip_add'],
	"L_ID" => $lang['Msgip_id'],
	"L_IP" => $lang['Msgip_ip'],
	"L_TEXT" => $lang['Msgip_text'],
	"L_ACTION" => $lang['Action'],
	"L_EDIT" => $lang['Edit'], 
	"L_DELETE" => $lang['Delete'],

	"S_MSG_ACTION" => ($action) ? $action : append_sid("admin_msgip.$phpEx"))
);
//
// Actually output the page here.
//
$template->pparse('body');

include('./page_footer_admin.'.$phpEx);

?>


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

Alexgraf
в общем написал 1.3.0... там можно добавить по маске... и вроде ни каких проблем... поэтому ждем места от администрации...
Руководство пользователя | FAQ | Правила | Как устанавливать MOD'ы
ВОСПОЛЬЗУЙСЯ ПОИСКОМ, ТАМ ЕСТЬ БОЛЬШИНСТВО ОТВЕТОВ
ЕСЛИ НЕ ПОМОГЛО, ИСПОЛЬЗУЙ ШАБЛОН ЗАПРОСА, ПОМОГИ В РЕШЕНИИ ЗАДАЧИ
БЕСПЛАТНО ПОМОГУ ТОЛЬКО НА ФОРУМЕ!!! (ЛС НЕ В СЧЕТ)

Оставь благодарность, подтверди работоспособность совета.

ВСЕ ПРАВА НА МОДЫ ОТДАНЫ m157y
Alexgraf

Сообщение Alexgraf »

[R: R@m$e$ :U]

Сейчас ситуация такая - в админке не удаляется, всё пишется в одну строчку, окошко всплывает только после входа зарегистрированного пользователя, а хочется что бы всплывало у всех.
Ждем 1.3.0
Alexgraf

Сообщение Alexgraf »

[R: R@m$e$ :U]
ждем места от администрации...
Место не нашлось ???
Xpert
phpBB Guru
phpBB Guru
Сообщения: 5484
Зарегистрирован: 21 год 1 месяц
Поблагодарили: 2 раза

Сообщение Xpert »

Да место-то есть...
Эксперт - это человек, который избегает мелких ошибок на пути к грандиозному провалу.
Любая более-менее сложная задача имеет несколько простых, изящных, лёгких для понимания неправильных решений
Аватара пользователя
[R: R@m$e$ :U]
phpBB Maniac
Сообщения: 1464
Зарегистрирован: 20 лет 3 месяца
Откуда: Novosibirsk,RU

Сообщение [R: R@m$e$ :U] »

Alexgraf
нету домена и фтп =) вернее теперь есть и домен... но нету фтп... =)
Руководство пользователя | FAQ | Правила | Как устанавливать MOD'ы
ВОСПОЛЬЗУЙСЯ ПОИСКОМ, ТАМ ЕСТЬ БОЛЬШИНСТВО ОТВЕТОВ
ЕСЛИ НЕ ПОМОГЛО, ИСПОЛЬЗУЙ ШАБЛОН ЗАПРОСА, ПОМОГИ В РЕШЕНИИ ЗАДАЧИ
БЕСПЛАТНО ПОМОГУ ТОЛЬКО НА ФОРУМЕ!!! (ЛС НЕ В СЧЕТ)

Оставь благодарность, подтверди работоспособность совета.

ВСЕ ПРАВА НА МОДЫ ОТДАНЫ m157y
Аватара пользователя
[R: R@m$e$ :U]
phpBB Maniac
Сообщения: 1464
Зарегистрирован: 20 лет 3 месяца
Откуда: Novosibirsk,RU

Сообщение [R: R@m$e$ :U] »

Alexgraf
идем в ветку бета версии... =)
Moderators
убейте этот топик =)
Руководство пользователя | FAQ | Правила | Как устанавливать MOD'ы
ВОСПОЛЬЗУЙСЯ ПОИСКОМ, ТАМ ЕСТЬ БОЛЬШИНСТВО ОТВЕТОВ
ЕСЛИ НЕ ПОМОГЛО, ИСПОЛЬЗУЙ ШАБЛОН ЗАПРОСА, ПОМОГИ В РЕШЕНИИ ЗАДАЧИ
БЕСПЛАТНО ПОМОГУ ТОЛЬКО НА ФОРУМЕ!!! (ЛС НЕ В СЧЕТ)

Оставь благодарность, подтверди работоспособность совета.

ВСЕ ПРАВА НА МОДЫ ОТДАНЫ m157y

Вернуться в «Запросы модов для phpBB 2.0.x»