Lightweight jQuery Accordion

There are many, many jQuery accordions floating around on the internet – Many of them are too complicated for a simple task, options, styles and different effects. I was recently challenged to make a very simple jQuery accordion with the least amount of code needed. I have uploaded an example of this Just Here

Continue reading

Posted in Javascript | Tagged , | 1 Comment

PHP – Get page links (using the DOMDocument)

PHP has a very useful library – The DOM Document. Using this you’ll be able to get the source code of a page and go through each element of the HTML filtering out what you need and don’t need, If you’re using this for scraping websites for information the DOMDocument library is invaluable.

Below I will be showing you how to get the source code of an external website and return an array of links.

Continue reading

Posted in PHP | Tagged , | Leave a comment

PHP – Posting to Twitter (using OAuth)

Twitter has now moved over to OAuth (no longer supporting Basic Auth) – You’re now forced to use this when wanting to post/retrieve information using a Twitter account and Twitter Application. Since searching around I haven’t found any good examples of how to post a Tweet to twitter using the Twitter REST API.

I will be using a third party library as an example and creating an wrapper class to set it up and use it, all you’ll have to do is include a file and a few lines of code to get started. Before we proceed you’ll need to download the Twitter OAuth API from GitHUB by Clicking Here which is developed by Abraham Williams.

Continue reading

Posted in PHP | Tagged , , , | 2 Comments

PHP – Simple Captcha Class

Developing your own Captcha verifications can be quite simple with PHP and the GD library. I’ve made a very basic captcha class below that should give you a head start when protecting your web pages from automated bots. Like I said, this is a very simple implementation so It isn’t perfect but It’s a start.

Continue reading

Posted in PHP | Tagged , | Leave a comment

PHP – cURL Example Class

cURL is a very powerful command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos…), file transfer resume, proxy tunneling and a busload of other useful tricks.

In this post I’ll be showing you a basic class I put together to be used with PHP – It’ll allow you to fetch the source code, info and headers of a remote website.

Continue reading

Posted in PHP | Tagged , | Leave a comment

PHP – FTP Class Example

One of the more useful extensions for PHP is the FTP modules. There are many uses for this, mainly uploading and downloading files to and from a remote server – Although could be used to backup websites, restore backups, file management, the list is endless.

I’ve prepared a basic class below that utilises the FTP functions, developing a class in this way allows us to create a simple and manageable FTP session cutting down on all un-needed and repetitive code.

Continue reading

Posted in PHP | Tagged , , | 1 Comment

PHP – Example Practical use for Similar Text

One of the more neat features of PHP is these functions; the ones that can analyse strings for you, taking away all of the hard work. While they’re neat to use, they may not always have a practical use in a project.

I was thinking of ways I could use similar_text() in a project, one of the examples I came up with is making a ‘Did you mean?’ part to navigation. The idea is, that when somebody types a wrong URL slug it’ll check the page names to see if any are close enough to match, if they are It’ll suggest that page.
Continue reading

Posted in PHP | Tagged , , | Leave a comment

PHP – Checking POST and GET Fields

This is another very basic piece of code that will probably come in handy when manually checking form fields for data and used to determine if there is actually any data in the field.

Normally you would have a block of code, normally an If or Switch statement that will check to make sure the variable isn’t empty() and that it is isset() – This function will allow you to do that in batch format, just pass in an array of required fields to check.

Continue reading

Posted in PHP | Tagged , , , | Leave a comment