Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

138 lines
3.4 KiB

<?php
function getIfIp($IF){
return $RVal;
};
function generate2DMapImage( $datafile, $a ){
$image = @imagecreate( 150, 150 ) or die("Cannot Initialize new GD image stream");
};
function generate3DMapImage( $datafile, $byMin = true, $imagefile='' ){
$thumbnail = imagecreatetruecolor( 2304, 288);
if(!$thumbnail) {
die('Error when creating the destination image.');
};
$handle = fopen($datafile, "rb");
$cx = 0;
$cy = 288;
$cc = 0.0;
$k = 1.0/409.60;
while( !feof( $handle ) ){
$data = fread( $handle, 4*2304 );
$stride = unpack ( "V*", $data );//, int $offset = 0 );
if( count($stride) == 2304 ){
for( $index = 0; $index< 2304; $index++ ){
$c = $stride[$index+1] >> 24;
if( $c ){
if( $byMin ){
$l = ( $stride[$index+1] & 0xFFF);
} else {
$l = ( ( $stride[$index+1] >> 12 ) & 0xFFF);
};
if( $l < 4000 ){
$z = $k * $l;
$s = 1.0 - log10( $z );
$R = (int)(255 * $s);
$G = (int)(255 * $s);
$B = (int)(255 * $s);
} else {
$R = 0;
$G = 0;
$B = 0;
};
} else {
$R = 255;
$G = 0;
$B = 0;
};
$C = imagecolorclosest ( $thumbnail, $R, $G, $B);
imagesetpixel ( $thumbnail, $index, $cy , $C );
};
$cy--;
};
};
fclose( $handle );
//header("Content-Type: image/png");
ob_start();
imagepng( $thumbnail );
$contents = ob_get_contents();
ob_end_clean();
imagedestroy( $thumbnail );
if( $imagefile != '' ){
$handle = fopen( $imagefile, "wb" );
fprintf( $handle, $contents );
fclose( $handle );
};
return $contents;
};
function loadNotPicture(){
global $SYSPath;
header("Content-Type: image/jpeg");
$Data = file_get_contents( $SYSPath . '/style/assets/no_picture.jpg' );
echo $Data;
};
function makeStorageBasePath( $MD ){
global $SYSPath;
$FL = substr( $MD, 0, 2 );
$SL = substr( $MD, 2, 2 );
$TL = substr( $MD, 4, 2 );
if( !is_dir( $SYSPath.'/storage/'.$FL ) ){
mkdir( $SYSPath.'/storage/'.$FL );
};
if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL ) ){
mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL );
};
if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ) ){
mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL );
};
return $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL;
};
function loadPicture( $Data ){
if( is_array( $Data ) ){
if( isset( $Data['md5'] ) && isset( $Data['ext'] ) ){
$fname = makeStorageBasePath( $Data['md5'] ).'/'.$Data['md5'].'.'.$Data['ext'];
switch( $Data['ext'] ){
case 'jpe':
case 'jpg':
case 'jpeg':
header("Content-Type: image/jpeg");
break;
case 'gif':
header("Content-Type: image/gif");
break;
case 'png':
header("Content-Type: image/png");
break;
default:
header("Content-Type: image/image");
break;
};
$D = file_get_contents( $fname );
echo $D;
return;
};
};
loadNotPicture();
};
function registerPicture( $fname ){
global $DATABASE;
if( file_exists( $fname ) ){
$MD5 = md5_file( $fname );
$REXT = substr(strtolower( pathinfo( $fname, PATHINFO_EXTENSION ) ), 3 );
$nfname = makeStorageBasePath( $MD5 ).'/'.$MD5.'.'.$REXT;
if( rename( $fname, $nfname ) ){
$QS = "INSERT INTO pictures SET md5='{$MD5}', ext='{$REXT}', TS=NOW()";
$DATABASE->Query( $QS, false );
return $DATABASE->getLastInsertID();
};
};
return 0;
};
?>