<?
// DeZend by Zeratul
class workimage
{
var $error = null;
var $filename = null;
var $masinfo = null;
var $binimage2 = null;
function workimage ()
{
$this->error = '';
$this->filename = 'info.txt';
$this->masinfo = array ();
$this->binimage2 = array ();
}
function readinfo ($type)
{
$fd = fopen ($this->filename, 'r');
$find = 0;
while (!feof ($fd))
{
$string = fgets ($fd);
if (preg_match ('/\\[type=' . $type . '\\]/', $string))
{
$find = 1;
break;
}
}
if (!$find)
{
$this->error = 'Не найдена информация о ' . $tgpname;
return 0;
}
while (!feof ($fd))
{
$string = fgets ($fd);
if (preg_match ('/\\[.*\\]/', $string))
{
break;
}
$mas = explode ('=', $string);
$this->masinfo[trim ($mas[0])] = trim ($mas[1]);
}
return 1;
}
function getfiles ($dir)
{
if ($handle = opendir ($dir))
{
while (false !== $file = readdir ($handle))
{
if (($file != '.' AND $file != '..'))
{
$mas[] = $file;
continue;
}
}
closedir ($handle);
}
return $mas;
}
function loadalphabet ($dir)
{
$files = $this->getfiles ($dir);
for ($k = 0; $k < count ($files); ++$k)
{
$fd = fopen ($dir . '/' . $files[$k], 'r');
$info = fscanf ($fd, '%s %d %d');
$x = $info[2];
$y = $info[1];
$symbol = $info[0];
$alphabet[$k]['symbol'] = $symbol;
for ($i = 0; $i < $y; ++$i)
{
for ($j = 0; $j < $x; ++$j)
{
$alphabet[$k]['mas'][$j][$i] = fgetc ($fd);
}
fgets ($fd);
}
}
return $alphabet;
}
function savesymbols ($massymbols)
{
for ($k = 0; $k < count ($massymbols); ++$k)
{
$fd = fopen ('temp/' . microtime () . '.txt', 'w');
fputs ($fd, ' ' . count ($massymbols[$k][0]) . ' ' . count ($massymbols[$k]) . '
');
for ($j = 0; $j < count ($massymbols[$k][0]); ++$j)
{
$str = '';
for ($i = 0; $i < count ($massymbols[$k]); ++$i)
{
$str .= $massymbols[$k][$i][$j];
}
fputs ($fd, $str . '
');
}
fclose ($fd);
}
}
function imagecreatefrombmp ($file)
{
$bmp_data = substr ($file, 0, 54);
$bmp_file_header = substr ($bmp_data, 0, 14);
$file_header = unpack ('stype/lsize/s2recerved/loffbits', $bmp_file_header);
$bmp_info_header = substr ($bmp_data, 14, 40);
$info_header = unpack ('lsize/lwidth/lheight/splanes/sbit_count/lcompression/lsize_image/lx_pels_per_meter/ly_pels_per_meter/lclr_used/lclr_important', $bmp_info_header);
if ($info_header['bit_count'] == 24)
{
$image = imagecreatetruecolor ($info_header['width'], $info_header['height']);
$bmp = substr ($file, 54, $info_header['size_image']);
$fullwidth = ceil ($info_header['width'] / 4) * 4;
for ($j = 0; $j < $info_header['height']; ++$j)
{
for ($i = 0; $i < $info_header['width']; ++$i)
{
$temp = substr ($bmp, ($fullwidth * $j + $i) * 3, 3);
$mas = unpack ('Cr/Cg/Cb', $temp);
imagesetpixel ($image, $i, $info_header['height'] - $j - 1, $mas['r'] + $mas['g'] * 256 + $mas['b'] * 65536);
}
}
}
if ($info_header['bit_count'] == 8)
{
$image = imagecreatetruecolor ($info_header['width'], $info_header['height']);
$rgb = substr ($file, 54, $file_header['offbits'] - 54);
$bmp = substr ($file, $file_header['offbits'], $info_header['size_image']);
$rgbcount = ($file_header['offbits'] - 54) / 4;
for ($i = 0; $i < $rgbcount; ++$i)
{
$temp = substr ($rgb, $i * 4, 4);
$rgbmas[] = unpack ('Cr/Cg/Cb/Cs', $temp);
}
$fullwidth = ceil ($info_header['width'] / 4) * 4;
for ($j = 0; $j < $info_header['height']; ++$j)
{
for ($i = 0; $i < $info_header['width']; ++$i)
{
$temp = substr ($bmp, $fullwidth * $j + $i, 1);
$mas = unpack ('Cc', $temp);
imagesetpixel ($image, $i, $info_header['height'] - $j - 1, $rgbmas[$mas['c']]['r'] + $rgbmas[$mas['c']]['g'] * 256 + $rgbmas[$mas['c']]['b'] * 65536);
}
}
}
return $image;
}
function imagecreatefrompic ($file)
{
if (($file[0] == 'B' AND $file[1] == 'M'))
{
$image = $this->imagecreatefrombmp ($file);
}
else
{
$image = imagecreatefromstring ($file);
}
return $image;
}
function imagetobin ($image)
{
$picx = imagesx ($image);
$picy = imagesy ($image);
for ($i = 0; $i < $picx; ++$i)
{
for ($j = 0; $j < $picy; ++$j)
{
$color_index = imagecolorat ($image, $i, $j);
$color_tran = imagecolorsforindex ($image, $color_index);
if ($this->masinfo['maincolor'] == 'black')
{
if ($this->masinfo['sensitivity'] < ($color_tran['red'] - 255) * ($color_tran['red'] - 255) + ($color_tran['green'] - 255) * ($color_tran['green'] - 255) + ($color_tran['blue'] - 255) * ($color_tran['blue'] - 255))
{
$binimage[$i][$j] = 1;
}
else
{
$binimage[$i][$j] = 0;
}
}
if ($this->masinfo['maincolor'] == 'white')
{
if (($color_tran['red'] - 255) * ($color_tran['red'] - 255) + ($color_tran['green'] - 255) * ($color_tran['green'] - 255) + ($color_tran['blue'] - 255) * ($color_tran['blue'] - 255) < $this->masinfo['sensitivity'])
{
$binimage[$i][$j] = 1;
}
else
{
$binimage[$i][$j] = 0;
}
}
if (!empty ($this->masinfo['sensitivity2']))
{
if ($this->masinfo['maincolor'] == 'black')
{
if ($this->masinfo['sensitivity2'] < ($color_tran['red'] - 255) * ($color_tran['red'] - 255) + ($color_tran['green'] - 255) * ($color_tran['green'] - 255) + ($color_tran['blue'] - 255) * ($color_tran['blue'] - 255))
{
$this->binimage2[$i][$j] = 1;
}
else
{
$this->binimage2[$i][$j] = 0;
}
}
if ($this->masinfo['maincolor'] == 'white')
{
if (($color_tran['red'] - 255) * ($color_tran['red'] - 255) + ($color_tran['green'] - 255) * ($color_tran['green'] - 255) + ($color_tran['blue'] - 255) * ($color_tran['blue'] - 255) < $this->masinfo['sensitivity2'])
{
$this->binimage2[$i][$j] = 1;
continue;
}
else
{
$this->binimage2[$i][$j] = 0;
continue;
}
continue;
}
continue;
}
}
}
return $binimage;
}
function binfilter1 ($binimage)
{
for ($j = 0; $j < count ($binimage); ++$j)
{
$binimage[$j][0] = 0;
$binimage[$j][count ($binimage[0]) - 1] = 0;
}
for ($j = 0; $j < count ($binimage[0]); ++$j)
{
$binimage[0][$j] = 0;
$binimage[count ($binimage) - 1][$j] = 0;
}
return $binimage;
}
function binfilter2 ($binimage)
{
for ($j = 0; $j < count ($binimage); ++$j)
{
if ($binimage[$j][0] == 1)
{
for ($i = 0; $i < count ($binimage[0]); ++$i)
{
if ($binimage[$j - 1][$i] + $binimage[$j + 1][$i] == 0)
{
$binimage[$j][$i] = 0;
continue;
}
}
continue;
}
}
for ($j = 0; $j < count ($binimage[0]); ++$j)
{
if ($binimage[0][$j] == 1)
{
for ($i = 0; $i < count ($binimage); ++$i)
{
if ($binimage[$i][$j - 1] + $binimage[$i][$j + 1] == 0)
{
$binimage[$i][$j] = 0;
continue;
}
}
continue;
}
}
return $binimage;
}
function binfilter3 ($binimage)
{
for ($j = 0; $j < count ($binimage[0]); ++$j)
{
if ($binimage[0][$j] == 1)
{
for ($i = 0; $i < count ($binimage); ++$i)
{
if ($binimage[$i][$j - 1] + $binimage[$i][$j + 1] == 0)
{
$binimage[$i][$j] = 0;
continue;
}
}
continue;
}
}
return $binimage;
}
function binfilter ($binimage)
{
$mas = explode (',', $this->masinfo['binfilters']);
for ($i = 0; $i < count ($mas); ++$i)
{
switch ($mas[$i])
{
case 'binfilter1':
{
$binimage = $this->binfilter1 ($binimage);
break;
}
case 'binfilter2':
{
$binimage = $this->binfilter2 ($binimage);
break;
}
case 'binfilter3':
{
$binimage = $this->binfilter3 ($binimage);
}
}
}
return $binimage;
}
function selectsymbol ($binimage, $i, $j)
{
$count = 0;
$doit = 0;
$temp[$count]['x'] = $i;
$temp[$count]['y'] = $j;
++$count;
while ($doit < count ($temp))
{
$x = $temp[$doit]['x'];
$y = $temp[$doit]['y'];
++$doit;
if ($binimage[$x - 1][$y] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y;
++$count;
$binimage[$x - 1][$y] = 0;
}
if ($binimage[$x][$y + 1] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y + 1;
++$count;
$binimage[$x][$y + 1] = 0;
}
if ($binimage[$x][$y - 1] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y - 1;
++$count;
$binimage[$x][$y - 1] = 0;
}
if ($binimage[$x - 1][$y + 1] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y + 1;
++$count;
$binimage[$x - 1][$y + 1] = 0;
}
if ($binimage[$x - 1][$y - 1] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y - 1;
++$count;
$binimage[$x - 1][$y - 1] = 0;
}
if (!empty ($this->masinfo['downsize']))
{
if ($binimage[$x][$y + 2] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y + 2;
++$count;
$binimage[$x][$y + 2] = 0;
}
if ($binimage[$x][$y + 3] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y + 3;
++$count;
$binimage[$x][$y + 3] = 0;
}
}
if (!empty ($this->masinfo['maxwidth']))
{
if ($this->masinfo['maxwidth'] <= $x - $i)
{
continue;
}
}
if ($binimage[$x + 1][$y + 1] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y + 1;
++$count;
$binimage[$x + 1][$y + 1] = 0;
}
if ($binimage[$x + 1][$y - 1] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y - 1;
++$count;
$binimage[$x + 1][$y - 1] = 0;
}
if ($binimage[$x + 1][$y] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y;
++$count;
$binimage[$x + 1][$y] = 0;
continue;
}
}
$minx = 999999999;
$maxx = -1;
$miny = 999999999;
$maxy = -1;
for ($i = 0; $i < count ($temp); ++$i)
{
if ($temp[$i]['x'] < $minx)
{
$minx = $temp[$i]['x'];
}
if ($temp[$i]['y'] < $miny)
{
$miny = $temp[$i]['y'];
}
if ($maxx < $temp[$i]['x'])
{
$maxx = $temp[$i]['x'];
}
if ($maxy < $temp[$i]['y'])
{
$maxy = $temp[$i]['y'];
continue;
}
}
for ($i = 0; $i < count ($temp); ++$i)
{
$mas[$temp[$i]['x'] - $minx][$temp[$i]['y'] - $miny] = 1;
}
for ($i = 0; $i < $maxx - $minx + 1; ++$i)
{
for ($j = 0; $j < $maxy - $miny + 1; ++$j)
{
if ($mas[$i][$j] != 1)
{
$mas[$i][$j] = 0;
continue;
}
}
}
return $mas;
}
function selectwithsymbol ($binimage, $i, $j)
{
$count = 0;
$doit = 0;
$newcount = 0;
$temp[$count]['x'] = $i;
$temp[$count]['y'] = $j;
++$count;
$newtemp[$newcount]['x'] = $i;
$newtemp[$newcount]['y'] = $j;
++$newcount;
while ($doit < count ($temp))
{
$x = $temp[$doit]['x'];
$y = $temp[$doit]['y'];
++$doit;
if ($this->masinfo['maxwidth'] <= $x - $i)
{
continue;
}
else
{
if ($this->masinfo['maxheight'] <= $y - $j)
{
continue;
}
else
{
if ($x < $i)
{
continue;
}
else
{
if ($binimage[$x][$y] == 1)
{
$newtemp[$newcount]['x'] = $x;
$newtemp[$newcount]['y'] = $y;
++$newcount;
$binimage[$x][$y] = 0;
}
if ($this->binimage2[$x + 1][$y] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y;
++$count;
$this->binimage2[$x + 1][$y] = 0;
}
if ($this->binimage2[$x - 1][$y] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y;
++$count;
$this->binimage2[$x - 1][$y] = 0;
}
if ($this->binimage2[$x][$y + 1] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y + 1;
++$count;
$this->binimage2[$x][$y + 1] = 0;
}
if ($this->binimage2[$x][$y - 1] == 1)
{
$temp[$count]['x'] = $x;
$temp[$count]['y'] = $y - 1;
++$count;
$this->binimage2[$x][$y - 1] = 0;
}
if ($this->binimage2[$x + 1][$y + 1] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y + 1;
++$count;
$this->binimage2[$x + 1][$y + 1] = 0;
}
if ($this->binimage2[$x + 1][$y - 1] == 1)
{
$temp[$count]['x'] = $x + 1;
$temp[$count]['y'] = $y - 1;
++$count;
$this->binimage2[$x + 1][$y - 1] = 0;
}
if ($this->binimage2[$x - 1][$y + 1] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y + 1;
++$count;
$this->binimage2[$x - 1][$y + 1] = 0;
}
if ($this->binimage2[$x - 1][$y - 1] == 1)
{
$temp[$count]['x'] = $x - 1;
$temp[$count]['y'] = $y - 1;
++$count;
$this->binimage2[$x - 1][$y - 1] = 0;
continue;
}
continue;
}
continue;
}
continue;
}
}
$minx = 999999999;
$maxx = -1;
$miny = 999999999;
$maxy = -1;
for ($i = 0; $i < count ($newtemp); ++$i)
{
if ($newtemp[$i]['x'] < $minx)
{
$minx = $newtemp[$i]['x'];
}
if ($newtemp[$i]['y'] < $miny)
{
$miny = $newtemp[$i]['y'];
}
if ($maxx < $newtemp[$i]['x'])
{
$maxx = $newtemp[$i]['x'];
}
if ($maxy < $newtemp[$i]['y'])
{
$maxy = $newtemp[$i]['y'];
continue;
}
}
for ($i = 0; $i < count ($newtemp); ++$i)
{
$mas[$newtemp[$i]['x'] - $minx][$newtemp[$i]['y'] - $miny] = 1;
}
while (true)
{
for ($i = 0; $i < $maxx - $minx + 1; ++$i)
{
for ($j = 0; $j < $maxy - $miny + 1; ++$j)
{
if ($mas[$i][$j] != 1)
{
$mas[$i][$j] = 0;
continue;
}
}
}
break;
}
return $mas;
}
function decsymbol ($binimage)
{
$picx = count ($binimage);
$picy = count ($binimage[0]);
for ($i = 0; $i < $picx; ++$i)
{
for ($j = 0; $j < $picy; ++$j)
{
if ($binimage[$i][$j] == 1)
{
$massymbols[] = $this->selectsymbol (&$binimage, $i, $j);
continue;
}
}
}
return $massymbols;
}
function decwithsymbol ($binimage)
{
$picx = count ($binimage);
$picy = count ($binimage[0]);
for ($i = 0; $i < $picx; ++$i)
{
for ($j = 0; $j < $picy; ++$j)
{
if ($binimage[$i][$j] == 1)
{
$massymbols[] = $this->selectwithsymbol (&$binimage, $i, $j);
continue;
}
}
}
return $massymbols;
}
function equalsymbol ($binimage)
{
$x = $this->masinfo['firstx'] - 1;
$y = $this->masinfo['firsty'] - 1;
$doit = 1;
while ($doit)
{
$symbol = array ();
$doit = 0;
for ($i = $x; $i < $x + $this->masinfo['width']; ++$i)
{
for ($j = $y; $j < $y + $this->masinfo['height']; ++$j)
{
$symbol[$i - $x][$j - $y] = $binimage[$i][$j];
}
}
$count = 0;
for ($i = 0; $i < count ($symbol); ++$i)
{
for ($j = 0; $j < count ($symbol[0]); ++$j)
{
if ($symbol[$i][$j] == 1)
{
++$count;
continue;
}
}
}
if ($this->masinfo['height'] < $count)
{
$doit = 1;
$massymbols[] = $symbol;
}
$x += $this->masinfo['width'] + $this->masinfo['between'];
}
return $massymbols;
}
function delsymbol ($symbol)
{
$min = 9999999;
$mini = -1;
$tmps = $symbol;
for ($i = 4; $i < count ($symbol) - 4; ++$i)
{
$col = 0;
$isone = 0;
for ($j = 0; $j < count ($symbol[$i]); ++$j)
{
if ($symbol[$i][$j] == 1)
{
$tmps[$i][$j] = 0;
$isone = 1;
}
if (($symbol[$i][$j] == 1 AND $symbol[$i + 1][$j] == 1))
{
++$col;
}
if (($symbol[$i][$j] == 0 AND $isone == 1))
{
break;
}
}
for ($k = 0; $k < count ($symbol[$i]); ++$k)
{
if ($tmps[$i][$k] == 1)
{
$col = 9999999;
break;
}
}
if ($col <= $min)
{
$min = $col;
$mini = $i;
continue;
}
}
for ($i = 0; $i <= $mini; ++$i)
{
for ($j = 0; $j < count ($symbol[$i]); ++$j)
{
$temp[0][$i][$j] = $symbol[$i][$j];
}
}
for ($i = $mini + 1; $i < count ($symbol); ++$i)
{
for ($j = 0; $j < count ($symbol[$i]); ++$j)
{
$temp[1][$i - $mini - 1][$j] = $symbol[$i][$j];
}
}
$count[0] = 0;
$count[1] = 0;
for ($k = 0; $k < 2; ++$k)
{
for ($i = 0; $i < count ($temp[$k]); ++$i)
{
for ($j = 0; $j < count ($temp[$k][$i]); ++$j)
{
if ($temp[$k][$i][$j] == 1)
{
$newtemp[$k][$count[$k]]['x'] = $i;
$newtemp[$k][$count[$k]]['y'] = $j;
++$count[$k];
continue;
}
}
}
}
for ($k = 0; $k < 2; ++$k)
{
$minx = 999999999;
$maxx = -1;
$miny = 999999999;
$maxy = -1;
for ($i = 0; $i < count ($newtemp[$k]); ++$i)
{
if ($newtemp[$k][$i]['x'] < $minx)
{
$minx = $newtemp[$k][$i]['x'];
}
if ($newtemp[$k][$i]['y'] < $miny)
{
$miny = $newtemp[$k][$i]['y'];
}
if ($maxx < $newtemp[$k][$i]['x'])
{
$maxx = $newtemp[$k][$i]['x'];
}
if ($maxy < $newtemp[$k][$i]['y'])
{
$maxy = $newtemp[$k][$i]['y'];
continue;
}
}
for ($i = 0; $i < count ($newtemp[$k]); ++$i)
{
$mas[$k][$newtemp[$k][$i]['x'] - $minx][$newtemp[$k][$i]['y'] - $miny] = 1;
}
for ($i = 0; $i < $maxx - $minx + 1; ++$i)
{
for ($j = 0; $j < $maxy - $miny + 1; ++$j)
{
if ($mas[$k][$i][$j] != 1)
{
$mas[$k][$i][$j] = 0;
continue;
}
}
}
}
return $mas;
}
function countsymbol ($binimage)
{
$picx = count ($binimage);
$picy = count ($binimage[0]);
for ($i = 0; $i < $picx; ++$i)
{
for ($j = 0; $j < $picy; ++$j)
{
if ($binimage[$i][$j] == 1)
{
$massymbols[] = $this->selectwithsymbol (&$binimage, $i, $j);
continue;
}
}
}
while (count ($massymbols) < $this->masinfo['count'])
{
$max = -1;
$maxi = -1;
for ($i = 0; $i < count ($massymbols); ++$i)
{
if ($max < count ($massymbols[$i]))
{
$max = count ($massymbols[$i]);
$maxi = $i;
continue;
}
}
$tmp = $this->delsymbol ($massymbols[$maxi]);
for ($i = count ($massymbols); $maxi + 1 < $i; --$i)
{
$massymbols[$i] = $massymbols[$i - 1];
}
$massymbols[$maxi] = $tmp[0];
$massymbols[$maxi + 1] = $tmp[1];
}
return $massymbols;
}
function doit ($massymbols, $alphabet)
{
$passphrase = '';
for ($k = 0; $k < count ($massymbols); ++$k)
{
$maxs = -1;
$indexmax = -1;
$minr = 99999999999;
$indexmin = -1;
for ($a = 0; $a < count ($alphabet); ++$a)
{
$s = 0;
$r = 0;
if (count ($alphabet[$a]['mas'][0]) < count ($massymbols[$k][0]))
{
$y = count ($massymbols[$k][0]);
}
else
{
$y = count ($alphabet[$a]['mas'][0]);
}
if (count ($alphabet[$a]['mas']) < count ($massymbols[$k]))
{
$x = count ($massymbols[$k]);
}
else
{
$x = count ($alphabet[$a]['mas']);
}
for ($i = 0; $i < $x; ++$i)
{
for ($j = 0; $j < $y; ++$j)
{
if ($alphabet[$a]['mas'][$i][$j] == $massymbols[$k][$i][$j])
{
++$s;
continue;
}
else
{
++$r;
continue;
}
}
}
if ($maxs < $s)
{
$maxs = $s;
$indexmax = $a;
}
if ($r < $minr)
{
$minr = $r;
$indexmin = $a;
continue;
}
}
if ($this->masinfo['compare'] == 'max')
{
$passphrase .= $alphabet[$indexmax]['symbol'];
}
if ($this->masinfo['compare'] == 'min')
{
$passphrase .= $alphabet[$indexmin]['symbol'];
continue;
}
}
$passphrase = str_replace ('~', '', $passphrase);
return $passphrase;
}
function findsymbols ($binimage)
{
switch ($this->masinfo['search_symbols'])
{
case 'decsymbol':
{
$massymbols = $this->decsymbol ($binimage);
break;
}
case 'decwithsymbol':
{
$massymbols = $this->decwithsymbol ($binimage);
break;
}
case 'equalsymbol':
{
$massymbols = $this->equalsymbol ($binimage);
break;
}
case 'countsymbol':
{
$massymbols = $this->countsymbol ($binimage);
}
}
return $massymbols;
}
function work ($file, $type)
{
$this->readinfo ($type);
$image = $this->imagecreatefrompic ($file);
unset ($file);
$binimage = $this->imagetobin ($image);
unset ($image);
$binimage = $this->binfilter ($binimage);
$massymbols = $this->findsymbols ($binimage);
unset ($binimage);
unset ($this[binimage2]);
$alphabet = $this->loadalphabet ($this->masinfo['path_to_alphabet']);
$passphrase = $this->doit ($massymbols, $alphabet);
return $passphrase;
}
function razbit ()
{
$fmas = $this->getfiles ('images');
$this->readinfo (2);
for ($i = 0; $i < count ($fmas); ++$i)
{
$file = file_get_contents ('images/' . $fmas[$i]);
$binimage = $this->imagetobin ($this->imagecreatefrompic ($file));
$binimage = $this->binfilter ($binimage);
$massymbols = $this->findsymbols ($binimage);
$this->savesymbols ($massymbols);
}
}
function testdoit ()
{
$this->readinfo (2);
$dir = 'images';
$alphabet = $this->loadalphabet ($this->masinfo['path_to_alphabet']);
$files = $this->getfiles ($dir);
for ($i = 0; $i < count ($files); ++$i)
{
$file = file_get_contents ($dir . '/' . $files[$i]);
$binimage = $this->imagetobin ($this->imagecreatefrompic ($file));
$binimage = $this->binfilter ($binimage);
$massymbols = $this->findsymbols ($binimage);
$passphrase = $this->doit ($massymbols, $alphabet);
echo '<img src="' . $dir . '/' . $files[$i] . '">' . $passphrase . '<br>' . '
';
}
}
}
?>