<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OODA Strategies&#187; PHP</title>
	<atom:link href="http://oodastrategies.com/category/technical/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://oodastrategies.com</link>
	<description>Build a web presence, not just a website</description>
	<lastBuildDate>Sat, 21 May 2011 04:53:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Department of Defense Goes Wiki</title>
		<link>http://oodastrategies.com/2008/08/10/department-of-defense-goes-wiki/</link>
		<comments>http://oodastrategies.com/2008/08/10/department-of-defense-goes-wiki/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 20:41:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Information/Wiki Websites]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[video streaming]]></category>
		<category><![CDATA[virtual office]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://opensourceactivism.blogivists.com/2008/08/10/department-of-defense-goes-wiki/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.gcn.com/print/27_19/46779-1.html?topic=defense&amp;page=5" target="_blank">Department of Defense is embracing the web 2.0 world</a> with the use of wikis, social networking, and blogging. [Emphasis mine]</p>
<blockquote><p>“The only way they can get their jobs done is to <strong>collaborate via a virtual office</strong> and to get the information via AKO,” Noble said. Project members collaborate via <strong>virtual meetings, file sharing, community pages and Web pages</strong> dedicated to their parts of the program, Noble said. “We already have <strong>video, blogging and threaded discussions</strong>, 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 <strong>Intellipedia</strong> project, which <strong>uses wiki technology</strong> as the basis of intelligence information sharing.</p></blockquote>
<p>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.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Foodastrategies.com%2F2008%2F08%2F10%2Fdepartment-of-defense-goes-wiki%2F&amp;title=Department%20of%20Defense%20Goes%20Wiki" id="wpa2a_2"><img src="http://oodastrategies.com/socmedia/sharethis.png" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://oodastrategies.com/2008/08/10/department-of-defense-goes-wiki/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>XML Parsing Error: xml declaration not at start of external entity</title>
		<link>http://oodastrategies.com/2008/03/27/xml-parsing-error-xml-declaration-not-at-start-of-external-entity/</link>
		<comments>http://oodastrategies.com/2008/03/27/xml-parsing-error-xml-declaration-not-at-start-of-external-entity/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 23:41:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[FeedWordPress]]></category>
		<category><![CDATA[Parsing Error]]></category>
		<category><![CDATA[Wordpress MU]]></category>

		<guid isPermaLink="false">http://opensourceactivism.blogivists.com/2008/03/27/xml-parsing-error-xml-declaration-not-at-start-of-external-entity/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever seen this error in your WordPress feed?</p>
<blockquote><p>XML Parsing Error: xml declaration not at start of external entity</p></blockquote>
<p>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.</p>
<p>We use WordPress MU here at <a href="http://blogivists.com">Blogivists</a> running on a Linux server.  On the main page we have a <a href="http://blogivists.com/wpmu-feed/">feed</a> that displays the latest posts from all of the <a href="http://blogivists.com">blogivists</a> blogs. Yesterday, we discovered our <a href="http://blogivists.com/wpmu-feed/">feed</a> was broken and displaying the error shown above.  I had seen this error before when <a href="http://opensourceactivism.blogivists.com/2008/03/20/2-simple-wordpress-security-tasks/">securing the website</a>.</p>
<p>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&#8217;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.</p>
<p>I started by doing the following in the webroot of the website:</p>
<blockquote><p>find . -mtime -1 -name \*.php</p></blockquote>
<p>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.</p>
<p>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.</p>
<p>I assumed at this point that something was getting printed incorrectly.  I added print statements throughout the feed building code (<a href="http://projects.radgeek.com/2008/02/04/feedwordpress-0992-author-remapping-and-uri-bug-fix/">FeedWordPress</a>) until it was obvious that my first thought was correct, a file had whitespace before or after the php tags.</p>
<p>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 &lt;?php.  I removed those and the <a href="http://blogivists.com/wpmu-feed/">feed</a> was working properly again.</p>
<p>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 ?&gt; to eliminate that issue, however it won&#8217;t prevent the leading whitespace issue.  I don&#8217;t do that because I think it is bad coding style to not close all tags.</p>
<p>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 (<a href="http://wp-content/blogs.dir/110/files/2008/03/checkfiles.tar.gz">Check Whitespace Download</a>).  These are written for Linux, but could be modified for Windows is you wish.  Included in the file are my test files. I&#8217;ll outline the process below so you can see how it works.</p>
<p>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.</p>
<blockquote><p>
find . -name \*.php &gt; checkfiles.lst<br />
perl checkfiles.pl
</p></blockquote>
<p>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 &lt;?php tag:</p>
<blockquote><p>
        for ( $line=0; $line &lt; $rows; $line++ ) {<br />
                #print &#8220;line $line: &#8221; . $myfile[$line];<br />
                if ( $myfile[$line] =~ /^[ 0 ) { print "$fname - check leading whitespace\n"; }<br />
                        break;<br />
                }<br />
        }
</p></blockquote>
<p>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 &lt;?php.  If it is not the first line I print out a message to check the beginning of the file.</p>
<p>Checking the trailing whitespace is just the opposite.  I start with the last line and walk backwards looking for ?&gt;.  Here is the code segment that checks the end of the file:</p>
<blockquote><p>
        for ( $line = ($rows-1); $line &gt;= 0 ; $line-- ) {<br />
                #print "line $line: " . $myfile[$line];<br />
                if ( $myfile[$line] =~ /[?][&gt;]/ ) {<br />
                        if ( $line &lt; ($rows-1) ) { print &#8220;$fname &#8211; check trailing whitespace\n&#8221;; }<br />
                        break;<br />
                }<br />
        }
</p></blockquote>
<p>Hopefully you will never need to run any of these checks, but if you do this should make your life much easier.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Foodastrategies.com%2F2008%2F03%2F27%2Fxml-parsing-error-xml-declaration-not-at-start-of-external-entity%2F&amp;title=XML%20Parsing%20Error%3A%20xml%20declaration%20not%20at%20start%20of%20external%20entity" id="wpa2a_4"><img src="http://oodastrategies.com/socmedia/sharethis.png" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://oodastrategies.com/2008/03/27/xml-parsing-error-xml-declaration-not-at-start-of-external-entity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

