<?php
function GetLongBinary($num)
{
return pack("N",$num);
}
return pack("N",$num);
function GetShortBinary($num)
{
return pack("n",$num);
}
function GetDummy($count)
{
$str = "";
for($i=0;$i<$count;$i++)
$str .= "\x00";
return $str;
}
function GetBlock($val)
{
$len = strlen($val);
if( $len < 254 )
return chr($len).$val;
else
return "\xFE".GetLongBinary($len).$val;
}
function EchoHeader($errno)
{
$str = GetLongBinary(1111);
$str .= GetShortBinary(202);
$str .= GetLongBinary($errno);
$str .= GetDummy(6);
echo $str;
}
function EchoConnInfo()
{
$version = sqlite_libversion();
$str = GetBlock($version);
echo $version ;
$str .= GetBlock($version);
echo $str;
$str .= GetBlock($version);
echo $str;
}
function EchoConnInfo3()
{
$version = SQLite3::version();
$str = GetBlock($version["versionString"]);
$str .= GetBlock($version["versionString"]);
$str .= GetBlock($version["versionString"]);
echo $str;
}
function EchoResultSetHeader($errno, $affectrows, $insertid, $numfields, $numrows)
{
$str = GetLongBinary($errno);
$str .= GetLongBinary($affectrows);
$str .= GetLongBinary($insertid);
$str .= GetLongBinary($numfields);
$str .= GetLongBinary($numrows);
$str .= GetDummy(12);
echo $str;
}
function EchoFieldsHeader($res, $numfields)
{
$str = "";
for ( $i = 0; $i < $numfields; $i++ ) {
$str .= GetBlock(sqlite_field_name($res, $i));
$str .= GetBlock("");
$type = -2;
$length = 0;
$flag = 0;
$str .= GetLongBinary($type);
$str .= GetLongBinary($flag);
$str .= GetLongBinary($length);
}
echo $str;
}
header("Content-Type: text/html");
?>