October 19, 2009

Convert a 2D Associative Array To CSV using PHP

Here is a bit of code to convert an array of associative arrays into a CSV file. The first line will be a header line of the key values:

function to_csv( $array ) {
 $csv;

 ## Grab the first element to build the header
 $arr = array_pop( $array );
 $temp = array();
 foreach( $arr as $key => $data ) {
   $temp[] = $key;
 }
 $csv = implode( ',', $temp ) . "\n";

 ## Add the data from the first element
 $csv .= to_csv_line( $arr );

 ## Add the data for the rest
 foreach( $array as $arr ) {   
   $csv .= to_csv_line( $arr );
 }

 return $csv;
}

function to_csv_line( $array ) {
 $temp = array();
 foreach( $array as $elt ) {
   $temp[] = '"' . addslashes( $elt ) . '"';
 }

 $string = implode( ',', $temp ) . "\n";

 return $string;
}
Permalink • Print • Comment

September 1, 2009

Backup and Restore Disk Images Over A Network

Here is a quick and easy way to save and restore hard disk images using dd, netcat and gzip.

To Save An Image:
On the server: nc -l -p 7000 | dd of=Output.img
On the client: dd if=/dev/sdb | gzip -9 | nc 12.34.56.78 7000

To Restore:
On the client: nc -l -p 7000 | gzip -dc | dd of=/dev/sda
On the server: dd if=Output.img | nc 12.34.56.78 7000

I just boot the client using an Ubuntu live-cd, all the neccessary tools are already installed. I store my images gzipped to save space, I just copied a 40 GB disk and the image file compressed down to 4.4 GB!

Permalink • Print • Comment

February 18, 2009

New LibKi Feature

I’m still making alot of updates to Libki lately, the newest feature is a ‘Clients’ view. On the Clients page of the web administration, you can see all the machines running the Libki client, and whether or not someone is logged into the client. I imagine this will be far more useful than limiting the User’s view to only logged in users.

I will be rolling this version out in production at the Linesville Public Library, most likely tomorrow.

In addition, a reservations system will be coming soon. It is in the planning stages. If anyone has any suggestions for features, don’t hesitate to let me know!

Kyle

Permalink • Print • Comment

February 11, 2009

LibKi Updates

Hey All,

I’ve been hard at work getting LibKi into a form that is more suitable for the general public to use. First, I’ve moved the code from SourceForge’s subversion repo to GitHub, at least for now.

I’ve finished porting the code from using PostgreSQL to MySQL. In addition I’ve been working on the startup scripts that disable hotkeys that could be used to bypass LibKi on Windows clients. These scripts were made with AutoHotKey, a wonderful piece of FOSS that was designed for creating Windows shortcuts, but has grown so fast it’s possible to write complete graphical programs using only an AutoHotKey script. These scripts are located in the libki/client/src/windows directory, as they only function on Windows. There are four, each one is slightly different to better suit individual needs.

  • libki-keylock – Disables alt-tab, ctrl-alt-del, and many other commands that can be used to gain unauthorised access. With this version the key combo ctrl-alt-shift-L will pop up a password dialog that can disable the script. The password is contained in the file /etc/libki/keylock
  • libki-keylock-nopwd – The same script without the password unlock feature.
  • libki-keylock-startbutton – The same as libki-keylock, but this version also disables the start button, so only shortcuts on the desktop can be used to launch programs.
  • libki-keylock-startbutton-nopwd – The same as above, but without the password unlock feature.

For each of these scripts, there is an executable, and a corrosponding .ahk file which contains the original AutoHotKey script code in case someone would wish to modify the scripts further.

That’s all for now. More updates will be coming soon.

Permalink • Print • Comment

January 31, 2009

My Koha 3 Repo at Github

Hey All,

I’ve decided to avoid the messy business of setting up my own Koha git repository ( at least for now ). Instead, I’ve set up a Github account here.  I’ve configured github to update my twitter account ( kylemhall ) each time I make a push, so if you want to track my changes you can watch that. I may even set up automatic posting to this blog. I will be continuously rebasing from git.koha.org and pushing those updates so it will be up to date with the latest changes from the official git repository.

Kyle

Permalink • Print • Comment

January 30, 2009

Know your sources…

Here’s a interesting article comparing and contasting the Koha, Evergree and Rome ILS systems. I stumbled upon it because it happens to link to my Koha VMWare Appliance page. Linky.

Permalink • Print • Comment

Offline Circ being used by NExpress!

NExpress is apparently a consortium of libraries in New England and New York the Northeast Kansas Library System’s shared catalog project. I found a page linking to the Offline Circ download. Linky.

Permalink • Print • Comment

Koha 3 Development Updates

It’s been awhile since I posted last so I thought I’d let everyone know what I’m doing development-wise involving Koha 3

We are about 5 weeks out from the point where we have to be ready to switch over from using the dev_week development version of Koha to 3 which is based on dev_week, but with many differences. To get ready, I’ve had to port a number of features from dev_week to Koha 3. These include:

  • Porting my Reserves System updates from dev_week to Koha 3
  • Porting my Rotating Collections system from dev_week to Koha 3
  • Adding the ability to pay fines by an amount paid, rather than paying individual fines one at a time.
  • Porting my ‘Fines On Return’ system where actual fines are not generated until an item is checked in. I think it’s a great system and our librarians definitely prefer it to Koha’s standard fines system.
  • Porting my Clubs & Services feature from dev_week to Koha 3. This is the largest and complex addition to Koha I have made, and I’m done with the basic feature, but I haven’t sent a patch yet because I’d like to add some more bells & whisles to it first.

Hopefully I’ll have a public Git repository up soon so anyone can pull these updates from me instead of waiting for them to make it into Koha 3 proper.

In addition, I’ve set up a new website for KUDOS, the US based Koha Users & Developers Group. It’s located at kudos.koha.org.

Kyle

Permalink • Print • Comment

September 24, 2008

Koha Offline Circulation hits 1.x

I believe the Koha Offline Circulation client has hit a milestone. Geauga County is now using the KOC program on their bookmobiles to avoid resorting to pen-and-paper. Thanks to them, KOC has a much expanded feature set, a Koha community endorsed file format, and the server-side scripts are included as part of the Koha 3.x distribution.

Go to the Koha Offline Circulation Home Page.

Permalink • Print • Comment

April 9, 2008

More LibKi Updates!

I just completed the work necessary to run the LibKi client on Windows! The instructions are here. We are already running the LibKi kiosk software on about 10 Ubuntu thin clients, with around 50 to 75 unique user’s logging in each day.

The system has worked very well, the few issues we have are connected to the fact that I have customized our particular LibKi installation to integrate with the Koha ILS. By doing this, we are able to have a single username and password for each patron, for both Koha and LibKi. Those issues have been resolved, and we have not had any problems since.

Permalink • Print • Comment
Made with WordPress and a healthy dose of Semiologic • Fire Brick skin by Denis de Bernardy