Вход Регистрация
Файл: dictionary-maker/make.php
Строк: 82
<?php



            
/**************************************************************************************************
            | 
            | http://alternanetworks.com
            | ask@alternanetworks.com
            |
            |**************************************************************************************************
            |
            | By using this software you agree that you have read and acknowledged our End-User License 
            | Agreement available at http://envato.com/ and to be bound by it.
            |
            | Copyright (c) 2011 alternanetworks.com All rights reserved.
            |
            | http://codecanyon.net/user/AlternaNetworks 
            |**************************************************************************************************/

            //error_reporting( E_ALL );
            //ini_set( 'display_errors', '1' );

            // replace array
            
$chars = array( 'Љ'=>'S''љ'=>'s''Ћ'=>'Z''ћ'=>'z''А'=>'A''Б'=>'A''В'=>'A''Г'=>'A''Д'=>'A''Е'=>'A''Ж'=>'A''З'=>'C''И'=>'E''Й'=>'E',
                            
'К'=>'E''Л'=>'E''М'=>'I''Н'=>'I''О'=>'I''П'=>'I''С'=>'N''Т'=>'O''У'=>'O''Ф'=>'O''Х'=>'O''Ц'=>'O''Ш'=>'O''Щ'=>'U',
                            
'Ъ'=>'U''Ы'=>'U''Ь'=>'U''Э'=>'Y''Ю'=>'B''Я'=>'Ss''а'=>'a''б'=>'a''в'=>'a''г'=>'a''д'=>'a''е'=>'a''ж'=>'a''з'=>'c',
                            
'и'=>'e''й'=>'e''к'=>'e''л'=>'e''м'=>'i''н'=>'i''о'=>'i''п'=>'i''р'=>'o''с'=>'n''т'=>'o''у'=>'o''ф'=>'o''х'=>'o',
                            
'ц'=>'o''ш'=>'o''щ'=>'u''ъ'=>'u''ы'=>'u''э'=>'y''э'=>'y''ю'=>'b''я'=>'y' );

            
$min = isset( $_POST['min'] ) && is_numeric$_POST['min'] ) ? $_POST['min'] : 4;
            
$max = isset( $_POST['max'] ) && is_numeric$_POST['max'] ) ? $_POST['max'] : 14;
            
$lowercase true;

            if ( isset( 
$_FILES['dictionary'] ) && $_FILES['dictionary']['error'] == ) {

                 
// setting min/max
                 
--$min;
                 ++
$max;

                 
// load the file
                 
$data file_get_contents$_FILES['dictionary']['tmp_name'] );

                 
// remove line breaks
                 
$data preg_replace"#n|r|rn#"' '$data );

                 
// replace unwanted chars
                 
$data strtr$data$chars );

                 
// remove non chars
                 
$data preg_replace"/[^p{L}p{N}]/m"' '$data );

                 
// remove short words
                 
$data preg_replace'/bw{1,' $min '}b/'''$data );

                 
// remove too long words
                 
$data preg_replace'/bw{' $max ',}b/'''$data );

                 
// make array
                 
$data explode' '$data );

                 
// remove empty
                 
$data array_filterarray_map'trim'$data ) );

                 
// if we want only lowercase
                 
$data $lowercase array_filterarray_map'strtolower'$data ) ) : $data;

                 
// unique array
                 
$data array_unique$data );

                 
// reset array
                 
$data array_values$data );

                 
// total of items
                 
$total count$data );

                 
// prepare dictionary
                 
$data json_encode$data );

                 
// get name
                 
$name pathinfo$_FILES['dictionary']['name'] );
                 
$name str_replace(' ','-',$name['filename']);

                 
// download dictionary
                 
header'Content-disposition: attachment; filename=' $name '.dictionary.php' );
                 
header'Content-type: text/plain' );
                 echo 
'<?php' "rn";
                 echo 
'if(!defined("CAPTCHA_LOAD_DICTIONARY")){die();}' "rn";
                 echo 
'/* dictionary words: ' $total ' */' "rn";
                 echo 
'/* created: ' date'r' ) . ' */' "rn";
                 echo 
'$words=' "'" $data "';";
                 exit;
            }
            
header'Location: ' $_SERVER['HTTP_REFERER'] );
Онлайн: 2
Реклама