Thursday 22 March 2007

Monday 19 March 2007

Orcas

This is the first of a couple posts I'm hoping to get finished tonight, the other two are in progress but I don't want to post them until I finish some other bits and pieces. Back to this post though. Saturday I was finally able to get all the Visual Studio Orcas downloads, and I got myself Virtual PC 2007, uncompressed the base and orcas files to give it a whirl. Now i know its CTF so you have to be patient however what I experienced yesterday was far from good :( Upon creating my new virtual machine as per the site's instructions I was presented with an error. Instead of being able to update and choose the location of my base image for the orcas machine i get the browse file window, find my file, and then click open . . . . and that's it nothign happens, you can click open as much as you want but nothing happens :( Bit of a major error as Orcas won't work without it. I then tried to load the base image. This loads up fine but could I login with the login details provided by Microsoft, hell I couldn't :( After a few searches on le Google I found that the password is actuall P@ssw0rd, not P2ssw0rd. Error 2 for Microsoft. (Error 1 was my image not wanting to update) So of course I'm now confident I can load up my virtual image just to play with Windows Server 2003 at least. Well not quite, P@ssw0rd wouldn't work either. By this point I'm pondering if I continue this venture or just give up. However not being a quitter, well often, I decided to Google my new problem. Low and behold the answer came quite quickly. Basically the Base PC image its expecting by default a US keyboard, so to get an @ you do shift + 2, I had naturally assumed that Virtual PC made this conversion for you, as that's the logical thing to do. Keyboard Mappign can't be that hard, especially as it was a Microsoft OS I was virtualizing, now armed with the solution I tried logging in again P"ssw0rd. As you can imagine I was quite happy when it logged in, however I was surprised by the fact you have to activate your windows :( very odd in my books, especially as I had disabled the network card emulation as I didn't really want Server 2003 on my network. Any how after activating the network and rebooting Windows booted fine and activated. However I still can't run orcas as the stupid orcas image wouldn't update. When I find out why I will post my solution here so other people can not be bogged down by these issues. I'm hoping to see how good orcas is one day. Probably not today though :(

Friday 16 March 2007

del.icio.us links

del.icio.us links

Links for 2007-03-15 [del.icio.us]

Posted: 16 Mar 2007 12:00 AM CDT

Thursday 15 March 2007

It's all about the del in del.icio.us

In my opinion what makes del.icio.us great is the ability to view or allow other people to view your bookmarks where ever you are. If you then put this into the blogging context then having the ability to show your bookmarks on your blog is an awesome way of publicising what you look at. Now if we take this a step further then having a daily update of links of articles, pages and tutorials that we found useful that day is mind bogglingly awesome.


Del.icio.us also thinks this is the way forward and offers (if a some what crude and unfriendly) interface for linking you del.icio.us links with your blog. However all is not strawberries and cream if you are a user of Blogger. The Blogger API doesn't seem to use the same XML-RPC interface. Meaning that del.icio.us won't talk to you blog and getting a daily blog of your links will be a pain.


I decided to come up with a way to overcome this. Bring in some PHP, Cron Job's and a hole lot of XML goodness, a touch of html email and just a hint of blogger configuration and you get the MJJames Del.icio.us blog poster :D


An Overview

Currently in alpha my PHP script takes a del.icio.us RSS feed, an email address and an optional range field and produces an email that gets sent to the specified email address.

As such it can be used for email daily, monthly or even yearly link lists to either a blog or to individuals or mailing lists.


The script works by taking the provided RSS feed and opening it as a PHP XML Source, the optional range field is then used to determine the date range of del.icio.us links to return. Currently the options are daily (default), month or year.


The date range returned is then used to loop through the del.icio.us RSS feed and pulls out any nodes that match the date criteria. These nodes are then used to generate the contents of the email. The beta version uses title, date, short description and link.


The entire email is then sent to the provided email address. Now the way this email appears on a blog is by letting your blog accept post's via email and setting up a unique email address for blog posts.


Of course with the script and blogger configured the next step is to schedule this script to run daily.


With most PHP installations running on UNIX the main way to schedule this script is to use Cron Jobs, this way we can specify to run this script daily, weekly, monthly or even yearly depending on your needs.


Now this is where I must say that I have ran into some problems. I got my Cron Job to execute my script by using /usr/bin/php -q /home/el/public_html/development/delicious/index.php


However, this doesn't allow me to specify any options for the script, so I have had to fall back to hard coded values for my feed and email. This is far from ideal and in effect renders alot of the script useless, now I was sure you could give Cron a URL with querystring parameters but it has alluded me thus far :(


Current Issues

  • The code used DOM and loops through the RSS feed using PHP to perform some logic checks, this is untidy and far from optimised code. My next version will use XPath to query the RSS feed and return the matching nodes which PHP can then render into an email
  • It doesn't do weeks. Currently you can schedule it to daily updates, monthly and yearly reminders / reading lists but there is no provision for weeks. This is mainly because at the time I couldn't be bothered to find the week's start and end date based on the day its ran. This is easily doable, I just need to get off of playing with .Net and back on to PHP for a night.
  • My issues with CRON and url's needs resolving so this script can be configured for multiple users
  • It assumes the url feed doesn't include http:// and adds this on, this should be looked for before adding
  • Currently it only handles del.icio.us feeds, the next step is to looking at how it would handle Google Bookmarks and making it work seamlessly with that.
  • It needs to be completely turned into object orientated PHP 5 code, not some functions and main code - Currently lazy code

Code

/* ====================================== MJJames - Blog Poster Alpha v 0.6 email: blogposter (at) michaeljames.me.uk ====================================== */ function loadXMLStream($input){ $xml = new DOMDocument; // We need to validate our document before refering to the id $xml->validateOnParse = true; $success = false; if ($xml->load($input)){ $success = true; } if ($success==true){ return $xml; } else{ echo "ERROR: Source Not Found"; //cronJob will email us any output - normally we don't want this but as the feed wasnt found we need an error message return "XML Source Not Found } } function makeDate($daterange){ switch (strtolower($daterange)){ //our date range field will stipulate if we return a day, week or month's worth of nodes case "day": $date = date("Y-m-d", time()); break; case "week": // needs to be added break; case "month": $date = date("Y-m", time()); break; case "year": $date = date("Y", time()); break; } return $date; } $url = "http://".$_GET["url"]; $xml = loadXMLStream($url); $range= strtolower($_GET["range"]); if ($range==""){ $range = "day"; } $date = makeDate($range); foreach ($xml->documentElement->childNodes as $links) { //if node is an element (nodeType == 1) and the name is "item" loop further if ($links->nodeType == 1 && $links->nodeName == "item") { foreach ($links->childNodes as $item) { //if node is an element and the name is "title" "link" or "description" then add to temp variables for the email if ($item->nodeName == "title" ) { $title = $item->nodeValue; } if ($item->nodeName =="link"){ $link = $item->nodeValue; } if ($item->nodeName == "description"){ $description = $item->nodeValue; } if ($item->nodeType == 1 && $item->nodeName == "dc:date" && stristr($item->nodeValue, $date)){ //if its a date node check to see if our date is in it $dates = $item->nodeValue; $output = true; //if we're here then its our date and we need to add it to our email } } } if ($output){ $email.= "

$title - ".date("j F, Y",strtotime($dates))."

$description

Link: $link

";
} $output = false; } $sendto = "".$_GET["email"]; if ($sendto == ""){ echo "email failed - no email address"; //cronJob will email us any output - normally we don't want this but as the email failed to send we should know this } else{ if ($email != ""){ //if we have content and an email address $email = "

Del.icio.us Links For ".date("d/m/Y", time())."

".$email;
$headers = 'From: blogposter@michaeljames.me.uk' . "\r\n" . 'Reply-To: blogposter@michaeljames.me.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(). "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; if (mail($sendto, "Del.icio.us Links For ".date("d/m/Y", time()), $email, $headers)){ } else{ echo "email failed"; //cronJob will email us any output - normally we don't want this but as the email failed to send we should know this } } } ?>

del.icio.us links

del.icio.us links

Links for 2007-03-14 [del.icio.us]

Posted: 15 Mar 2007 12:00 AM CDT

Wednesday 14 March 2007

del.icio.us links

del.icio.us links

Links for 2007-03-13 [del.icio.us]

Posted: 14 Mar 2007 12:00 AM CDT

Sunday 11 March 2007

del.icio.us links

del.icio.us links

Links for 2007-03-10 [del.icio.us]

Posted: 11 Mar 2007 12:00 AM CST

Links for 2007-03-08 [del.icio.us]

Posted: 09 Mar 2007 12:00 AM CST

Friday 9 March 2007

Return of the Flash Object

Well today I had another run in with multiple flash objects within a page of a site. However today it wasn't flagged by using IE6, it was IE7. The problem I was experiencing was, that the page loaded up fine with it's various flash animation, but if you refreshed the page IE7 crashed out. What made matters worse was that it was only happening on one of our IE7 test machines, annoying, at this point I knew it had to be down to the version of flash. This test machine was using Flash Player 6 and after some web trawling I stumbled upon the following: If you are running Internet Explorer and Flash Player version 6.0.21, 6.0.23, or 6.0.29, the browser will crash if you call GetVariable or SetVariable (or a number of other methods that are built into the Flash Player plugin). However this doesn't seem quite right, as it was only happening on a reload, I am still puzzled, but for now I have taken the cheats way out. I looked at Adobe's penetration stats of its various flash players and came to the conclusion that flash player 6 is only used by 1% of majorly developed country's. So decided to up the required Flash to version 7 within my UFO detection script, which miraculously cured the bug. But I am not satisfied with this, it is a cop out and a cheats way out. I need to find out whats doing it, I know that if you try to look at the revision numbers of flash player 6 the lower revisions cause the browser to crash, but this should happen on every load, not upon a refresh. So needless to say I am looking into this further, if anyone has any ideas or advice let me know so I can cure this problem and then share the information on here.

Thursday 8 March 2007

del.icio.us links

del.icio.us links

Links for 2007-03-07 [del.icio.us]

Posted: 08 Mar 2007 12:00 AM CST

Learning ASP.Net 2 Part 1

I started this Blog so that I could document my experiences of Web Technology and how I have found using them etc. One of my keen areas of interest was going to be learning .Net 2. Sadly this has yet to happen as I have been busy with work and some old PHP stuff. However I have been given a project by my church to build them a new website that will allow an editor to maintain it but also to have an events calendar and to provide podcast feeds. I was thinking to either use an old basic CMS system I had made in PHP or to use a free open source CMS system. But after some thought I came to the conclusion that this would be a great project to learn .Net with. So this evening while the wife's away I started. Yesterday evening I messed around with some tutorial videos on .net and Ajax but tonight I started writing my own code. I won't bore you with all the details but tonight I got a rough db design together, made a basic page that currently lists the page table and allows you to sort these as well as feature paging. I also started the add/edit page and got it inserting data into the database. What I have noticed so far is how easy it is to use controls, tonight I have used grid view and form view and tailored them as needed. This makes such a change from PHP and ASP where everything is so manual and lengthy. I also got FCKeditor working in .Net and as a control in Visual Studio Express. This was easier than in ASP or PHP and having IntelliType while setting it up made a huge difference. One thing I didn't sort tonight was default values for my form inputs, this frustrated me as I could bind the fields to the db or have a value, sorting this will tomorrow night's first task. So far I'm liking .Net, C# is quite natural as I have used C++, Java and PHP in the past and Visual Studio Express is a great tool, so hopefully tomorrow things will go onwards and upwards :D.

Saturday 3 March 2007

Game On March 2007 - Day 1

Well its just past 2am and the first evening of the GameOn LAN event has been pretty good. We arrived just after 9.30 after a quick Mc D's for tea, chicken selects by the way are awesome, and then started setting up. It's not fully booked here but we have a good 80 - 90 LAN players, each ranging from CSS demons to Battlefield 2 pro's. It being the first night means people are mainly just setting up and getting their systems primed as well as there wrists. So far I have played some CSS and a crazy little car racing game called TMNations. For such a game its really fun to play, especially on a LAN. Tomorrow will involve Tournaments and this time we are in teams of 5 and competing in various games, CSS, TMNation, UT & Battlefields 2. Sadly I'm not really good enough to be considered a real opponent in any of these, so far i have been p'wned preety badly, but hey its about havign a laugh. On a more positive note the XP Reinstall has really helped speed up my comp :D Until tomorrow :)

Thursday 1 March 2007

Houston we have a Problem :S

This evening I fell victim to another grand M$ cock up. I decided to clean install xp on another drive, as my exisiting one is getting chuggy and with the GameOn Lan starting tomorrow evening I wanted my PC to be in 100% form. I thought what the hell lets chuck on Office incase I need to get to any of my work and can't be bothered to reboot. I chucked in the disc, fired up as usual, 3rd time I've installed Office 2007 and I have never had a problem until tonight. "The windows installer service cannot update one or more protected windows files." Three characters came to mind W T F! I had never seen this error before so tried again, no joy, rebooted, no joy, tried a different CD Drive, no joy. :( I then decided to check our friends over at Developer Fusion and Thushan Fernando had the answer. It was missing a file. A file, a stupid file that shouldnt have existed after a clean boot. Now this puzzles me as a) why not just install the file, b) its a stupid error and c) they have had this problem since office 2000 How crazy is this, why hasn't this bug been cured yet, it baffles me. Any way if you stumple onto this post because you have this same error do the following: Simple, download a copy of the missing file fp4autl.dll from DllDump, place it into the c:\program files\common files\microsoft shared\web server extensions\40\bin\ folder and retry installation. Sorted