filter_mode = false; // ******************************************************************************** // Добавление слова // ******************************************************************************** if( $action == "add" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) {die( "Hacking attempt! User not found" );} $word_find = trim( strip_tags( stripslashes( $_POST['word_find'] ) ) ); if( $word_find == "" ) { msg( "error", $lang['word_error'], $lang['word_word'], "?mod=wordfilter" ); } if( $word_replace == "($lang[word_del])" ) { $word_replace = ""; } $word_replace = stripslashes( $parse->BB_Parse( $parse->process( $_POST['word_replace'] ), false ) ); $word_id = time(); $all_items = file( SYSTEM_DIR . '/data/wordfilter.db.php' ); foreach ( $all_items as $item_line ) { $item_arr = explode( "|", $item_line ); if( $item_arr[0] == $word_id ) { $word_id ++; } } foreach ( $all_items as $word_line ) { $word_arr = explode( "|", $word_line ); if( $word_arr[1] == $word_find ) { msg( "error", $lang['word_error'], $lang['word_ar'], "?mod=wordfilter" ); } } $new_words = fopen( SYSTEM_DIR . '/data/wordfilter.db.php', "a" ); $word_find = str_replace( "|", "|", $word_find ); $word_replace = str_replace( "|", "|", $word_replace ); $word_find = str_replace( "$", "$", $word_find ); $word_find = str_replace( "{", "{", $word_find ); $word_find = str_replace( "}", "}", $word_find ); $word_replace = str_replace( "$", "$", $word_replace ); $word_replace = str_replace( "{", "{", $word_replace ); $word_replace = str_replace( "}", "}", $word_replace ); fwrite( $new_words, "$word_id|$word_find|$word_replace|" . intval( $_POST['type'] ) . "|". intval( $_POST['register'] ) ."|". intval( $_POST['filter_search'] ) ."|". intval( $_POST['filter_action'] ) ."||\n" ); fclose( $new_words ); } // ******************************************************************************** // Удаление слова // ******************************************************************************** elseif( $action == "remove" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) { die( "Hacking attempt! User not found" ); } if( ! $word_id ) { msg( "error", $lang['word_error'], $lang['word_nof'], "$PHP_SELF?mod=wordfilter" ); } $old_words = file( SYSTEM_DIR . '/data/wordfilter.db.php' ); $new_words = fopen( SYSTEM_DIR . '/data/wordfilter.db.php', "w" ); foreach ( $old_words as $old_words_line ) { $word_arr = explode( "|", $old_words_line ); if( $word_arr[0] != $word_id ) { fwrite( $new_words, $old_words_line ); } } fclose( $new_words ); } // ******************************************************************************** // Редактирование слова // ******************************************************************************** elseif( $action == "edit" ) { // Check if Filter was specified if( ! $word_id ) { msg( "error", $lang['word_error'], $lang['word_nof'], "$PHP_SELF?mod=wordfilter" ); } // Search & Load filter in to the Form $all_words = file( SYSTEM_DIR . '/data/wordfilter.db.php' ); foreach ( $all_words as $word_line ) { $word_arr = explode( "|", $word_line ); if( $word_arr[0] == $word_id ) { $word_arr[1] = $parse->decodeBBCodes( $word_arr[1], false ); $word_arr[2] = $parse->decodeBBCodes( $word_arr[2], false ); if( $word_arr[3] ) $selected = "selected"; else $selected = ""; if( $word_arr[4] ) $selected_1 = "selected"; else $selected_1 = ""; $selected_2[$word_arr[5]] = "selected"; $selected_3[$word_arr[6]] = "selected"; $msg = "
{$lang['word_word']}
{$lang['word_rep']}
{$lang['filter_type']}
{$lang['filter_register']}
{$lang['filter_search']}
{$lang['filter_action']}
 
"; // Messages msg( "wordfilter", $lang['word_head'], $msg ); } } } // ******************************************************************************** // Сохранение слова // ******************************************************************************** elseif( $action == "doedit" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) { die( "Hacking attempt! User not found" ); } $word_find = trim( strip_tags( stripslashes( $_POST['word_find'] ) ) ); if( $word_find == "" ) { msg( "error", $lang['word_error'], $lang['word_word'], "javascript:history.go(-1)" ); } $word_replace = stripslashes( $parse->BB_Parse( $parse->process( $_POST['word_replace'] ), false ) ); $word_find = str_replace( "|", "|", $word_find ); $word_replace = str_replace( "|", "|", $word_replace ); $word_find = str_replace( "$", "$", $word_find ); $word_find = str_replace( "{", "{", $word_find ); $word_find = str_replace( "}", "}", $word_find ); $word_replace = str_replace( "$", "$", $word_replace ); $word_replace = str_replace( "{", "{", $word_replace ); $word_replace = str_replace( "}", "}", $word_replace ); $old_words = file( SYSTEM_DIR . '/data/wordfilter.db.php' ); $new_words = fopen( SYSTEM_DIR . '/data/wordfilter.db.php', "w" ); foreach ( $old_words as $word_line ) { $word_arr = explode( "|", $word_line ); if( $word_arr[0] == $word_id ) { fwrite( $new_words, "$word_id|$word_find|$word_replace|" . intval( $_POST['type'] ) . "|". intval( $_POST['register'] ) ."|". intval( $_POST['filter_search'] ) ."|". intval( $_POST['filter_action'] ) ."||\n" ); } else { fwrite( $new_words, $word_line ); } } fclose( $new_words ); } // ******************************************************************************** // Список слов // ******************************************************************************** echoheader( "wordfilter", $lang['word_head'] ); echo <<
{$lang['word_word']}
{$lang['word_rep']}
{$lang['filter_type']}
{$lang['filter_register']}
{$lang['filter_search']}
{$lang['filter_action']}
 
HTML; $all_words = file( SYSTEM_DIR . '/data/wordfilter.db.php' ); $count_words = 0; usort( $all_words, "compare_filter" ); foreach ( $all_words as $word_line ) { $word_arr = explode( "|", $word_line ); $result .= " "; $count_words ++; } if( $count_words == 0 ) { echo " "; } else { echo ""; echo $result; } echo ""; echo <<
$word_arr[1] "; if( $word_arr[2] == "" ) { $result .= "$lang[word_del]"; } else { $result .= "$word_arr[2]"; } $type = ($word_arr[3]) ? $lang['filter_type_2'] : $lang['filter_type_1']; $register = ($word_arr[4]) ? $lang['opt_sys_yes'] : $lang['opt_sys_no']; $result .= "{$register}{$type}{$lang['filter_search_'.$word_arr[5]]}{$lang['filter_action_'.$word_arr[6]]} [ {$lang[word_ledit]} ] [ $lang[word_ldel] ]


$lang[word_empty]

$lang[word_worte] $lang[word_lred] $lang[filter_register] $lang[filter_type] $lang[filter_search] $lang[filter_action]    

{$lang['word_help_2']}
HTML; echofooter(); ?>