PHP Classes – quick example
June 16, 2010 | Comments | Uncategorized
www.maggsweb.com
June 16, 2010 | Comments | Uncategorized
June 16, 2010 | Comments | Uncategorized
The below given listing illustrates four of the most common: listing files using ftp_nlist(); uploading files with ftp_put(); downloading files with ftp_get(); and deleting files with ftp_delete(). Note that ftp_put() and ftp_get() must be supplied with the remote and local file name, together with the transfer type (binary or ASCII).
February 5, 2010 | Comments | Javascript
Ever clicked a link only to find out that the image/download was massive and you wished you hadn’t? Wouldn’t it have been nice to have an idea of the file-size when hovering over the link?
[More]
Displaying the day-part of the date, followed by the month etc. just looks plain wrong and lazy – ’20 September 2009′. ’20th’ would look much nicer and can be achieved without too much hard work. A simple function…
[More]
This has got to be the most self-explanatory, most obvious, but coolest function ever!
[More]
I usually write my own vars out to the screen for debugging using ‘print_r($_SESSION)’,'print_r($_POST)’etc inside <pre> tags, but this is awesome! (a little too much even). It’s like phpinfo(), but for your webpage!
[More]
My image upload script. Loads of checks, not all used each time. Optional file-physical-size checks rely on ‘getimagesize’ working. Its long, but stick with it. It works.
[More]
Logging user activity is vital when there are multiple authors for a site. It also helps with debugging user activity when there is problems. You certainly don’t want to be putting this into a database, so the next best thing is a nice little text file.
I have used this to log user activity in a number of sites, as it can easily be added after development. In this example, $PAGE and $pageTitle are set in each page as they are used to determine menu selections, etc.. but these can easily be set manually.
[More]
Text too long…? Not wrapping, or pushing other elements around…? I wrote this little function to trim text to any length, adding ‘…’ at the end if trimmed. Then, it displays the full text as you hover over it. Cooool!
Can’t rely on the size of an uploaded image and don’t want to resize it?
This function takes the larger size of the width and height and applies a formula accordingly. Then gets the new value and applies the percentage, then rounds the value. It returns the new sizes in html image tag format so that you can plug this function inside an image tag.