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.

133 lines
3.2 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. function getIfIp($IF){
  3. return $RVal;
  4. };
  5. function generate3DMapImage( $datafile, $byMin = true, $imagefile='' ){
  6. $thumbnail = imagecreatetruecolor( 2304, 288);
  7. if(!$thumbnail) {
  8. die('Error when creating the destination image.');
  9. };
  10. $handle = fopen($datafile, "rb");
  11. $cx = 0;
  12. $cy = 288;
  13. $cc = 0.0;
  14. $k = 1.0/409.60;
  15. while( !feof( $handle ) ){
  16. $data = fread( $handle, 4*2304 );
  17. $stride = unpack ( "V*", $data );//, int $offset = 0 );
  18. if( count($stride) == 2304 ){
  19. for( $index = 0; $index< 2304; $index++ ){
  20. $c = $stride[$index+1] >> 24;
  21. if( $c ){
  22. if( $byMin ){
  23. $l = ( $stride[$index+1] & 0xFFF);
  24. } else {
  25. $l = ( ( $stride[$index+1] >> 12 ) & 0xFFF);
  26. };
  27. if( $l < 4000 ){
  28. $z = $k * $l;
  29. $s = 1.0 - log10( $z );
  30. $R = (int)(255 * $s);
  31. $G = (int)(255 * $s);
  32. $B = (int)(255 * $s);
  33. } else {
  34. $R = 0;
  35. $G = 0;
  36. $B = 0;
  37. };
  38. } else {
  39. $R = 255;
  40. $G = 0;
  41. $B = 0;
  42. };
  43. $C = imagecolorclosest ( $thumbnail, $R, $G, $B);
  44. imagesetpixel ( $thumbnail, $index, $cy , $C );
  45. };
  46. $cy--;
  47. };
  48. };
  49. fclose( $handle );
  50. //header("Content-Type: image/png");
  51. ob_start();
  52. imagepng( $thumbnail );
  53. $contents = ob_get_contents();
  54. ob_end_clean();
  55. imagedestroy( $thumbnail );
  56. if( $imagefile != '' ){
  57. $handle = fopen( $imagefile, "wb" );
  58. fprintf( $handle, $contents );
  59. fclose( $handle );
  60. };
  61. return $contents;
  62. };
  63. function loadNotPicture(){
  64. global $SYSPath;
  65. header("Content-Type: image/jpeg");
  66. $Data = file_get_contents( $SYSPath . '/style/assets/no_picture.jpg' );
  67. echo $Data;
  68. };
  69. function makeStorageBasePath( $MD ){
  70. global $SYSPath;
  71. $FL = substr( $MD, 0, 2 );
  72. $SL = substr( $MD, 2, 2 );
  73. $TL = substr( $MD, 4, 2 );
  74. if( !is_dir( $SYSPath.'/storage/'.$FL ) ){
  75. mkdir( $SYSPath.'/storage/'.$FL );
  76. };
  77. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL ) ){
  78. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL );
  79. };
  80. if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ) ){
  81. mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL );
  82. };
  83. return $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL;
  84. };
  85. function loadPicture( $Data ){
  86. if( is_array( $Data ) ){
  87. if( isset( $Data['md5'] ) && isset( $Data['ext'] ) ){
  88. $fname = makeStorageBasePath( $Data['md5'] ).'/'.$Data['md5'].'.'.$Data['ext'];
  89. switch( $Data['ext'] ){
  90. case 'jpe':
  91. case 'jpg':
  92. case 'jpeg':
  93. header("Content-Type: image/jpeg");
  94. break;
  95. case 'gif':
  96. header("Content-Type: image/gif");
  97. break;
  98. case 'png':
  99. header("Content-Type: image/png");
  100. break;
  101. default:
  102. header("Content-Type: image/image");
  103. break;
  104. };
  105. $D = file_get_contents( $fname );
  106. echo $D;
  107. return;
  108. };
  109. };
  110. loadNotPicture();
  111. };
  112. function registerPicture( $fname ){
  113. global $DATABASE;
  114. if( file_exists( $fname ) ){
  115. $MD5 = md5_file( $fname );
  116. $REXT = substr(strtolower( pathinfo( $fname, PATHINFO_EXTENSION ) ), 3 );
  117. $nfname = makeStorageBasePath( $MD5 ).'/'.$MD5.'.'.$REXT;
  118. if( rename( $fname, $nfname ) ){
  119. $QS = "INSERT INTO pictures SET md5='{$MD5}', ext='{$REXT}', TS=NOW()";
  120. $DATABASE->Query( $QS, false );
  121. return $DATABASE->getLastInsertID();
  122. };
  123. };
  124. return 0;
  125. };
  126. ?>