Check broken links/rewrites with curl

I just did a change in the URL structure of a bigger site and had to check if all existing URLs are rewritten correctly to the new structure. First I extracted a list of all URLs from the CMS of the old version and wrote them to a text file, each line containing an URL. Then I changed the structure and used the following shellscript to check each URL with curl and output the result. Afterwards it’s easy to analyze the results and check for broken links.

#!/bin/sh
while read f
do
  echo $f
  echo ""
  curl -IL --silent $f
  echo "------------------"
  echo ""
done < $1

Usage:

$ ./checklinks.sh links.txt > stats.txt

Continuous Integration with phpUnderControl and Git

Continuous Integration with phpUnderControl and Git

I was looking for a decent continuous integration solution for my PHP projects for some time now, but always had the problem that most of the described solutions used SVN instead of Git as VCS system. Yesterday I found an article which describes the setup exactly as I needed it: phpUnderControl with Git on a Debian/Ubuntu system. Using the article, I managed to set up a working system quickly, which basically works as expected: CruiseControl checks the repository for modifications and starts the build process if there are any new commits. The build process includes generating API documentation (phpdocumentor), running static code analysis (php-codesniffer) and executing unit tests (phpunit). If the build succeeds, the results are published and can be accessed through a nice webinterface powered by phpUnderControl (see screenshot above which I stole from the phpUnderControl site).

However, the described setup has a few issues which bugged me:

  1. CruiseControl runs from the shellscript as root, posts all output to the console and is not automatically started at boot time.
  2. CruiseControl runs on port 8080, but I wanted to manage access to the webinterface through the apache which is already running on the box
  3. There’s no authentication – everybody can access my CI server, see the build details and start new builds through the webinterface.
read more »

FH Raumbelegung: iCal Support für Wochenübersicht

FH Raumbelegung: iCal Support für Wochenübersicht

Ab sofort gibt es in meinem Raumbelegung-Webservice die Möglichkeit, die Wochenübersicht via iCal abzurufen. Dadurch lässt sich der Service komfortabel in Kalenderapplikationen (z.B. der Thunderbird-Extension Lightning) verwenden. Verwendung: einfach an eine Wochenübersicht den Parameter format/ical anhängen oder die entsprechenden Links am Ende der Übersicht verwenden.

Um zum Beispiel immer die aktuelle Woche des Studiengangs WI07 als Kalender in meinem Thunderbird anzeigen zu können, habe ich dort folgende URL als iCal-Quelle angegeben:

http://raumbelegung.stud.ailoo.net/week/show/class/wi07-vz/format/ical

Vorschläge sind wie üblich willkommen :)

Build a FlashMessenger system in ASP.NET MVC

Build a FlashMessenger system in ASP.NET MVC

Usually, I’m using PHP for web projects, but currently I’m working on an application using ASP.NET’s MVC framework. In many frameworks (e.g. Zend Framework or CakePHP) there is some kind of messaging system (flash messages), which allows to save a message to the session and to display it on the next request. This is useful in many situations, but mostly used after saving forms. So for example you recieve a POST request to create a new record, you save the record, redirect the user to the overview page and inform him about successful creation through a flash message which you saved before doing the redirect. As I didn’t find a way how to achieve this in ASP.NET MVC, I started to build an own solution. The result is a combination of a base controller, an action filter and a flashmessenger object which is stored in the session. Please note that I’m not too familiar neither with ASP.NET nor with C#/.NET in general, so if there are things to improve please feel free to correct me.

read more »

Set up a Zend Framework application using Zend_Application (including PHPUnit setup)

Today I spent some time setting up a new Zend Framework application using ZF 1.8.0 Beta 1 and the new component Zend_Application. Using that component, all bootstrapping is done by Zend_Application_Bootstrap and so-called resource plugins. Such resource plugins are responsible for initialization of single components such as front controller, database or the view. This way, the whole bootstrapping is nicely modularized and keeps some headache away. In addition, the majority of settings can be set in the application config file. As I ran into some issues, I’d like to note the required steps and hope that it’s useful so someone. I won’t explain the files in detail, you can find enough information about components and parameters on the manual and the quickstart, but you should get to a working setup with just copy&pasting the code here ;)

Basically a big part of this setup can be done using the new Zend_Tool CLI, however I had some problems setting it up, so I’ve done it manually (however most of the code is the one generated by Zend_Tool).

read more »

Authenticate Apache against Redmine with AuthMySQL

For a student project we needed to authenticate an apache host against a MySQL database, in this a case we wanted to handle authentication for a Subversion repository with a Redmine database. I know that Redmine has its own solution for this problem using Redmine.pm, but for some reason that approach didn’t work and we didn’t have the time to bug around with it. This howto is written for the use with Redmine (especially the database view), but you should get the point how to set it up on other environments. The howto was done on an Ubuntu 8.10 box but should work on any other distro as well (except for the module installation). I assume that you got all the other stuff (apache, mysql, …) up and running.

read more »

gitosis-create-repo

A simple script to create a new gitosis-repository on the fly. I’m not really familiar with bash scripting so don’t expect too much ;)

#!/bin/bash
if [ -z $1 ]; then
    echo "Please specify a repository."
    exit 1
fi

if [ -z $2 ]; then
    echo "Please specify a remote url."
    exit 1
fi

if [ -d $1 ]; then
    echo "Repository already exists."
    exit 1
fi

mkdir $1
cd $1
git init
touch .gitignore
git add .gitignore
git commit -a -m "Initial commit."
git remote add origin $2:$1.git
git push origin master:refs/heads/master

Please make sure you set the correct permissions in gitosis.conf. Example:

[group me]
members = me@example.com
writable = test</pre>

Then you can run the script to create a new repository test on myhost.example.org:

$ gitosis-create-repo test git@myhost.example.org