As a developer you’re probably using a versioning control system, like subversion or git, to safeguard your data. Advantages of using a VCS are that you can walk to the individual changes for a document, see who made each change and revert back to specific revision if needed. These are features which would also be nice for data stored in a database. With the use of triggers we can implement versioning for data stored in a MySQL db.

The revisioning table
We will not store the different versions of the records in the original table. We want this solution to be in the database layer instead of putting all the logic in the application layer. Instead we’ll create a new table, which stores all the different versions and lives next to the original table, which only contains the current version of each record. This revisioning table is copy of the original table, with a couple of additional fields.

CREATE TABLE `_revision_mytable` LIKE `mytable`;

ALTER TABLE `_revision_mytable`
  CHANGE `id` `id` int(10) unsigned,
  DROP PRIMARY KEY,
  ADD `_revision` bigint unsigned AUTO_INCREMENT,
  ADD `_revision_previous` bigint unsigned NULL,
  ADD `_revision_action` enum('INSERT','UPDATE') default NULL,
  ADD `_revision_user_id` int(10) unsigned NULL,
  ADD `_revision_timestamp` datetime NULL default NULL,
  ADD `_revision_comment` text NULL,
  ADD PRIMARY KEY (`_revision`),
  ADD INDEX (`_revision_previous`),
  ADD INDEX `org_primary` (`id`);

The most important field is `_revision`. This field contains a unique identifier for a version of a record from the table. Since this is the unique identifier in the revisioning table, the original id field becomes a normal (indexed) field.
Continue reading »

 

Associated websites often share user information, so a visitor only has to register once and can use that username and password for all sites. A good example for this is Google. You can use you google account for GMail, Blogger, iGoogle, google code, etc. This is nice, but it would be even nicer if logging in for GMail would mean I’m also logged in for the other websites. For that you need to implement single sign-on (SSO).

There are many single sign-on applications and protocols. Most of these are fairly complex. Applications often come with full user management solutions. This makes them difficult to integrate. Most solutions also don’t work well with AJAX, because redirection is used to let the visitor log in at the SSO server.

I’ve written a simple single sign-on solution (400 lines of code), which works by linking sessions. This solutions works for normal websites as well as AJAX sites.
Continue reading »

 

The normal way to save a state, like the fact that a user is logged in, is to use sessions. Session work really nice, you can save all kind of data on the server (in a temp file) which is identified by a hash which is known on the client in a cookie or by url rewriting.

However if you only need to save a small bit of login info, like a username and timestamp, using sessions is a bit of an overkill. Also, if your system would grow beyond to a size where you need load balancing over multiple servers, having a solution with sessions would be somewhat of a burden. You would need to store them in a centralized place, like a DB server.

Another way to do this, is to create an authentication hash. The idea is fairly simple: Join the information you want to known into a single string and append an md5 key of all the info + a secret word. On each request, check if the hash is available and correct, otherwise redirect the user to a login form. You can use the hash the same way PHP uses the session hash, using cookies or URL rewriting.

[snip php-source]code/authhash/authhash.php[/snip]
Download the code

 

This is a reaction to article (or is it a commercial) ‘How to choose an Ajax Framework’.

The idea behind client side only AJAX is that you don’t have to do a lot of complicated javascript work yourself. The difficult stuff is done by the lib and you only have to call it upon HTML event.
Since the code is actually executed on the client, having client-side code, makes the code base simpler. The lines of code will most likely be less than with a server side solution. The only drawback is that you do need to program some javascript. This might be a new language to you and therefore uncomfortable.

There is a third key of AJAX framework not discussed in this articled. These framework are usually described as RIA (Rich Internet Application) platforms. These frameworks parse XML much like how XHTML is parsed by the browser. The XML contains a lot more nodes types than HTML and is usually extendible. So instead of only having having an <input> tag, you will have things like <tree> and <datagrid>.
Ajax calls are also represented as XML and neat things like databinding is also supported.

RIA frameworks:
 Abode Flex
 Ajax.org PlatForm
 Dojo Dijit
 OpenLaszlo

If you’re working on a web based application and not at a website RIA platforms are certainly worth having a look at. OpenLaszlo has got a good screencast, which is representative for all of these frameworks.

 

Yesterday, PHPBuilder posted an article about sending a form using AJAX. This article shows how to post a simple form. But looking closely at the example, you can also see what the problem is using the plain XMLHttpRequest object and writing an implementation yourself.

First of all you to write some rather difficult javascript code. Next you need to completely rewrite your page, looking nor working like a normal HTML form. Last and most important, the function fetches values using getElementById(). This is not really very flexible, because you will need not only the form, but the function as well when you add a field.

Using an AJAX library can really help you here. Javeline TelePort has got a brand new method, which automatically creates a HTTP post request of a form and sends it to the server.
Continue reading »

 

Please use http://beepme.javeline.com/bugs/ to report bugs and not this blog.

We have been working hard on the BeepMe and FeedMe Facebook applications. And BeepMe is almost ready to be published.

BeepMe is a notifier for Facebook that runs in your system tray. Whenever you get a new message, friend invite, etc you’ll get a pop-up. There also a cool feature to add a text box to your Facebook profile allowing friends (or others depending on you settings) to send a pop-up message to you instantly.

I have BeepMe running under Linux, though it is a windows only application. Using crossover (commercial version of wine) I am able to run it on my gnome desktop.
Beepme image

Goto http://apps.facebook.com/_beepme/ to give BeepMe a try.

 

We at Javeline are currently working on creating 2 applications for FeedMe and BeepMe. FeedMe is an RSS aggregator and reader and BeepMe is a notifier. Both will use Javeline PlatForm and BeepMe will also use DeskRun. But more on this later.

Creating a facebook interface works quite well. They supply a PHP client API and decent documentation http://developers.facebook.com. Because of the provided SDK, most of what happens is magic. When you develop an Ajax application, you might run into some unexpected trouble because of this. Instead of getting the requested data, you get a <script> tag with an redirect to the facebook login page.

What you need to do it send the complete HTTP query with the request, eg:

http://beepme.javeline.com/get_notifications.php?fb_sig_in_iframe=1&fb_sig_time=1186090520.6582&fb_sig_user=789574251&fb_sig_profile_update_time=1185200116&fb_sig_session_key=…&fb_sig_expires=0&fb_sig_api_key=…&fb_sig_added=1&fb_sig=…

Normally facebook solve this problem internally, but it can only do so if is in the browser and in an iframe.

Anyway, if you are using facebook, stay tuned for these apps, because they will pebble (rock is a bit of an overstatement) your world.

 

The server has gone online, but the website isn’t live yet. There are still some CSS problems with IE, especially in the bug tracker. I’ll have to look at that next week.
Also much of the content is still a stub and the downloads are fake as well. The deadline is the 21st of may, so that should be a problem.

If you want to have a look already go to http://developer.javeline.net (use Firefox).

Questions? Just ask!

About the author

Hi, I'm Arnold Daniels. How nice that you like to know a bit more about little old me :).

I've spend a big part of my life behind a computer (and not playing games). I've learned a lot about databases, programming and system administration especially on. the LAMP stack (Linux, Apache, MySQL & PHP).

Have a look at what I'm working on now!
© 2012 Jasny · web development Suffusion theme by Sayontan Sinha