Shell - Drupal 6 Module

Note!  This project is now an official Drupal project.  You may download it by going here: http://drupal.org/project/shell

shell-screenshot.jpgAre you using an inexpensive (or just plain limited) web host, and don't have access to a proper shell?  You know if only you could pull up putty, you could perform some operation in half the time it will take you in cpanel or some FTP client.  If this sounds familiar, then you should check out my latest Drupal 6 module, Shell.

Shell is a web-based Ajaxy pseudo shell which gives you most of the commands of your linux/unix server.  This will not work for Windows servers.  It works by passing whatever you type through PHP and directly to the server, then shows you the response.  If you are comfortable using putty (or any other shell) then you will feel right at home with this module.  It even gives you a tab-autocomplete like a real shell.

Meet My Friend, Mr. Curly Brace

The curly brace (also known as the curly bracket) is a fairly powerful tool in PHP.  In a nutshell, it lets you specify the name of a variable in a string.  Why is that so important?  Because what if you want to specify a member variable to an object in another variable?  Maybe an example would elucidate the problem...

Let's say you want to compare apples to oranges in a standard object...

$obj = new stdClass();
$obj->apples[] = "Granny";
$obj->apples[] = "Red";
$obj->apples[] = "Bad";

$obj->oranges[] = "Navel";
$obj->oranges[] = "Tangerine";

Now, let's say that you need to access either the apples array or the oranges array based on some other variable, $fruit

PHP Tip: Sorting Multidimensional Associative Arrays

We've all faced this problem before.  You have a multidimensional associative array, and you need to sort it by some element right in the middle.  Or even sort by several elements.  How do you do it?  Well, here's a quick tip that will keep you from having to program custom comparison routines to get usort() to work.

For example, let's say your array looks something like this:

// array structure:  $a[person name][age][pet name] = pet age

$a["mary"][35]["spot"] = 5;
$a["bob"][29]["nosy"] = 8;
$a["mary"][35]["fido"] = 12;
$a["bob"][29]["eve"] = 2;

Now let's say you want to know the order of pet names, sorted by owner's age, then pet age, then person name, then pet name.  If we go the traditional usort route, we would have to program several annoying and confusing comparison functions.  So, here's the trick:  flatten out the array!

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.

Easy Gallery - Drupal 6 Module

Attached File(s): 

Last updated: 5-26-2011, version 1.1b.

easy-gallery-screenshot-1.jpgLike the name says, this is meant to be a simple and easy photo/image gallery. It is intended for people who just want a simple solution for a photo gallery, and do not want the hassle of having to set up Views and CCK, or of installing another application (like Gallery2).  It is meant to be as easy to use as Facebook or Flickr.

A little backstory:  I wrote this partially because of a client I was building a web site for.  He had no technical expertise at all, so I wanted an image gallery which I felt was easy enough for him to set up and maintain.  I looked around the Drupal community, but never found one that met that description.  Believe me, they were all very good, very snazzy galleries! But, I never found anything that seemed easy enough for a novice to use.

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.

Daily MySQL Backup - Drupal 6 Module

Attached File(s): 

 This module allows you to create a daily MySQL backup of your entire drupal database. If you have more than one drupal installation (or any other applications) on your database, you can tell the module to only backup tables with a particular prefix (eg. "site2_"). To install, simply unpack to /sites/all/modules/daily_mysql_backup, then visit Administer->modules, and enable it. To configure it, go to Administer->Site Configuration->Daily Mysql Backup.

Automatically download your backups to your computer every night with my new program, psBackup.

Features

  • Backups are compatible with mysqldump (can be restored by any mysql client, including phpMyAdmin, sqlYog, Navicat, etc).
  • Keep backups for up to 30 days. Automatically deletes old ones after that.
  • You configure when to make a backup.
  • Backup files can be gzipped to make them as small as possible.
  • Random characters can be added to the backup filename to make it harder for hackers to guess your filenames.
  • Automatically excludes cache tables from backups.
  • You specify any additional tables to exclude.

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.

Syndicate content