Пример #1
0
function EchoData($res, $numfields, $numrows)
{
	for( $i = 0; $i < $numrows; $i++ ) {
		$str = "";
		$row = mysql_fetch_row( $res );
		for( $j = 0; $j < $numfields; $j++ ){
			if( is_null($row[$j]) )
				$str .= "\xFF";
			else
				$str .= GetBlock($row[$j]);
		}
		echo $str;
	}
}
Пример #2
0
<?php

/* ************** Actions ************** */
$action = $_GET['action'];
if ($action == 'filesize') {
    $file = base64_decode($_GET['file']);
    echo RealFileSize($file);
}
if ($action == 'getblock') {
    $file = base64_decode($_GET['file']);
    $block = $_GET['block'];
    $blocksize = $_GET['blocksize'];
    echo GetBlock($file, $block, $blocksize);
}
return;
/* *********** Actions-End  ************ */
function GetBlock($file, $block, $blocksize)
{
    if (!(file_exists($file) && is_numeric($block) && $block > 0 && is_numeric($blocksize) && $blocksize > 0)) {
        return 'invalid arguments';
    }
    $handle = fopen($file, 'r');
    if ($handle == null) {
        return 'cant read block';
    }
    $size = RealFilesize($file);
    $offset = ($block - 1) * $blocksize;
    if (fseek($handle, $offset, SEEK_SET) < 0) {
        fclose($handle);
        return 'cant read block';
    }