Example #1
0
function crc32_file2($filename)
{
    return dechex(crc32_file($filename));
}
Example #2
0
<?php

function crc32_file($fileName)
{
    $crc = hash_file("crc32b", $fileName);
    $crc = sprintf("%08X", 0x100000000 + hexdec($crc));
    return substr($crc, 6, 2) . substr($crc, 4, 2) . substr($crc, 2, 2) . substr($crc, 0, 2);
}
echo crc32_file("http://example.com/dl/c1f35b6eff6d7d4039da371be48a1c93.nfo");
Example #3
0
/**
 * Create a zip file.
 *
 * @param  array			A list of maps (time,data/full_path,name) covering everything to zip up
 * @param  boolean		Whether to stream the output direct to the browser
 * @param  boolean		Whether to return the tuple
 * @return mixed			The data for the zip file OR a tuple: data, offsets, sizes
 */
function create_zip_file($file_array, $stream = false, $get_offsets = false)
{
    if ($stream) {
        ini_set('ocproducts.xss_detect', '0');
        flush();
        // Works around weird PHP bug that sends data before headers, on some PHP versions
    }
    $out = '';
    $offset = 0;
    $offsets = array();
    $sizes = array();
    // Write files
    foreach ($file_array as $i => $file) {
        $file_array[$i]['offset'] = $offset;
        $date = getdate($file['time']);
        if (!array_key_exists('data', $file) || is_null($file['data'])) {
            $crc = crc32_file($file['full_path']);
            $uncompressed_size = filesize($file['full_path']);
        } else {
            $crc = crc32($file['data']);
            $uncompressed_size = strlen($file['data']);
        }
        $file_array[$i]['crc'] = $crc;
        $compressed_size = $uncompressed_size;
        $now_date = $date['year'] - 1980 << 25 | $date['mon'] << 21 | $date['mday'] << 16 | $date['hours'] << 11 | $date['minutes'] << 5 | $date['seconds'] >> 1;
        $file_array[$i]['date'] = $now_date;
        $offsets[$file['name']] = $offset + 30 + strlen($file['name']);
        $out .= pack('VvvvVVVVvv', 0x4034b50, 10, 0, 0, $now_date, $crc, $compressed_size, $uncompressed_size, strlen($file['name']), 0);
        $out .= $file['name'];
        if ($stream) {
            echo $out;
            $offset += strlen($out) + $uncompressed_size;
            if (!array_key_exists('data', $file) || is_null($file['data'])) {
                readfile($file['full_path']);
            } else {
                echo $file['data'];
            }
            $out = '';
        } else {
            if (!array_key_exists('data', $file) || is_null($file['data'])) {
                $out .= file_get_contents($file['full_path'], FILE_BINARY);
            } else {
                $out .= $file['data'];
            }
            $offset = strlen($out);
        }
        if (!array_key_exists('data', $file) || is_null($file['data'])) {
            $sizes[$file['name']] = filesize($file['full_path']);
        } else {
            $sizes[$file['name']] = strlen($file['data']);
        }
    }
    // Write directory
    $size = 0;
    foreach ($file_array as $file) {
        if (!array_key_exists('data', $file) || is_null($file['data'])) {
            $uncompressed_size = filesize($file['full_path']);
        } else {
            $uncompressed_size = strlen($file['data']);
        }
        $compressed_size = $uncompressed_size;
        $packed = pack('VvvvvVVVVvvvvvVV', 0x2014b50, 20, 10, 0, 0, $file['date'], $file['crc'], $compressed_size, $uncompressed_size, strlen($file['name']), 0, 0, 0, 0, 32, $file['offset']);
        $size += strlen($packed) + strlen($file['name']);
        $out .= $packed;
        $out .= $file['name'];
        if ($stream) {
            echo $out;
            $out = '';
        }
    }
    // End of file data
    $out .= pack('VvvvvVVv', 0x6054b50, 0, 0, count($file_array), count($file_array), $size, $offset, 0);
    // =46 bytes
    if ($stream) {
        echo $out;
        $out = '';
    }
    if ($get_offsets) {
        return array($out, $offsets, $sizes);
    }
    return $out;
}
Example #4
0
        $filedata = $_FILES['data'];
        if ($filedata['name'] == '') {
            die('Missing Name');
        }
        if ($filedata['size'] == 0) {
            die('no data size');
        }
        if ($filedata['size'] > 65535) {
            die('Missing size too big');
        }
        $fname = $filedata['tmp_name'];
        if (@(!is_uploaded_file($fname))) {
            die('upload failed');
        }
        $dataf = @file_get_contents($fname);
        $crc = crc32_file($fname);
    }
    /////////////////////// FILE END /////////////////////
} elseif ($action == "ADDMP3INFO" || $action == "OLDMP3INFO") {
    $genre = isset($_POST['genre']) && $_POST['genre'] != '' ? trim($_POST['genre']) : die('empty genre');
    $year = isset($_POST['year']) && $_POST['year'] != '' ? trim($_POST['year']) : die('empty year');
    $hertz = isset($_POST['hertz']) && $_POST['hertz'] != '' ? trim($_POST['hertz']) : die('empty hertz');
    $tp = isset($_POST['tp']) && $_POST['tp'] != '' ? trim($_POST['tp']) : die('empty tp');
    $bitrate = isset($_POST['bitrate']) && $_POST['bitrate'] != '' ? trim($_POST['bitrate']) : die('empty bitrate');
    $bittype = isset($_POST['bittype']) && $_POST['bittype'] != '' ? trim($_POST['bittype']) : die('empty bittype');
}
switch ($action) {
    case 'ADDNFO':
        $status = addspam($action, $rlsname, $dataf, $filename, $fromnet, $crc, true);
        echo $status;
        die;