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.

103 lines
2.6 KiB

6 years ago
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. function getIfIp($IF){
  3. return $RVal;
  4. };
  5. function generate2DMapImage( $datafile, $a ){
  6. $image = @imagecreate( 150, 150 ) or die("Cannot Initialize new GD image stream");
  7. };
  8. function generate3DMapImage( $datafile, $byMin = true, $imagefile='' ){
  9. $thumbnail = imagecreatetruecolor( 2304, 288);
  10. if(!$thumbnail) {
  11. die('Error when creating the destination image.');
  12. };
  13. $handle = fopen($datafile, "rb");
  14. $cx = 0;
  15. $cy = 288;
  16. $cc = 0.0;
  17. $k = 1.0/409.60;
  18. while( !feof( $handle ) ){
  19. $data = fread( $handle, 4*2304 );
  20. $stride = unpack ( "V*", $data );//, int $offset = 0 );
  21. if( count($stride) == 2304 ){
  22. for( $index = 0; $index< 2304; $index++ ){
  23. $c = $stride[$index+1] >> 24;
  24. if( $c ){
  25. if( $byMin ){
  26. $l = ( $stride[$index+1] & 0xFFF);
  27. } else {
  28. $l = ( ( $stride[$index+1] >> 12 ) & 0xFFF);
  29. };
  30. if( $l < 4000 ){
  31. $z = $k * $l;
  32. $s = 1.0 - log10( $z );
  33. $R = (int)(255 * $s);
  34. $G = (int)(255 * $s);
  35. $B = (int)(255 * $s);
  36. } else {
  37. $R = 0;
  38. $G = 0;
  39. $B = 0;
  40. };
  41. } else {
  42. $R = 255;
  43. $G = 0;
  44. $B = 0;
  45. };
  46. $C = imagecolorclosest ( $thumbnail, $R, $G, $B);
  47. imagesetpixel ( $thumbnail, $index, $cy , $C );
  48. };
  49. $cy--;
  50. };
  51. };
  52. fclose( $handle );
  53. //header("Content-Type: image/png");
  54. ob_start();
  55. imagepng( $thumbnail );
  56. $contents = ob_get_contents();
  57. ob_end_clean();
  58. imagedestroy( $thumbnail );
  59. if( $imagefile != '' ){
  60. $handle = fopen( $imagefile, "wb" );
  61. fprintf( $handle, $contents );
  62. fclose( $handle );
  63. };
  64. return $contents;
  65. };
  66. function makeStorageBasePath( $MD ){
  67. global $SYSPath;
  68. $FL = substr( $MD, 0, 2 );
  69. $SL = substr( $MD, 2, 2 );
  70. $TL = substr( $MD, 4, 2 );
  71. if( !is_dir( $SYSPath.'/storage/'.$FL ) ){
  72. mkdir( $SYSPath.'/storage/'.$FL );
  73. };
  74. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL ) ){
  75. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL );
  76. };
  77. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ) ){
  78. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL );
  79. };
  80. return $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL;
  81. };
  82. function registerPicture( $fname ){
  83. global $DATABASE;
  84. if( file_exists( $fname ) ){
  85. $MD5 = md5_file( $fname );
  86. $REXT = substr(strtolower( pathinfo( $fname, PATHINFO_EXTENSION ) ), 3 );
  87. $nfname = makeStorageBasePath( $MD5 ).'/'.$MD5.'.'.$REXT;
  88. if( rename( $fname, $nfname ) ){
  89. $QS = "INSERT INTO pictures SET md5='{$MD5}', ext='{$REXT}', TS=NOW()";
  90. $DATABASE->Query( $QS, false );
  91. return $DATABASE->getLastInsertID();
  92. };
  93. };
  94. return 0;
  95. };
  96. ?>