private function decrypt_old($value)
 {
     if (strlen($value) <= 2) {
         return '';
     }
     if (ord($value[0]) == 1 && ord($value[1]) == 1) {
         // registry
         $value = substr($value, 2);
         if (strlen($value) <= 4) {
             return '';
         }
         $l = data_int32(substr($value, 0, 4));
         $value = substr($value, 4);
         if (strlen($value) != $l) {
             return '';
         }
         $value = chr(0x75) . chr(0x18) . chr(0x15) . chr(0x14) . $value;
         $decrypted_pass = '';
         for ($i = 1; $i <= int_divide($l, 4); $i++) {
             $int_value = data_int32(substr($value, $i * 4, 4)) ^ data_int32(substr($value, ($i - 1) * 4, 4));
             $value[$i * 4 + 0] = chr($int_value & 0xff);
             $value[$i * 4 + 1] = chr($int_value >> 8 & 0xff);
             $value[$i * 4 + 2] = chr($int_value >> 16 & 0xff);
             $value[$i * 4 + 3] = chr($int_value >> 24 & 0xff);
         }
         for ($i = int_divide($l, 4) * 4 + 1; $i <= int_divide($l, 4) * 4 + $l % 4; $i++) {
             $value[$i + 3] = chr(ord($value[$i + 3]) ^ ord($value[$i + 3 - $l % 4]));
         }
         return ztrim(substr($value, 4));
     } else {
         if (ord($value[0]) == 1 && ord($value[1]) == 2) {
             // pstorage
             $value = ztrim(unicode_to_ansi(substr($value, 2)));
             return assign($this->pstorage[$value]);
         }
     }
     return '';
 }
Example #2
0
function decrypt_cfbblock($module, $data, &$iv)
{
    $outdata = "";
    $p1 = substr($data, 0, 8);
    $p2 = '';
    for ($i = 0; $i < int_divide(strlen($data), 8); $i++) {
        $temp = $p1;
        $iv = mcrypt_generic($module, $iv);
        $p2 = $p1;
        $p2 = xor_block($p2, $iv);
        $iv = $temp;
        $outdata .= $p2;
        $p1 = substr($data, ($i + 1) * 8, 8);
    }
    if (strlen($data) % 8 != 0) {
        $iv = mcrypt_generic($module, $iv);
        $outdata .= xor_block(substr($data, -(strlen($data) % 8)), $iv);
    }
    $outdata = substr($outdata, 0, strlen($data));
    return $outdata;
}
Example #3
0
function vertlinex($tlx, $tly, $brx, $bry, $image, $approxw, $tolerance = 2, $attempts = 10, $searchlongest = true)
{
    //0 is black, 1 is white
    $x = 0;
    //try $attempts times to find start of line
    $yadd = int_divide($bry - $tly, $attempts);
    $s = array();
    $count = 0;
    $avg = 0;
    for ($y = $tly; $y < $bry; $y += $yadd) {
        $col = imagecolorat($image, $x, $y);
        $width = 0;
        $start = $x;
        for ($x = $tlx; $x < $brx; $x++) {
            $rgb = imagecolorat($image, $x, $y);
            if ($rgb != $col) {
                if ($width >= $approxw - $tolerance && $width <= $approxw + $tolerance && $col == 0) {
                    $s[$start + int_divide($width, 2)] = $y;
                    $count++;
                    $avg += $start;
                }
                $width = 0;
                $col = $rgb;
                $start = $x;
            }
            $width++;
            //print $rgb;
        }
        //print "<br/>\n";
    }
    if (empty($s)) {
        return 0;
    }
    //add ability to search for the line closest to a certain length - not just the longest which
    //may be a page artifact. need to define CORNER_LINE_LENGTH in pixels and enablels
    $line = 0;
    if ($searchlongest == false) {
        $line = 100000;
    }
    $longest = key($s);
    foreach ($s as $x => $yval) {
        $col = imagecolorat($image, $x, $tly);
        $width = 0;
        for ($y = $tly; $y < $bry; $y += 1) {
            $rgb = imagecolorat($image, $x, $y);
            if ($rgb != $col) {
                //print "X LINE: $x width: $width COL: $col<br/>";
                if ($searchlongest) {
                    if ($width > $line && $col == 0) {
                        $longest = $x;
                        $line = $width;
                    }
                } else {
                    if (abs($width - $approxw) < $line && $col == 0) {
                        $longest = $x;
                        $line = abs($width - $approxw);
                    }
                }
                $width = 0;
                $col = $rgb;
            }
            $width++;
        }
    }
    return $longest;
}