[1] | 1 | <?php |
---|
[741] | 2 | $xoopsOption['nocommon'] = true ; |
---|
| 3 | require '../../mainfile.php' ; |
---|
[1] | 4 | $mydirpath = dirname(__FILE__); |
---|
[741] | 5 | $mydirname = basename(dirname(__FILE__)); |
---|
[1] | 6 | $icon_cache_limit = 3600 ; // default 3600sec == 1hour |
---|
| 7 | |
---|
| 8 | session_cache_limiter('public'); |
---|
| 9 | header("Expires: ".date('r',intval(time()/$icon_cache_limit)*$icon_cache_limit+$icon_cache_limit)); |
---|
| 10 | header("Cache-Control: public, max-age=$icon_cache_limit"); |
---|
| 11 | header("Last-Modified: ".date('r',intval(time()/$icon_cache_limit)*$icon_cache_limit)); |
---|
| 12 | header("Content-type: image/png"); |
---|
| 13 | |
---|
[741] | 14 | // file name |
---|
| 15 | if( ! empty( $_GET['file'] ) ) { |
---|
| 16 | $file_base = preg_replace( '/[^0-9a-z_]/' , '' , $_GET['file'] ) ; |
---|
| 17 | } else { |
---|
| 18 | $file_base = 'module_icon' ; |
---|
| 19 | } |
---|
[1] | 20 | |
---|
[741] | 21 | // branches by cores |
---|
| 22 | if( defined( 'ICMS_TRUST_PATH' ) ) { |
---|
| 23 | $draw_dirname = false ; |
---|
| 24 | $file_base .= '_icms' ; |
---|
| 25 | } else if( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
---|
| 26 | $draw_dirname = true ; |
---|
| 27 | $file_base .= '_xcl' ; |
---|
| 28 | $title = '('.$mydirname.')'; |
---|
| 29 | $px = ( 112 - 6 * strlen( $title ) ) ; |
---|
| 30 | $py = 14; |
---|
| 31 | $font = 3; |
---|
[1] | 32 | |
---|
[741] | 33 | } else { |
---|
| 34 | $draw_dirname = true ; |
---|
| 35 | $title = $mydirname; |
---|
| 36 | $px = ( 92 - 6 * strlen( $title ) ) / 2 ; |
---|
[742] | 37 | $py = 34; |
---|
[741] | 38 | $font = 3; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | // icon files must be PNG |
---|
| 42 | $file = $file_base . '.png' ; |
---|
| 43 | |
---|
| 44 | // custom icon |
---|
| 45 | if( file_exists( $mydirpath.'/'.$file ) ) { |
---|
| 46 | $draw_dirname = false ; |
---|
| 47 | $icon_fullpath = $mydirpath.'/module_icon.png' ; |
---|
| 48 | } else { |
---|
| 49 | $icon_fullpath = dirname(__FILE__).'/images/'.$file ; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | if( $draw_dirname && function_exists( 'imagecreatefrompng' ) && function_exists( 'imagecolorallocate' ) && function_exists( 'imagestring' ) && function_exists( 'imagepng' ) ) { |
---|
| 53 | |
---|
[1] | 54 | $im = imagecreatefrompng( $icon_fullpath ) ; |
---|
| 55 | |
---|
| 56 | $color = imagecolorallocate( $im , 0 , 0 , 0 ) ; // black |
---|
[741] | 57 | imagestring( $im , $font , $px , $py , $title , $color ) ; |
---|
[1] | 58 | imagepng( $im ) ; |
---|
| 59 | imagedestroy( $im ) ; |
---|
| 60 | |
---|
| 61 | } else { |
---|
| 62 | |
---|
| 63 | readfile( $icon_fullpath ) ; |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | ?> |
---|