| <?php |
| require_once dirname(__FILE__).'/_settings.php'; |
| |
| |
| $web = $_SERVER[ 'HTTP_HOST']; |
| |
| $request = preg_replace( '~/forum-sig/([^\.]+?)\..+?$~', '$1', $_SERVER[ 'REQUEST_URI' ] ); |
| |
| if( !empty( $urls[$web][ $request ] ) ) |
| { |
| $settings = $urls[$web][ $request ]; |
| } |
| else |
| { |
| exit(); |
| } |
| |
| $search = array( '&' ); |
| $replace = array( '&' ); |
| |
| |
| |
| $file = dirname(__FILE__).'/cached/'.$request.'.png'; |
| |
| if( !is_file( $file ) || ( time() - filemtime( $file ) ) > ( $settings['cache'] * 60 ) ) |
| { |
| $ch = curl_init(); |
| |
| curl_setopt($ch, CURLOPT_URL, $settings['feed'].'?tempskin=_rss2' ); |
| curl_setopt($ch, CURLOPT_HEADER, 0); |
| curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; |
| $res = curl_exec($ch); |
| curl_close($ch); |
| |
| preg_match( '~<item>.+?<title>(.+?)</title>.+?<pubDate>(.+?)</pubDate>.+?<category[^>]+?>(.+?)</category>.+?</item>~s', $res, $matches ); |
| |
| $title = str_replace( $search, $replace, $matches[1] ); |
| $tagline = str_replace( $search, $replace, preg_replace( '~.+?,\s(.+?)\s[0-9]{4}\s.+?$~', '$1', $matches[2] ).' - '.$matches[3] ); |
| if( !$settings['background']['image'] || !isfile( dirname(__FILE__).'/'.$settings['background']['image'] ) ) |
| { |
| $image = imagecreatetruecolor( $settings['background']['width'], $settings['background']['height'] ); |
| $colour = hex2rgb( $settings['background']['color'] ); |
| $background = ImageColorAllocate( $image, $colour['red'], $colour['green'], $colour['blue'] ) ; |
| $colour = hex2rgb( $settings['background']['border'] ); |
| $border = ImageColorAllocate( $image, $colour['red'], $colour['green'], $colour['blue'] ) ; |
| imagefill( $image, 0, 0, $background ); |
| imagerectangle( $image, 0, 0, $settings['background']['width'] - 1, $settings['background']['height'] - 1, $border ); |
| } |
| $colour = hex2rgb( $settings['title']['color'] ); |
| $title_color = ImageColorAllocate( $image, $colour['red'], $colour['green'], $colour['blue'] ) ; |
| $colour = hex2rgb( $settings['tagline']['color'] ); |
| $tagline_color = ImageColorAllocate( $image, $colour['red'], $colour['green'], $colour['blue'] ) ; |
| |
| |
| imagettftext( $image,$settings['title']['size'], 0, 8, intval( $settings['background']['height'] / 2 ) - 5, $title_color, 'fonts/'.$settings['title']['font'], $title ) ; |
| imagettftext( $image,$settings['tagline']['size'], 0, 24, $settings['background']['height'] - 6, $tagline_color, 'fonts/'.$settings['tagline']['font'], $tagline ) ; |
| |
| header('Content-type: image/png') ; |
| imagepng( $image, $file ); |
| imagepng( $image ); |
| |
| imagedestroy( $image ) ; |
| } |
| else |
| { |
| header('Content-type: image/png') ; |
| echo implode( '', file( $file ) ); |
| } |
| exit() ; |
| |
| function hex2rgb( $hex_colour = '' ) |
| { |
| $hex_colour = preg_replace( '~^#~', '', $hex_colour ); |
| if( strlen( $hex_colour ) == 6 ) |
| { |
| $cut = 2; |
| } |
| else |
| { |
| $cut = 1; |
| } |
| $rgb = array(); |
| $rgb['red'] = hexdec( substr( substr( $hex_colour, 0, $cut ).substr( $hex_colour, 0, $cut ), 0, 2 ) ); |
| $rgb['green'] = hexdec( substr( substr( $hex_colour, $cut, $cut ).substr( $hex_colour, $cut, $cut ), 0, 2 ) ); |
| $rgb['blue'] = hexdec( substr( substr( $hex_colour, $cut * 2, $cut ).substr( $hex_colour, $cut * 2, $cut ), 0, 2 ) ); |
| return $rgb; |
| } |
| ?> |
Posts : 420
Joined : 04/04/05