Archive for category PHP

Amazon Associates Wordpress Plugin v0.2

I’ve just updated my amazon associates plugin to take into account the recent signiture changes which amazon have introduced for their webservices api.

This now also means you’ll have to enter your amazon secret access key in the plugin configuration page.

You can download the updated version over here.

It also means my wishlist has finally been brought back to life. Just in time for Christmas…

Tags: , , , ,

No Comments

Amazon Associates Wordpress Wishlist Plugin

One of the things that’s bugged me for a while whilst having a website is that at certain times of the year when people might actually like to buy me a gift they’re unable to find my wishlist. This is mainly because they’re simple folk who might not think to check amazon for my name. I’m also signed up with amazon associates, so I decided it could do me well to post my wishlist items along with my referral tag in the links in order to earn a bob or two on my own homepage. All this data is available on the web already its just a case of putting it together.

Some keen readers might of noticed the wishlist page I stuck up recently and want something similar on their own site and (like myself) either can’t be bothered or didn’t have the time to create a plugin to pull this data together. I’m putting up here my own quick and dirty plugin I built a few weeks ago to achieve this.

It uses amazon web services to look up a wishlist, stick in a specified associates id in each of my item links and replace where I put the text (without spaces) in a post with my wishlist items. The plugin regularly updates this (hourly) as a scheduled event in wordpress in case someone decides to actually buy me something. Of course you’ll need a services key to use it, which you can easily get by signing up with amazon at aws.amazon.com. Fill out your services id, your wishlist id (found by logging into amazon and heading to your wishlist page) and your locale (the bit after amazon. so mine is .co.uk) and press the fetch items to pull all the items in. If you don’t have an associates id, feel free to leave as my own : )

I used curl to get the remote data from amazon as the file_get_content methods generally aren’t enabled on normal web hosts. If you’d like the items to be fetched less regularly, then install the plugin with and updated wp_schedule_event method in the main wishlist.php to a value of your choice.

You can download it over here.

Double alliteration in a post title? Not sure I’ve attempted that before.

[Edit: You'll need to be running on PHP5 to make use of this plugin]
[Edit: I released an updated version based on Amazon's move to use of signitures, see the details here]

Tags: , , , ,

24 Comments

Book Review: Code Igniter for Rapid PHP Application Development

Code Igniter for Rapid PHP Application DevelopmentIn this book, author David Upton walks you through use of the Code Igniter framework, which is essentially PHP’s answer to Ruby on Rails. I’ve been a avid user of Code Igniter since I discovered it last year, which is a nice waypoint for anyone trying to understand model-view-controller architectures and not wanting to make the move over to ROR quite yet.

The angle of this book is taken from a first time CI developer, but one with some knowledge of both PHP and web development in general. The initial chapters begin by exploring why you’d choose to use CI and some of its benefits over straight PHP code (such as saving on code reproduction or easing development burdens), though doesn’t really offer any real comparison of features of other similar frameworks. A traditional chapter on setup of CI is also included, (though I think at 4 pages could have perhaps been merged with another!).

The book then proceeds by tackling the subject at the core of CI, ‘model-view-controller’ and how this relates to traditional methods of programming. David breaks down how CI is structured very well and gives suggestions of how applications built within it should be designed to be successful. Some of the example code savings at this stage are somewhat minimal over a standard approach, but I think David conveys how these rack up throughout a web app. Useful chapters of how active record and CRUD can be used to ease DB interaction and also how views can be organised to avoid repitition complete with examples should allow any new CI developer to get to grips with it very quickly.

The later chapters quite extensively cover more “geeky” complicated subjects (using objects and namespaces, localisation, getting CI to interact with other services) which might be a bit much for a hobbyist user, but it gives some room for learning for others. The book also includes some good descriptions of how to make the most of the testing and profiling features which CI has out of the box to debug some of the larger web applications that you might undertake (Both features which I’ve previously been unaware of).

The use of friendly language is a welcome change from other texts, but I think in places it does get in the way a bit of the particular functionality which is being talked about. The constant reenforcement of the MVC throughout will be welcome for new converts, but my own practical experience suggests this might be better bent in places. A number of the descriptions of features provided in the book are at the CI site, and I think what might have helped this book is if a single larger running example led the way to describing each of the features.

At the moment, this is the only CI book available and it does well at covering the large featureset CI has. For a seasoned CI veteran it won’t bring any revelations, but if you’re new the framework it will serve you extremely well at getting your head round what makes it shine.

[Disclosure: This book was given freely by PackPub for review within the Cardiff Geeks group.]

Tags: , ,

4 Comments

Decrypting Filezilla Passwords with PHP

One of the most frustrating things I find in managing a number of websites is that I’m always forgetting passwords. The version of Filezilla I’m running however makes it easy to remember them again through its use of weak XOR encryption and a the key being hard coded into the software. I’ve used a program previously called the Filezilla Password Recover, but it turns out that this is also extremely easy to extract them using a simple PHP script. The following code makes use of the nice XML parsing in PHP5 and a decryption function I found over here. I’ve added some comments to roughly describe what is going on.

Note: Apparently this encryption has been dropped from version 3 with absolutely no encryption featured at all, that’ll make my job easier now.


<?php
$filezilla_password_file 
"FileZilla.xml";
    
$xml file_get_contents($filezilla_password_file);
    
$simple_xml simplexml_load_string($xml);

foreach($simple_xml->Sites->Site as $site)
{
    
$attributes =  $site->attributes();

    print "Site: ".$attributes->Name."\n";
    print 
"User: ".$attributes->User."\n";
    print 
"Encrypted Pass: ".$attributes->Pass."\n";
    print 
"Unencrypted Pass:".decryptPass((string)$attributes->Pass)."\n\n";
}
    
function 
decryptPass($pass
{
        
// Encryption Key for FileZilla 2 Passwords
    
$key "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        
    
// Find the offset position in the key for this pass
    
$pos=(strlen($pass)/3) % strlen($key);
    
$decrypt '';

    $t=0;
        
    
//Loop through each 3rd of the password
    
for($i=0;$i strlen($pass) / 3;$i++) {
            
        
//Get 3 characters, remove the 0 at the 
    //front to get ASCII code to represent the character 
    
$num substr($pass,$i 3,3);

    if (substr($num,0,1) == 0) {
        
$num substr($num,1,2);
    }
            
    
//Get the ascii code of the unencrypted character
    //by performing XOR against current ASCII and key
    //before converting back and adding to decrypted pass
        
$t $num ord($key[($i $pos) % strlen($pass)]);
         
$decrypt .= chr($t);
            
    }
        
    
// Return the decrypted pass
       
return $decrypt;
}

?>


Tags: , ,

13 Comments

UK Jobs in Web 2.0

If anyone else like me is considering working in the uk “web 2.0″ market, and finds the posts on common job boards clogged up with all the jobs from america, the small job board I have created and posted online might be a help. You’ll find it over at: http://webtyrant.com/jobs. It aggregates some common job boards together like 37Signals and ThinkVitamin, but removes anything but those located in the UK.

No Comments

pMachine changes its name

pMachine has changed its name to Ellislab, and are sporting a shiny new website for all to see. The reason for the change is the expansion over the last 6 years to encompass products which don’t fall under the same banner now. I’m glad to see that the CodeIgniter website has got a facelift. 31three did the hard graft on the design and they all look awesome.

No Comments