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

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 loadNotPicture(){
  67. global $SYSPath;
  68. header("Content-Type: image/jpeg");
  69. $Data = file_get_contents( $SYSPath . '/style/assets/no_picture.jpg' );
  70. echo $Data;
  71. };
  72. function makeStorageBasePath( $MD ){
  73. global $SYSPath;
  74. $FL = substr( $MD, 0, 2 );
  75. $SL = substr( $MD, 2, 2 );
  76. $TL = substr( $MD, 4, 2 );
  77. if( !is_dir( $SYSPath.'/storage/'.$FL ) ){
  78. mkdir( $SYSPath.'/storage/'.$FL );
  79. };
  80. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL ) ){
  81. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL );
  82. };
  83. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ) ){
  84. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL );
  85. };
  86. return $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL;
  87. };
  88. function loadPicture( $Data ){
  89. if( is_array( $Data ) ){
  90. if( isset( $Data['md5'] ) && isset( $Data['ext'] ) ){
  91. $fname = makeStorageBasePath( $Data['md5'] ).'/'.$Data['md5'].'.'.$Data['ext'];
  92. switch( $Data['ext'] ){
  93. case 'jpe':
  94. case 'jpg':
  95. case 'jpeg':
  96. header("Content-Type: image/jpeg");
  97. break;
  98. case 'gif':
  99. header("Content-Type: image/gif");
  100. break;
  101. case 'png':
  102. header("Content-Type: image/png");
  103. break;
  104. default:
  105. header("Content-Type: image/image");
  106. break;
  107. };
  108. $D = file_get_contents( $fname );
  109. echo $D;
  110. return;
  111. };
  112. };
  113. loadNotPicture();
  114. };
  115. function registerPicture( $fname ){
  116. global $DATABASE;
  117. if( file_exists( $fname ) ){
  118. $MD5 = md5_file( $fname );
  119. $REXT = substr(strtolower( pathinfo( $fname, PATHINFO_EXTENSION ) ), 3 );
  120. $nfname = makeStorageBasePath( $MD5 ).'/'.$MD5.'.'.$REXT;
  121. if( rename( $fname, $nfname ) ){
  122. $QS = "INSERT INTO pictures SET md5='{$MD5}', ext='{$REXT}', TS=NOW()";
  123. $DATABASE->Query( $QS, false );
  124. return $DATABASE->getLastInsertID();
  125. };
  126. };
  127. return 0;
  128. };
  129. ?>