Guest User

Untitled

a guest
Aug 10th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1.    function showImage($contents, $export="png")  {
  2.       global $CFG_GLPI;
  3.       if ($export!="odt" && $export!="odtall") {
  4.  
  5.          $show_inline = true;
  6.        
  7.          //test browser (if ie < 9, show img from temp dir instead base64 inline)
  8.          $ua = trim(strtolower($_SERVER["HTTP_USER_AGENT"]));
  9.          $pattern = "/msie\s(\d+)\.0/";
  10.          if(preg_match($pattern,$ua,$arr)){
  11.             $ie_version = $arr[0];
  12.             if (version_compare($ie_version, '9.0') < 0) {
  13.                $show_inline = false;
  14.                $rand=mt_rand();
  15.                $filename_tmp = GLPI_ROOT."/files/_tmp/mreporting_img_$rand.png";
  16.                file_put_contents($filename_tmp, $contents);
  17.  
  18.                echo "<img src='$filename_tmp' alt='graph' title='graph' />";
  19.             }
  20.          }
  21.            
  22.          if ($show_inline)
  23.             echo "<img src='data:image/png;base64,".base64_encode($contents)
  24.                ."' alt='graph' title='graph' />";
  25.          
  26.       }
  27.    }
Add Comment
Please, Sign In to add comment