Simple WordPress plugin (include-file)

I may have created one of the simplest possible plugins for WordPress. I also have no doubt that this has probably been created before my multiple other people, but it was easier to create than evaluate the existing options out there. If you just want to download the plugin click here.

This plugin includes the contents of a file from a URL or path into a WordPress page or post using a shortcode. It would look like this in your post:

[include_file url='http://example.org/somefile.txt']

I’ve posted the source code below as it might serve as a good template to someone who wants to create their own plugin.

<?php
/*
Plugin Name: include-file
Plugin URI: http://wordpress.org/extend/plugins/include-file/
Description: Includes the contents of a file at a given url in a post.
Version: 1
Author: Tyler Stafford <tyler.stafford@gmail.com>
Author URI: http://tylerstafford.net
*/

function tsIncludeFile($atts,$content=null,$code="") {
	$content = file_get_contents($atts['url']); 
	if ($content == true) {
		return $content;
	} else {
		return "An error occured retreiving " . $atts['url'];
	}
	return $atts['url'];
}

add_shortcode('include_file','tsIncludeFile');
?>

Locked user profiles in Windows 7/Vista/2008

I’ve been experiencing this problem at work for over a year. After the system was up for an undetermined period of time, users who logged in would sometimes receive the following message.

You have been logged on with a temporary profile. You cannot access your files and files created in this profile will be deleted when you log off. To fix this, log off and try logging on later. Please see the event log for details or contact your system administrator.

This appears in the event log as event id 1502, 1515, and 1511.

I had tried to resolve the problem numerous times and was never able to find any answers better than “restart the system”. Not good enough. Then yesterday, I FINALLY found a thread which accurately identified the cause of the problem. Apparently, it’s Google Updater!

One poster on another thread solved the issue by uninstalling Google Updater, however, I didn’t want to go so far just yet. Instead, I disabled the scheduled tasks setup by Google and the Google Updater Service. I scheduled a restart on the server and, so far, I haven’t seen the locked profiles issue again.

Update: I did more testing on this and the solution is indeed to remove Google Updater. I re-enabled the “GoogleUpdateTaskMachineCore” and “GoogleUpdateTaskMachineUA” tasks, and things seem to be working fine.

Updates to my KVM backup script

I’ve been spending quite a bit of time refining the KVM backup script. I’ve added the ability for the script to snapshot the LVM block device and immediately restart the machine. I was also not able to find a way to get Windows guests to shutdown reliably. The guest will shutdown if a user is logged on, and if no user is logged on, but it will not shut down if a user is logged on and the user has locked the workstation. To workaround this I added the “-w” option to shutdown a windows guest using the “net rpc shutdown” command with samba. Check out the project on github.