{"id":14,"date":"2005-08-10T13:52:26","date_gmt":"2005-08-10T17:52:26","guid":{"rendered":"http:\/\/blog.chase.net.au\/?p=14"},"modified":"2005-08-10T13:54:20","modified_gmt":"2005-08-10T17:54:20","slug":"creating-dynamic-sigs-for-phpbb","status":"publish","type":"post","link":"http:\/\/blog.chase.net.au\/index.php\/2005\/08\/creating-dynamic-sigs-for-phpbb\/","title":{"rendered":"Creating dynamic sigs for phpbb"},"content":{"rendered":"<p>Creating dynamic sigs for phpbb is rather difficult, mainly due to the fun &ldquo;security&rdquo; features in phpbb.&nbsp; First of all, for obvious reasons, it doesn&rsquo;t let you include server side scripting within your sig text.&nbsp; That rules out most efforts to create dynamic text, which leaves you with the&nbsp;use of a dynami image.&nbsp; The problem with that is that phpbb&nbsp;is all nazi&nbsp;when parsing [img] tags and&nbsp;prevents you from using anything for an image other than something ending in .gif, .jpg or .png.&nbsp; Well, there&rsquo;s an easy solution &ndash; create a directory on your web server called &ldquo;sig.png&rdquo; and mess with the index.php file for that directory.&nbsp; Phpbb (how do you capitalize that at the start of a sentence?) accepts it because it thinks it is looking at an image (the URL ends in .png) but in reality it&rsquo;s hitting the index.php script for the directory.&nbsp; Fun times!<\/p>\n<p>In my case, for a first pass I just wanted the latest blog title to show up in the image I created, so the script ended up looking like this:<\/p>\n<blockquote dir=\"ltr\" style=\"MARGIN-RIGHT: 0px\">\n<p>&lt;?php<\/p>\n<p>\/\/ Spit out headers<br \/>header(&#8220;Content-type: image\/png&#8221;);<br \/>header(&#8220;Expires: &#8220;.gmdate(&#8220;D, d M Y H:i:s&#8221;, (time()+900)) . &#8221; GMT&#8221;); <\/p>\n<p>\/\/ Config Files<br \/>include (&#8220;..\/blog\/wp-config.php&#8221;);<\/p>\n<p>\/\/ Blog entry<br \/>$posts_list = wp_get_recent_posts(1);<br \/>foreach ($posts_list as $entry) {<br \/>&nbsp;&nbsp; <br \/>&nbsp;$choice = $entry[&#8216;post_title&#8217;];<br \/>}<\/p>\n<p>$choice = &#8220;Latest blog post: &#8221; . $choice;<\/p>\n<p>\/\/ Load a random quote<br \/>$font_name = &#8220;arial.ttf&#8221;;<br \/>$font_size = 9;<\/p>\n<p>\/\/ Image Settings<br \/>$x_size = 400;<br \/>$y_size = 18;<\/p>\n<p>\/\/ Calculate starting point of text (horizontal)<br \/>$line_width = imagettfbbox($font_size, 0, $font_name, $choice);<br \/>$x_start = 5;<br \/>$y_start = 13;<br \/>$max_width = $line_width[2];<\/p>\n<p>\/\/ Create the image resource &amp; assign colours.<br \/>$im = imagecreatetruecolor($x_size, $y_size);<br \/>$back = imagecolorallocate($im, 220, 220, 255);<br \/>imagefilledrectangle($im, 0, 0, $x_size-1, $y_size-1, $back);<br \/>$border = imagecolorallocate($im, 128, 128, 128);<br \/>imagerectangle($im, 0, 0, $x_size-1, $y_size-1, $border);<\/p>\n<p>\/\/ Write the text on to the image.<br \/>$textcolor = imagecolorallocate($im, 0, 0, 0);<br \/>imagettftext($im, $font_size, 0, $x_start, $y_start, $textcolor, $font_name, $choice);<\/p>\n<p>\/\/ Create and then destroy the image<br \/>imagepng($im);<br \/>@ImagePNG($im,$cache_filename) ;<br \/>imagedestroy($im);<\/p>\n<p>?&gt;<\/p>\n<\/blockquote>\n<p dir=\"ltr\">Will, it works.&nbsp; I guess I&rsquo;ll be putting some more stuff in there sometime in the future, but without the ability to create image maps, it&rsquo;s probably going to be rather entertaining getting anything too useful in the script.&nbsp; I guess my next avenue for playing is to see what web browsers do when the Content-Type header doesn&rsquo;t match the apparent file extension.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating dynamic sigs for phpbb is rather difficult, mainly due to the fun &ldquo;security&rdquo; features in phpbb.&nbsp; First of all, for obvious reasons, it doesn&rsquo;t let you include server side scripting within your sig text.&nbsp; That rules out most efforts to create dynamic text, which leaves you with the&nbsp;use of a dynami image.&nbsp; The problem [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":0,"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/posts\/14\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/media?parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/categories?post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.chase.net.au\/index.php\/wp-json\/wp\/v2\/tags?post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}