Archive for October, 2007

I have been working with eyeOS lately. I hacked around with some of the existing components, and developed one of my own. I can tell you that after researching every “Web Desktop” and “Virtual Desktop” I could find reference to, this is the best one that you can download and manipulate under an open source license. This project is unique in its approach. They have merged the use of PHP with javascript to seamlessly complement each other and create an actual OS on a web platform. One thing I noticed right away as I started developing with it, is that this team concentrated on creating systems that would be beneficial to having a web environment rather than a bunch of web apps throw together. For example, each running module or “eyeApp” is assigned a serialized process ID which can be used to kill the process, or Identify it. There is a lot of work that needs to be done on it depending on your application for it. The windowing system is done very well but all of the eye candy is not as rich as something like extjs. The PHP is clean and very innovative, but there are many core features that it lacks (Like native DB support). Since I started working with it, I have run across many more projects that are in the same area and I’m still very happy that I chose to go through the learning curve on this one. Here is a summary review to compare with other products: 0-10 style

  1. Cost: Free (Under an Open Source License)
  2. Features: 7
  3. Presentation: 8
  4. Code maturity: 8
  5. Documentation: 4
  6. Community:8
  7. User learning curve: 30 minutes
  8. Developer Learning curve: 3 days

If you have huge $$ to blow and want a commercial product to invest in instead of spending development time customizing eyeOS I recommend checking out the Laszlo webtop.

8
Oct

PHP tech mashup: CURL + Tidy + XMLParser

   Posted by: admin    in PHP, Software Development

I have been working on some very challenging projects recently that require retrieving remote pages, manipulating them and then sending them back to the user. There are several problems with this scenario:

  1. Due to a bunch of greedy and malicious hacks, many of the obvious and easier techniques are blocked by necessary security measures.
  2. Whenever you deal with outside code you don’t know what you’re going to get. It could be half formed, have all kinds of javascript workarounds, rely on frames in frames etc.
  3. Relative URLs. If you retrieve a remote page and display it locally, any relative URLs will be off, so links will be broken and image will not show. This also applies to stylesheet and script references.

Here’s the solution in a nutshell:

  1. Use CURL http://us3.php.net/manual/en/ref.curl.php to retrieve the remote page.
  2. Use Tidy http://us3.php.net/manual/en/ref.tidy.php to put the code into a proper XHTML format. This will close tags, give you predictable formatting, make it very easy to read the source and most importantly put it in a format that can be parsed as XML.
  3. Parse the XML using xml_parse http://us3.php.net/manual/en/function.xml-parse.php This is a wonderful function! I have spent hours coding XML parsing functions that recurse, save parents etc. This is a much more efficient method (Depending on your task) it creates 2 arrays, 1 for an index, and one for values. You can use the index to find what position you need in the values array and get any info you need.
  4. Manipulate the cleaned up HTML. Since you have XHTML to work with now you can manipulate it as XML or you can use string replacement. This would be the time to replace all of the relative URLs with Absolute ones.
  5. Display it back to the user! I don’t want to know how you apply this method, I just like coming up with the solutions ;)