Wordpress 2.6 RC1
Just to say that my rss-pages plugin works with the latest wordpress 2.6 rc1 release, so there’s no need to patch… All being well it looks like wordpress 2.6 will released next week
Just to say that my rss-pages plugin works with the latest wordpress 2.6 rc1 release, so there’s no need to patch… All being well it looks like wordpress 2.6 will released next week
So I have been trying to capitalise a word after a full stop and as this had me baffled for a good 30 minutes or so, so I though I would post it up in case anyone else is looking for it.
$content = preg_replace("/\. ([a-z])/e”, “‘. ‘.ucfirst(’\\1′)”, $content);
[update] Bleh at the auto formatting by Wordpress…. Check the Paste Dump for a nice copy and paste version http://www.pastedump.com/paste/54
So I had a situation whereby I needed to enter a few thousand captcha’s for various reasons… having never broke a captcha before I checked Harry’s and Slightly’s blogs to see how to do it. The captcha I needed to break in comparison to what their both up to is pretty damn lame (e.g. no letter rotation and separation needed), but combined with their sites and chatting to a couple of friends gave me a few ideas to get started, namely:
So step one was to start up gimp and see how I could clean up the image… seems doing the invert and thresholding removed all the surrounding crap and left me with just the text, with no need to clean up whatever is left, lucky me / crap captcha… So next to automate it with ImageMagick
convert -negate -threshold 20% -negate -despeckle -monochrome captcha.jpg captcha.tif
First we invert the colours using negate, apply a 20% back and white threshold and use negate to swap the colours back. I also chose to despeckle the picture to remove the odd speckle of black if it occurred and finally changed it to a monochrome tiff for use with the Tesseract OCR software.
After a bit of trail and error I realized that the DPI of the captcha was probably too low for Tesseract, so I simply doubled the size of the captcha using -resize when converting the image.
convert -resize 150x70 -negate -threshold 20% -negate -despeckle -monochrome captcha.jpg captcha.tif
Running Tesseract via following command happily gave the correct captcha 80/90% of the time… certainly good enough for what I needed.
tesseract captcha.tif captcha -l eng && echo captcha.txt
So next to wrap that up in php
get_image("http://www.path.to/captcha.jpg", "proxyip:port", "referer"); //curl wrapper
exec("convert -resize 150x70 -negate -threshold 50% -negate captcha.jpg captcha.tif && \\
tesseract testFile2.tif captcha -l eng 2>/dev/null && cat captcha.tx",$output);
$captcha = ereg_replace("[^A-Za-z0-9]“, “”, $output[0]); //keep alphanumberical values
$captcha = trim($captcha);
Done, one simple captcha cracked! I would put up an example of the captcha but it has the site’s name in the background, and I want to use this for a bit
Simple script for rotating your php logs using logrotate
/etc/logrotate.d/php
/var/log/php {
missingok
compress
weekly
rotate 5
delaycompress
}
While working on the RSS Pages Plugin for Wordpress I came across a bit of a bug, whereby I could not replace the current feeds with others. The problem is due to the way add_feed works.
Looking at the code
function add_feed($feedname, $function) {
global $wp_rewrite;
if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
$wp_rewrite->feeds[] = $feedname;
}
$hook = ‘do_feed_’ . $feedname;
remove_action($hook, $function, 10, 1);
add_action($hook, $function, 10, 1);
return $hook;
}
I figured that remove_action was failing due to the function being passed being the incorrect, after a bit of discussion with Ryan on we settled on changing the remove_action line to
remove_action($hook, $hook, 10, 1);
Hopefully the fix will be in 2.6…. The ticket can be found and tracked here
One problem with Wordpress is that the RSS feed only contains the latest posts and not pages. I suppose the idea is to have a feed which the blogosphere can use to know when there is updated news on your site… That’s ok for most Wordpress sites but when you are using as Wordpress as a CMS and thus using pages and not posts you can’t by default put the pages into a feed.
Thus I bring you the Wordpress RSS Pages Plugin
How it works
Simply install the plugin by copying it to your plugins directory (wp-content/plugins/rss-pages/rss-pages.php). Activate it on the plugins page and your posts RSS feeds will be replaced with page RSS feeds. (Note if you are using Wordpress < 2.6 you will need this patch)
Download available from http://wordpress.org/extend/plugins/rss-pages/
Let me know if you have any problems
Scuttle has a few XSS problems according to a few posts around the net… namely
http://site/bookmarks/%3CBODY%20onload=alert(document.cookie)%3E
http://site/?sort=%22%3E%3Cscript%3Ealert(document.cookie)%3C/script%3E
Fixes can be found here http://www.pastedump.com/paste/14
http://www.pastedump.com/ is live! (as you might of guessed from my last post).
I needed a site to dump programming snippets so I knocked together pastedump.com - A public paste bin. It has a few features other paste dumps / paste bins don’t have such as encrypted posting via a blowfish javascript implementation as well as options for sorting and stripping word lists, converting to ascii or base64, rot13 and reversing text, aswell as a few options for hashing text with sha1 / sha1-hmac / md5 / md5-hmac.
It still has a few bugs to iron out such as with long strings and text being cut off due to overflow: hidden to stop the layout going to crazy but as quirksmode explains there is no simple solution… will try the wbr hack at some point to see if that fixes it for a few more people.
Hope you find the site useful and yes, syntax highlighting is on the todo list.
Needed to show some pages as icon in the sidebar of a wordpress blog so I knocked together the following function (damn wordpress stripping content) http://www.pastedump.com/paste/12 and dropped it in the themes functions.php.
Note that I used wp-content/uploads/icons to store the images and use the page-id.jpg as the filename.
After wrestling with FPDF, terminal settings and vim’s character sets, together with the uk pound sign (£) - I finally settled on the following
$this->Cell( 17,4, chr(0x00A3).sprintf( "%0.2f", $totalvalue), '', '', 'R');
The chr(0×00A3) produces the pound sign required
Hope that helps any one using FPDF and needs a uk pound