예제 #1
0
파일: hex.php 프로젝트: sbaldrich/boca
function decryptData($crypttext, $key, $txt = '')
{
    $crypttext = base64_decode($crypttext);
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
    $test1 = '';
    $test2 = 'x';
    $clen = strlen($crypttext);
    if ($clen > $iv_size) {
        $iv = substr($crypttext, $clen - $iv_size, $iv_size);
        $crypttext = substr($crypttext, 0, $clen - $iv_size);
        $key = myhash($key . "123456789012345678901234567890");
        // . myhash($key);
        $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, substr(pack("H*", $key), 0, 32), $crypttext, MCRYPT_MODE_CBC, $iv);
        $pos = strrpos($decrypttext, "#");
        $iscompressed = false;
        if (substr($decrypttext, $pos - 1, 1) == '@') {
            $iscompressed = true;
        }
        $ll = strlen(myshorthash("x"));
        $test2 = substr($decrypttext, $pos - 1 - $ll, $ll);
        $decrypttext = substr($decrypttext, 0, $pos - 1 - $ll);
        $test1 = myshorthash($decrypttext);
    }
    if ($test1 != $test2) {
        if ($txt == '') {
            MSGError("Decryption error -- contact an admin now (" . getFunctionName() . ")");
        }
        //		LogError("Decryption error -- contact an admin, possibly password wrong (" . getFunctionName() .",$txt)");
        return "";
    }
    if ($iscompressed) {
        return unzipstr($decrypttext);
    }
    return $decrypttext;
}
예제 #2
0
파일: db.php 프로젝트: joffilyfe/boca
function DBGetRow($sql, $i, $c = null, $txt = '')
{
    if ($txt == '') {
        $txt = 'unknown at ' . getFunctionName();
    }
    if ($c == null) {
        $c = DBConnect();
    }
    $r = DBExec($c, $sql, $txt);
    if (DBnlines($r) < $i + 1) {
        return null;
    }
    $a = DBRow($r, $i);
    if (!$a) {
        LOGError("Unable to get row {$i} from a query ({$txt}). SQL=(" . $sql . ")");
        MSGError("Unable to get row from query ({$txt}).");
        exit;
    }
    return $a;
}
예제 #3
0
파일: fzip.php 프로젝트: sbaldrich/boca
function zipstr($str)
{
    if (!function_exists('gzcompress')) {
        MSGError("Compression error -- zlib not installed (" . getFunctionName() . ")");
        LogError("Compression error -- zlib not installed (" . getFunctionName() . ")");
    }
    return gzcompress($str . '#' . myshorthash($str));
}