Department of Defense Goes Wiki

The Department of Defense is embracing the web 2.0 world with the use of wikis, social networking, and blogging. [Emphasis mine]

“The only way they can get their jobs done is to collaborate via a virtual office and to get the information via AKO,” Noble said. Project members collaborate via virtual meetings, file sharing, community pages and Web pages dedicated to their parts of the program, Noble said. “We already have video, blogging and threaded discussions, and we are going to add other features like wikis,” Noble said. One of the most influential Web 2.0 information-sharing projects in the military and intelligence communities has been the Intellipedia project, which uses wiki technology as the basis of intelligence information sharing.

With all the disparate systems the governmental departments use, wikis and other web 2.0 technologies are great avenues for them to start standardizing. Standardization lowers cost in both training and information sharing. The addition of using Open Source technologies will also help keep costs down elminating the need for yearly maintenance fees. We should encourage more governmental agencies to use open source technoligies. Most are very resistent for a multitude of reasons. The largest reason I have seen is they are afraid of change. By keeping the same technologies that have been used for years, you never have to learn anything new; you maintian job security; and you keep your budget artifically inflated due to the maintenance costs.

Share

XML Parsing Error: xml declaration not at start of external entity

Have you ever seen this error in your WordPress feed?

XML Parsing Error: xml declaration not at start of external entity

I have now, multiple times. It is something that is so easy to cause without even knowing how it happened or that it happened at all for hours or days.

We use WordPress MU here at Blogivists running on a Linux server. On the main page we have a feed that displays the latest posts from all of the blogivists blogs. Yesterday, we discovered our feed was broken and displaying the error shown above. I had seen this error before when securing the website.

I recognized it immediately as being blank lines in the code outside the php tags of . The problem becomes finding the errant code. If you don’t have shell access you will have to go through each file you have changed to find the error. With shell access the task becomes a little easier. I intend to make it even easier for you.

I started by doing the following in the webroot of the website:

find . -mtime -1 -name \*.php

This gave me a list of all files that had been changed in the past 24 hours. I then stepped through each file looking for the problem. This was a tedious and slow process. I started with files in wp-content/plugins and wp-includes. I had no luck.

Next I wrote a quick script that printed the first 2 and last 2 lines of each php file. I then worked my way through the list and again found nothing.

I assumed at this point that something was getting printed incorrectly. I added print statements throughout the feed building code (FeedWordPress) until it was obvious that my first thought was correct, a file had whitespace before or after the php tags.

I reran the find command from earlier. At this point I started checking the themes themselves. I had skipped those earlier since I did not think theme templates would have an effect on the feed building. I discovered themes do have an effect, particularly since the theme that caused the problem was the main page theme. I finally discovered the functions.php file had been edited and 2 blank lines had been placed at the top of the file before the <?php. I removed those and the feed was working properly again.

Now, to make this easier for everyone and myself when this happens again. I wrote a script that will run through every php file and check the to make sure there is no whitespace before the starting tag. As a side note here, you can remove the ending tag ?> to eliminate that issue, however it won’t prevent the leading whitespace issue. I don’t do that because I think it is bad coding style to not close all tags.

You can download a gzip file that contains the test files and script source by right clicking and choosing Save Link As on the following link (Check Whitespace Download). These are written for Linux, but could be modified for Windows is you wish. Included in the file are my test files. I’ll outline the process below so you can see how it works.

The first script is a bash script that prints a file tree into a text file and starts the perl script that does the actual searching.

find . -name \*.php > checkfiles.lst
perl checkfiles.pl

The perl script loops through the file list and checks the beginning and end of the file. Here is the code segment to check for any whitespace before the <?php tag:

for ( $line=0; $line < $rows; $line++ ) {
#print “line $line: ” . $myfile[$line];
if ( $myfile[$line] =~ /^[ 0 ) { print "$fname - check leading whitespace\n"; }
break;
}
}

For both of those segments the current file has already been read into an array. This makes the searching must easier to accomplish. Basically all I am doing is checking each line to see if it contains <?php. If it is not the first line I print out a message to check the beginning of the file.

Checking the trailing whitespace is just the opposite. I start with the last line and walk backwards looking for ?>. Here is the code segment that checks the end of the file:

for ( $line = ($rows-1); $line >= 0 ; $line-- ) {
#print "line $line: " . $myfile[$line];
if ( $myfile[$line] =~ /[?][>]/ ) {
if ( $line < ($rows-1) ) { print “$fname – check trailing whitespace\n”; }
break;
}
}

Hopefully you will never need to run any of these checks, but if you do this should make your life much easier.

Share