$Date: 2005-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $
| > $Revision: 23 $
| > $Author: matt $
+---------------------------------------------------------------------------
|
| > Administration Module
| > Module written by Matt Mecham
| > Date started: 27th January 2004
|
| > Module Version Number: 1.0.0
| > DBA Checked: Mon 24th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Неверный вход
У Вас нет доступа к директиве этого файла. Если Вы проводили обновления, убедитесь, что не забыли обновить 'admin.php'.";
exit();
}
class ad_banandbadword {
var $functions = "";
/**
* Section title name
*
* @var string
*/
var $perm_main = "content";
/**
* Section title name
*
* @var string
*/
var $perm_child = "babw";
function auto_run()
{
//-----------------------------------------
// Require and RUN !! THERES A BOMB
//-----------------------------------------
$this->ipsclass->admin->page_detail = "";
$this->ipsclass->admin->page_title = "Фильтры блокировки (ban)";
//-----------------------------------------
// Kill globals - globals bad, Homer good.
//-----------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
//-----------------------------------------
// What to do...
//-----------------------------------------
switch($this->ipsclass->input['code'])
{
//-----------------------------------------
// Badword
//-----------------------------------------
case 'badword':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->badword_start();
break;
case 'badword_add':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-add' );
$this->badword_add();
break;
case 'badword_remove':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-remove' );
$this->badword_remove();
break;
case 'badword_edit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-edit' );
$this->badword_edit();
break;
case 'badword_doedit':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-edit' );
$this->badword_doedit();
break;
case 'badword_export':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-export' );
$this->badword_export();
break;
case 'badword_import':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':bw-import' );
$this->badword_import();
break;
//-----------------------------------------
// BAN (d-aid)
//-----------------------------------------
case 'ban':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':ban-view' );
$this->ban_start();
break;
case 'ban_add':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':ban-add' );
$this->ban_add();
break;
case 'ban_delete':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':ban-remove' );
$this->ban_delete();
break;
}
}
//-----------------------------------------
// BAN: Rebuild cache
//-----------------------------------------
function ban_rebuildcache()
{
$this->ipsclass->cache['banfilters'] = array();
$this->ipsclass->DB->simple_construct( array( 'select' => 'ban_content', 'from' => 'banfilters', 'where' => "ban_type='ip'" ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->cache['banfilters'][] = $r['ban_content'];
}
$this->ipsclass->update_cache( array( 'name' => 'banfilters', 'array' => 1, 'deletefirst' => 1 ) );
}
//-----------------------------------------
// BAN: DELETE
//-----------------------------------------
function ban_delete()
{
$ids = array();
foreach ($this->ipsclass->input as $key => $value)
{
if ( preg_match( "/^id_(\d+)$/", $key, $match ) )
{
if ( $this->ipsclass->input[$match[0]] )
{
$ids[] = $match[1];
}
}
}
if ( count( $ids ) )
{
$this->ipsclass->DB->simple_construct( array( 'delete' => 'banfilters', 'where' => 'ban_id IN('.implode( ",",$ids ).')' ) );
$this->ipsclass->DB->simple_exec();
}
$this->ban_rebuildcache();
$this->ipsclass->main_msg = "Бан удален";
$this->ban_start();
}
//-----------------------------------------
// BAN: ADD
//-----------------------------------------
function ban_add()
{
if ( ! $this->ipsclass->input['bantext'] )
{
$this->ipsclass->main_msg = "Вы должны ввести заменяемое слово!";
$this->ban_start();
}
//-----------------------------------------
// Check for existing entry
//-----------------------------------------
$result = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'banfilters', 'where' => "ban_content='{$this->ipsclass->input['bantext']}' and ban_type='{$this->ipsclass->input['bantype']}'" ) );
if ( $result['ban_id'] )
{
$this->ipsclass->main_msg = "Такое значение уже есть.";
$this->ban_start();
}
$this->ipsclass->DB->do_insert( 'banfilters', array( 'ban_type' => $this->ipsclass->input['bantype'], 'ban_content' => $this->ipsclass->input['bantext'], 'ban_date' => time() ) );
$this->ban_rebuildcache();
$this->ipsclass->main_msg = "Добавлен новый бан фильтр";
$this->ban_start();
}
//-----------------------------------------
// BAN: START
//-----------------------------------------
function ban_start()
{
$this->ipsclass->admin->page_title = "Управление фильтрами блокировки";
$this->ipsclass->admin->page_detail = "Эта секция позволяет вам изменять, удалять и добавлять ip-адреса, e-mail и зарезервированные имена в фильтр для блокировки.
Вы можете использовать «символ звездочки» — * , для любого(ых) символа(ов) ip-адреса или e-mail. (например: 127.0.*, *@mail.ru)";
//-----------------------------------------
// Get things
//-----------------------------------------
$ban = array();
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'banfilters', 'order' => 'ban_date desc' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$ban[ $r['ban_type'] ][ $r['ban_id'] ] = $r;
}
//-----------------------------------------
// SHOW THEM!
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'ban_delete'),
2 => array( 'act' , 'babw' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "1%" );
$this->ipsclass->adskin->td_header[] = array( "Запись" , "80%" );
$this->ipsclass->adskin->td_header[] = array( "Дата добавления" , "20%" );
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Управление фильтрами блокировки" );
//-----------------------------------------
// Banned IP Addresses
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Заблокированные ip-адреса", "left", "pformstrip");
if ( is_array( $ban['ip'] ) and count( $ban['ip'] ) )
{
foreach ( $ban['ip'] as $id => $entry )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "",
$entry['ban_content'],
$this->ipsclass->get_date( $entry['ban_date'], 'SHORT' ),
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Заблокированных IP-адресов нет", "left", "tdrow1");
}
//-----------------------------------------
// Banned Email Addresses
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Заблокированные e-mail адреса", "left", "pformstrip");
if ( is_array( $ban['email'] ) and count( $ban['email'] ) )
{
foreach ( $ban['email'] as $id => $entry )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "",
$entry['ban_content'],
$this->ipsclass->get_date( $entry['ban_date'], 'SHORT' ),
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Заблокированных e-mail адресов нет", "left", "tdrow1");
}
//-----------------------------------------
// Banned Names
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Запрещенные к регистрации имена пользователей", "left", "pformstrip");
if ( is_array( $ban['name'] ) and count( $ban['name'] ) )
{
foreach ( $ban['name'] as $id => $entry )
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "",
$entry['ban_content'],
$this->ipsclass->get_date( $entry['ban_date'], 'SHORT' ),
) );
}
}
else
{
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic("Запрещенных к регистрации имен пользователей нет", "left", "tdrow1");
}
$end_it_now = "
";
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic( $end_it_now, "center", "pformstrip");
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
$this->ipsclass->admin->output();
}
//-----------------------------------------
// BADWORDS: Import
//-----------------------------------------
function badword_import()
{
$content = $this->ipsclass->admin->import_xml( 'ipb_badwords.xml' );
//-----------------------------------------
// Got anything?
//-----------------------------------------
if ( ! $content )
{
$this->ipsclass->main_msg = "Закачка не совершена, ipb_badwords.xml некорректный или пуст";
$this->badword_start();
}
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require( KERNEL_PATH.'class_xml.php' );
$xml = new class_xml();
//-----------------------------------------
// Unpack the datafile
//-----------------------------------------
$xml->xml_parse_document( $content );
//-----------------------------------------
// Get current badwords
//-----------------------------------------
$words = array();
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'badwords', 'order' => 'type' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$words[ $r['type'] ] = 1;
}
//-----------------------------------------
// pArse
//-----------------------------------------
foreach( $xml->xml_array['badwordexport']['badwordgroup']['badword'] as $idx => $entry )
{
$type = $entry['type']['VALUE'];
$swop = $entry['swop']['VALUE'];
$m_exact = $entry['m_exact']['VALUE'];
if ( $words[ $type ] )
{
continue;
}
if ( $type )
{
$this->ipsclass->DB->do_insert( 'badwords', array( 'type' => $type, 'swop' => $swop, 'm_exact' => $m_exact ) );
}
}
$this->badword_rebuildcache();
$this->ipsclass->main_msg = "Импорт XML файла прошел успешно";
$this->badword_start();
}
//-----------------------------------------
// BADWORD: Export
//-----------------------------------------
function badword_export()
{
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require( KERNEL_PATH.'class_xml.php' );
$xml = new class_xml();
//-----------------------------------------
// Start...
//-----------------------------------------
$xml->xml_set_root( 'badwordexport', array( 'exported' => time() ) );
//-----------------------------------------
// Get emo group
//-----------------------------------------
$xml->xml_add_group( 'badwordgroup' );
$this->ipsclass->DB->simple_construct( array( 'select' => 'type, swop, m_exact', 'from' => 'badwords', 'order' => 'type' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$content = array();
foreach ( $r as $k => $v )
{
$content[] = $xml->xml_build_simple_tag( $k, $v );
}
$entry[] = $xml->xml_build_entry( 'badword', $content );
}
$xml->xml_add_entry_to_group( 'badwordgroup', $entry );
$xml->xml_format_document();
//-----------------------------------------
// Send to browser.
//-----------------------------------------
$this->ipsclass->admin->show_download( $xml->xml_document, 'ipb_badwords.xml' );
}
//-----------------------------------------
// BADWORD: Start
//-----------------------------------------
function badword_start()
{
$this->ipsclass->admin->page_detail = "В этой секции вы можете добавлять, изменять и удалять фильтры нецензурных слов. Фильтр нецензурных слов позволяет вам заменять нецензурные слова в сообщениях пользователей, в подписях и в названиях тем.
Совпадение по маске: при выборе способа 'Маска', введенное вами слово будет изменяться даже в словах, содержащих в себе это слово. Например, если вы введете в фильтр слово 'коза', то это слово будет изменено на указанный вами заменитель и в слове 'стрекоза'. Если вы не введете заменитель, то нецензурное слово будет изменено на шесть символов «решетки» — #
Точное совпадение:: При выборе способа 'Точный', введенное вами слово будет изменяться на заменитель только при точном совпадении этого слова. Например, если вы введете в фильтр слово 'коза', то это слово будет изменено на указанный вами заменитель, только в слове 'коза'. Если вы не введете заменитель, то нецензурное слово будет изменено на шесть символов «решетки» — #.
Данная опция чувствительна к регистру.";
$this->ipsclass->admin->page_title = "Фильтр нецензурных слов";
//-----------------------------------------
// Start form
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'badword_add' ),
2 => array( 'act' , 'babw' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "Слово" , "30%" );
$this->ipsclass->adskin->td_header[] = array( "Замена" , "30%" );
$this->ipsclass->adskin->td_header[] = array( "Метод" , "20%" );
$this->ipsclass->adskin->td_header[] = array( "Изменить" , "10%" );
$this->ipsclass->adskin->td_header[] = array( "Удалить" , "10%" );
//-----------------------------------------
// Start table
//-----------------------------------------
$export_button = $this->ipsclass->adskin->js_make_button("Импортирование файла с фильтрами нецензурных слов", $this->ipsclass->base_url."&{$this->ipsclass->form_code}&code=badword_export");
$table = "