- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
<?
function clearComma($str)
{
$str = preg_replace("#(,|\.|-|\/|:|;|\"|'|\?|\(|\)|\\|*)#", '', $str);
return $str;
}
function generate($bold_o, $bold_c)
{
$art = file_get_contents('article.txt');
$voc_str_mass = file('voc.txt');
$key = file('key.txt');
foreach ($key as $word)
{
$keys[] = trim($word);
}
foreach ($voc_str_mass as $voc_str)
{
$voc[] = explode("\t", trim($voc_str));
}
$words_massive = explode(' ', clearComma($art));
foreach ($words_massive as $word)
{
if (strlen($word) > 3)
{
foreach ($voc as $check)
{
if (in_array($word, $check) && $word != 'keyword')
{
$c = count($check);
$art = str_replace($word, $check[rand(0, $c - 1)], $art);
}
}
}
}
$art_mass = explode(' ', $art);
foreach ($art_mass as $string)
{
$art_out .= str_replace('keyword', $bold_o . $keys[rand(0, count($keys) - 1)] . $bold_c, $string) . ' ';
}
return $art_out;
}
//echo(generate('<b>', '</b>'));
//exit();
$tpl_mass = file("tpl.tpl");
foreach ($tpl_mass as $tpl_string)
{
$template .= str_replace('{GENERATE}', generate('<b>', '</b>'), $tpl_string);
}
//$date = date(d).'-'.date(m).'-'.date(Y).'_'.date(H).'-'.date(i).'-'.date(s);
$handle = fopen($date . '_generated.html', "w");
fwrite($handle, $template);
fclose($handle);
?>