A small webchat using JavaScript, PHP and MySQL

During my studies, I had some lectures about Ajax driven web-services in the second or third semester and I thought, that I can build something like that on my own. So I started this little chat project and gave it a try.

Used technologies:
JavaScript (for Ajax action), PHP and MySQL, HTML and CSS
(Thats also where the name comes from – AMPChat – AjaxMysqlPhpChat)

The working mechanism is the following (simplified):
A JavaScript function polls a PHP script, telling it which chatmessages it already knows. The PHP script checks, whether there are new chatmessages stored in the database or not and sends its response – an XML with either no records (if no new messages are around) or one with the missing chatmessages. The JavaScript then writes the new messages in a DIV element of a website.

The chat is available under the following link:
user: guest
password: 123123

The whole thing is open-source. You can find the code here: https://looke.ch/amp/source.php

BackupExec – Media sets vs. library partitioning


In this article, I want to give a short overview of the advantages of using partitioning with backup libraries and Symantec’s BackupExec and hopefully bring a bit of transparency in how BackupExec determines, which media it will use for a given backup job.


First we assume, we have a small company, which backs up its data every working day of the week – 4 times incremental (Monday, Tuesday, Wednesday, Thursday) and one time a full backup (Friday). The company uses a robotic library with 8 slots. The company wants to make sure, the backup types use different tapes, because the tapes with the Full backups are being stored at a safe location.

First attempt – Media sets

Now, how would you handle the backup plans, to have the incremental and the full backups separated from each other, to be able to archive the full backup tape-sets on a safe location?

You might think, you create two Media sets in the BackupExec Media pane, one named Full and the other named Incremental and then tell the backup jobs to use either Media set… But here is just where the problem starts.
After running the whole thing for some time, you might notice that either your Full or your Incremental Media set is empty and all tapes have shifted to the other media set.

Conclusion and Summary – Library partitioning vs. Media sets

BackupExec doesn’t handle the backup media like you might think, after just looking at it.
Media sets are intended to identify the data, stored on the tapes and not to identify the correct tapes for a job to be executed! To be really sure, to have your Backups separated, you need to enable partitioning on your backup library. Lets say, you configure slot 1 to 4 for the full backups and the slots 5 to 8 for the incremental ones. Works straight-forward, after the partitioning you can select of which partition the backup job should take its tapes.


Creating, configuring, and targeting a backup job to a Robotic Library partition in Backup Exec For Windows Server

List of ActiveDirectory User Attributes (2000 and 2003)

During my work as a system engineer I often come across situations, where I need to have an easy overview of an ActiveDirectories attribute names. To be a bit more independent of other sites, I decided to start with mirroring an attribute list from the MS KB.

Optional Attributes

accountExpires Value:9223372036854775807
cn (Container) Value:Nirmal
codePage Value:0
countryCode Value:536
displayName Value:Display Name
distinguishedName Value:CN=nirmal,CN=Users,DC=test,DC=local
instanceType Value:4
name Value:nirmal
objectCategory Value:CN=Person,CN=Schema,CN=Configuration,DC
uSNChanged Value:50203
uSNCreated Value:13920
whenChanged Value:2022552554552
whenCreated Value:2022554588585
logonHours Value:://///////////////////////////
userAccountControl Value:524802

Required Attributes

dn Value:CN=nirmal,CN=Users,DC=test,DC=local
objectClass Value:User
sAMAccountName Value:SAMLNAME

Attributes that can’t be imported into AD

badPasswordTime Value:1
badPwdCount Value:1
lastLogoff Value:0932479234902343
lastLogon Value:12924723489374737
logonCount Value:0
primaryGroupID Value:513
pwdLastSet Value:0
sAMAccountType Value:805306368
objectGUID Value::QT2p48fufjweue839384ufufj/A==
objectSid Value::
memberOf Value:CN=Domain Admins,


department Value:GIS
co (Country Name) Value:India
company Value:Computer Sciences Corporation
description Value:Description Field Cost Centre
adminCount Value:1
c (2 digit country) Value:IN
homeDirectory Value:\\amppfilerp01\hthrmg$
homeDrive Value:H:\
info (Phone notes)
initials Value:INT
l (City) Value:City Field
userPrincipalName Value:LogonName@test.local
wWWHomePage Value:Web Page Field
mail Value:Emailss@sss.com
msNPAllowDialin Value:FALSE
profilePath Value:\\tqchain2k3pc\profiles\nirmal
physicalDeliveryOfficeName Value:Office Name
postalCode Value:Zip Code
postOfficeBox Value:Post Office Box
scriptPath Value:qchain.vbs
sn (Surname) Value:Last Name Field
st (2 digit State / Province)

Taken from: http://support.microsoft.com/kb/555638
Further informations: http://support.microsoft.com/kb/257218
Information on ActiveDirectory attribute time/date conversion: http://support.microsoft.com/kb/555936

Pause W2K3 SMB shares

Although, there is no clicky way to pause a Windows servers shares, there is a bit more unconvenient way to prevent users from accessing your servers shares:

  • Fire up a registry editor and navigate to HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares
  • Export all shares you want to reopen again later
  • Delete all shares you want to pause and close the registry editor
  • Restart the service called “Server

et voila, you’re done.

Recursively delete outdated files with VBScript

Recently, I came across the situation, where I had to delete outdated SQL backup files from our MS SQL servers Backup directory. To tidy up the backup folder, I wrote a small VB script which handles this for me:

' DeleteOutdated
' Parameters
' MaxFileAge: Maximum file age in days (modification date)
' Path: Folder which contains the files
' VBScript ref. http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspx
' FSO ref. http://msdn.microsoft.com/en-us/library/z9ty6h50(VS.85).aspx

Dim objFso
Set objFso = CreateObject("Scripting.FileSystemObject")

Sub DeleteOutdated(Path, MaxFileAge)
	Set objDir = objFso.GetFolder(Path)
	For Each objFile in objDir.Files
		If objFile.DateLastModified < (Date() - MaxFileAge) Then
			AskDelete = MsgBox("Delete "&objFile.Path&"?",3,"Delete file")
			If AskDelete = 6 Then
			End If
			If AskDelete = 2 Then
			End If
		End If

	For Each objSubfolder in objDir.Subfolders
		Call DeleteOutdated(objSubfolder, MaxFileAge)
End Sub

Call DeleteOutdated("c:\outdatedstuff", 1)

In this state, the script asks to delete everytime, if it finds a file wich is older than specified. Of course, you might want to remove that in productive usage, when script execution is scheduled.

Here I attached a version, which writes a logfile and processes empty subfolders (updated on 26.08.2009):

Detecting rogue WLANs with Kismet

In a corporate environment, where you have several IT- security related regulations, it is critical to know what kind of wireless networks are in range of your facilities to avoid the bypassing of corporate security infrastructure (such as proxies, firewalls…)

This is where Kismet comes into play and assists you in finding rogue wireless LANs, using the monitor mode of your WLAN card.

You can get the software here: http://www.kismetwireless.net/
Kismet is open-source and also included in several security related linux distros.

The usage is quite simple. Just press “h” while the program runs to display a list of available keyboard shortcuts.

(taken from kismetwireless.net)

  • Ethereal/Tcpdump compatible data logging
  • Airsnort compatible weak-iv packet logging
  • Network IP range detection
  • Built-in channel hopping and multicard split channel hopping
  • Hidden network SSID decloaking

Here are some screenshots of Kismet in action

Hint (as fas as I know while using it under Ubuntu 8.10):
After closing the program, you might have to get your WLAN card back to managed mode.

  • ifconfig ethXX down
  • iwconfig ethXX mode managed
  • ifconfig ethXX up

A simple How-To to csv handling with PHP

This How-To provides a quick overview on how to add simple csv import-export functionality to your PHP project.

Write a csv from an array

$data = array('Text1', 'Text2', 'Text3'); // start with your data array
$delimiter = ",";			  // set delimiting character
$file = "./target.csv";			  // specify the target file
$line[0] = implode($delimiter, $data);	  // set content of the first line
$fileprocess = fopen($file, "w");	  // open the target file in write mode
fwrite($fileprocess, $line[0]."\n");	  // write the first line to the file
fclose($fileprocess);			  // close the target file

Read a csv to an array

$delimiter = ",";			  // set delimiting character
$file = "./source.csv";			  // specify the source file
$line = file($file);			  // read file line by line
$data = explode($delimiter, $line[0]);	  // get contents by line
	  	  	  	  	  // (0 for line 1, 1 for line 2 and so on...)
// access the data

The structure of source.csv/target.csv


The scripts above are just to demonstrate the basic functionality. There are many possibilities to extend them (i.e. add a way to write more than one line by working with a “for” expression and so on…)

Arduino – building open-source electronics prototypes

Arduino is an open-source microprocessor platform to build electronics prototypes. Not only the development tools are open-source, but also the hardware itself. You can download all the necessary plans for it and build your own one, if you want to.

The really cool thing about the Arduino is, that you can program it with the open-source programming language Wiring, which is very straightforward to use.

Of course, being a complete newbie in electronics engineering, I ordered my own Arduino board as a prebuilt base-board – the Arduino Duemilanove
…and finally, it arrived :)

As a first act of familiarization, I started with the very basic “push a button to power the LED” program

int ledPin = 13; // choose the pin for the LED
int inPin = 2;    // choose the input pin (for a pushbutton)
int val = 0;      // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);      // declare pushbutton as input

void loop(){
  val = digitalRead(inPin);   // read input value
  if (val == HIGH) {           // check if the input is HIGH (button released)
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH);  // turn LED ON