Technical paper on a possible generic PHP based system

This article is for personal reference. Its creation became necessary while pondering on a certain subject, I realized my brains (as with all brains being limited to a maximum of 7+2 variables simultaneously) could not handle all the required variables at once and was therefore unable to see clearly a coherent big picture of the envisioned idea.

Hopefully in creating this technical paper could it be made visible to me any possible design flaws when I examine each part in detail.

The goal is to create a system/framework that does the following

1. Accept many user created xml documents each describing different reptitive tasks that happens in a company in XML.
2. A XML document will contain:
2.1 All fields that exist and their data type
2.2 All stages that exist and their order
2.3 Fields and Stages mapping, access permission to fields available in each stage
2.4 Each stage will provide views of the object defined in the XML document
3. Instantiates an object that holds all that is in the corresponding XML document declared as properties
4. Assign system users as personel in charge of each xml defined stage as this is not captured in the XMl document to keep XML document system independent
5. Serialize this object and store it as a record in the template database table.
6. When Template Manager Object is triggered, it retrieves this template object from the template database table and replicates a working instance which will be then stored in the object database table
7. Has a work manager object which handles the manipulation of data stored within working instance objects.
8. Has a work manager object which handles the synchronization of serialized records in the object database table and the instantiated deserialized records in the system SESSION.
9. Ideally the work manager object will have built in features that will handle concurrency issues.
10. Data types defined in the XML document as part of object property will automatically instantiate existing native classes already included in the System
11. Data types will extend a parent data type which will provide methods which child data types will have to declare. Possible methods envisioned includes
11.1 Display
11.2 Edit
11.3 Store

Potential advantages of what I have envisioned thus far.
1. Database table structure will be independent of the object structure
2. Database structure will effectively be just reduced to two tables irregardless of the variety of object structure.
2.1 template table
2.1.1 field : id -> primary key
2.1.2 field : data -> serialized object
2.2 object table
2.2.1 field : id -> primary key
2.2.2 field : data -> serialized object

3. Framework remains sufficient abstract and can be easily ported from system to system

Potential down side of what I have envisioned thus far.
1. All objects instance in the object table will be loaded into SESSION during each call. This might impose a high load on the database server during the initial loading.
2. It might be difficult to sort or do a search amongst a collection of the same objects as compared to sorting available in traditional SQL search queries.
3. Synchronization issues might arise.
4. Possible out of memory error as more object instance comes into existance.

My next step from here will be to research into design patterns to examine the possible patterns that I could apply on this framework to address issues 2 & 3.

I will also need to look into the PHP documentation to understand the factors that will cause issues 1 & 4

Learning how to use Ektron CMS

Browsing through the Ektron manuals as well as watching all the videos on YouTube does help alot with the picking up of Ektron CMS.

Today I finally created a template page and registered it as a template in the EKTRON CMS. I am currently using it as a sandbox within which I test all the user controls that come along with the Ektron CMS.

It applied a templated to my page called test by first including it as an option in my Content Folder which holds my content object

I then assigned the template to my content object.

Thereafter I went to the command prompt and inserted the command IISRESET. This forced the Ektron CMS to clear off its cache and create a new one. Thus my changes are updated nicely.

Strangely, even though I haven’t programmed in C# for quite a few years already I could understand up to 80% of the syntax used. The main part that I found to be tedious at tackling was its convention. There is the aspx file, the aspx.cs file (if you are using C#)

within the aspx file itself there seem to be a few lines at the top registering some assemblies the source of which I have no idea where from.

As compared to typical open source technologies like PHP, this is mainly the downside of Proprietory technologies like ASP.net. PHP being open allows you to investigate through all the codes that were used in the implementation of a system. Try investigating the source of where a function came from in ASP.net and sooner or later you will hit a wall. The function was compiled and hidden within a DLL file of which location you have no idea where. Ouch!

Restoring an MOSS site

Given an MOSS bak file which looks something like blahblah.DAT. You will need to do the  following to install it on your MOSS installation.

First you will need to go to your MOSS Central Administration Page and create a site collection. For example

http://localhost/sites/test_site_collection

of you could simply go to

C:\program files\common files\microsoft\shared\web server extensions\12\bin

and type the following

STSADM.EXE -o createsite -url <url-to-site-collection> -ownerlogin domain\user -owneremail <email-address>

Next you will need to navigate to the following location using command prompt

C:\program files\common files\microsoft\shared\web server extensions\12\bin

Once you are here type in the following command

explorer .

This command will open this location and you can copy your blahblah.DAT file here via copy and paste.

Next go back to your command prompt you can type in the following command

stsadmin -o restore – url http://localhost/sites/test_site_collection -filename blahblah.DAT -overwrite

Click enter when you are done.

To see the restored sitetype

iexplore http://localhost/sites/test_site_collection

Upgrading MOSS server to use Active Directory

I recently upgraded one of my Virtual PC windows 2003 servers to use Active Directory. The very first thing that happened after the upgrading was done was that I encountered tons of errors. Apparently the Active Directory installation process by windows did not automatically update the logon details to services. Hence as a result MOSS which relies on quite a lot of these services to funciton properly was pretty crippled. The first thing I did was to open the service dialogue box and change the logon details for the following services

  1. Windows Sharepoint services administration
  2. Windows SharePoint Services Search
  3. Windows SharePoint Services Timer
  4. Windows SharePoint Services Tracing
  5. Windows SharePoint Services VSS Writer
  6. SQL Server 2005 Embedded Edition (Microsoft##SSEE)
  7. SQL Server VSS Writer

Apparently MOSS uses an embedded SQL server to store all its configuration as well as Web instances

Next I had to do some configuration at the following location

Start > Administration Tools > Component Services > Double Click to Open

Console Root > Component Services > My Computer > Right Click to Open Dialogue Box > Open Properties

Navigate to Tab > MSDTC and then click on the Security Configuration button

Basically in that view click on all checkboxs and then indicate No Authentication Required

Once you click  ok the MSDTC service will restart itself.

With that done, there is only one last thing to do.

Go To Location C:\Windows\ right click on the Temp folder, click properties and then navigate to the Security Tab

Even thought I have added Administrator and ASP.Net as the users with full control of this folder it seems it is still causing problems with some MOSS services, so I have instead given full control to Authenticated Users as well.

Please note while all these configurations ensure that your sharepoint services gets up and running, it is not all together secured because of the lax security rules. If you really need help please hire a MOSS professional

Windows 2003 Server on VPC cannot connect to the internet

One of the major problems on using operating Systems on VPC is the hardware detection problem. I tried running my Windows 2003 server on VPC with Windows XP as the host.

I tried connecting to the internet with it but it does not work. I configured the VPC to use my Windows XP Host Ethernet Adapter but still not signals.

Realizing that the issue might be on the Virtual OS. I did an ipconfig to check the details. True enough what I saw was that the Virtual OS could not detect the Local DNS server.

To solve the problem I configured my virtual OS ethernet adapter manually. I did this by specifying the default gateway as well as the DNS address.

Eureka. It worked nicely.  I could now connect to the internet with my VPC.

Making mod_rewrite work for Apache server on Windows XP

Last year I set up an Apache 2.2 server on my computer to do some developement work using EzPublish in multiple virtual host environment. One day, I happened to raise a question to Steven on how to get it configured so that mod_rewrite works on my server and I could debug my script locally instead of always having to test it on some remote server. I got the response from him that it does not work in Windows environment. Due to the fact that this particular feature was not critical to the whole operation, I left it as that.

Two days ago out of curiosity, I downloaded this new PHP social networking software called ElGG . Apparently it uses mod_rewrite extensively and provides no other alternative methods to access its function. I was thus forced into a corner. Hence I did what I did. I went to google.com and started researching. Interestingly, I read that some actually got mod_rewrite working on Apache server running on Windows XP.

I spent the next two days researching on the Apache architecture. The result I got was this assuming you already have multiple virtual host setup:

  1. uncomment LoadModule rewrite_module modules/mod_rewrite.so in your httpd.conf file
  2. add the following lines to your vhost.conf files

    <Directory “…”>
    #Tells your Apache webserver to detect for the .htaccess file in your directory
    AllowOverride All
    </Directory>

  3. The below was copied lock stock and barrel from Joomla. Copy and paste it into a .htaccess file on your webserver and place it at the root location

    ##
    # @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
    # @package Joomla
    # @copyright Copyright (C) 2005 – 2008 Open Source Matters. All rights reserved.
    # @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    # Joomla! is Free Software
    ##

    #####################################################
    #  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
    #
    # The line just below this section: ‘Options +FollowSymLinks’ may cause problems
    # with some server configurations.  It is required for use of mod_rewrite, but may already
    # be set by your server administrator in a way that dissallows changing it in
    # your .htaccess file.  If using it causes your server to error out, comment it out (add # to
    # beginning of line), reload your site in your browser and test your sef url’s.  If they work,
    # it has been set by your server administrator and you do not need it set here.
    #
    #####################################################

    ##  Can be commented out if causes errors, see notes above.
    Options +FollowSymLinks

    #
    #  mod_rewrite in use

    RewriteEngine On

    ########## Begin – Rewrite rules to block out some common exploits
    ## If you experience problems on your site block out the operations listed below
    ## This attempts to block the most common type of exploit `attempts` to Joomla!
    #
    # Block out any script trying to set a mosConfig value through the URL
    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
    # Block out any script trying to base64_encode crap to send via URL
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
    # Block out any script that includes a <script> tag in URL
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    # Block out any script trying to set a PHP GLOBALS variable via URL
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    # Block out any script trying to modify a _REQUEST variable via URL
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    # Send all blocked request to homepage with 403 Forbidden error!
    RewriteRule ^(.*)$ index.php [F,L]
    #
    ########## End – Rewrite rules to block out some common exploits

    #  Uncomment following line if your webserver’s URL
    #  is not directly related to physical file paths.
    #  Update Your Joomla! Directory (just / for root)

    # RewriteBase /

    ########## Begin – Joomla! core SEF Section
    #
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
    RewriteRule (.*) index.php
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    #
    ########## End – Joomla! core SEF Section

If you are still having problems after all these steps contact me. I will help set it up for your nicely. 🙂

Using statcounter.com concurrently with Google Analytics

These two days I got really puzzled with Google Adsense. My page impressions were really high but apparently no clicks were registered on my page for the adsense. I wonder what went wrong. So ended up I started researching over the internet about Google Adsense click not registered. This was when I chanced upon this new tool called statcounter.com

This is a real time tool that shows you where visitors came into the site from and where they exited the site to. One of the really useful things about this is the fact that they could help track if someone actually clicked on the links in your adsense. This does provide a counter as to whether Google Adsense if just simply faking your click rates.

I would not have changed upon this site had I not found my adsense revenue to be suspiciously non-existant

Improving the performance of Ajax on ThingsToDoSingapore.com

Recently I started working on Things To Do Singapore again.

Apparently the javascript libraries were getting quite thick and this was affecting the loading of the interface.

There is the use of the following :

  1. Xajax Library
  2. Jquery Library
  3. Google friends Connect Api
  4. Facebook Connect Api
  5. SWFUpload Library

After much observation I realised the SWFUpload Library sometimes takes too long to load and fails as well causing the whole interface to fail loading at time seriously affecting usability of the site. Perhaps this might be to cause of the high bounce rate I observer from my Google Analytics of 80%.

I spent this morning thinking how to go about solving this problem and this was the method I came to

Javascript library should be classify into two groups as critical and non-critical to user experience.

The Xajax Library, jQuery library are considered critical to user experience

The Google Friends Connect library as well as the Facebook Connect library are not often employed. though these two library are too tightly integrated with the core achitecture. Perhaps it was a bad design choice.

SWFUpload is not often used by other users and hence rarely employed.

Having done the proper classification, I next work  on loading the SWFUpload asynchronously after the other library and interface has loaded. This in face drastically reduced improved useer experience. It reduced user waiting time as well as at the same time reduced the error rate of the loading interface.

This was how I did it.

jQuery(document).ready(function() {

loadScript(“http://thingstodosingapore.com/swfupload/swfupload.js”);
loadScript(“http://thingstodosingapore.com/swfupload/swfupload.queue.js”);
loadScript(“http://thingstodosingapore.com/swfupload/fileprogress.js”);
loadScript(“http://thingstodosingapore.com/swfupload/handlers.js”);
//alert(“swf loaded”);
});

function loadScript(sScriptSrc) {
var oHead = document.getElementById(‘head’);
var oScript = document.createElement(‘script’);
oScript.type = ‘text/javascript’;
oScript.src = sScriptSrc;
oHead.appendChild(oScript);
}

Picking up Photoshop on the Run – YouTube

Recently I started using Photoshop intensively. More and more a need is there to do so in order to keep cost low.

Thankfully one night while having supper with Pasha, he unknowingly commented on how photoshop tutorials were so easily available over YouTube. What he said was totally true. You could just pretty much go about learning any aspects of a software you want to pick up over YouTube nowadays. No longer do you have to read through lines of ambiguous written instructions to understand what the hell is going on.