Tuesday, August 19, 2008

The World Wide Web (WWW) is not qualified as a distributed system

1.0 Introduction

This position paper mainly considers on the topic given above, which was supported by Tanenbaum and Van Steen where they have stated that World Wide Web is not qualified as a distributed system. And also this paper will depict the background information on WWW and distributed system and the counterclaims and arguments that will differentiate one and another. Lots of resources through out the web have shown out that WWW is a part of the Internet with flexible user interfaces and hyperlinks for easy navigation.

In some websites the web is pointed out as a vast distributed file system rather than a distributed computing system. Tanenbaum (2002, p.2) states that “A distributed system is a collection of independent computers that appear to the users of the system as a single computer”. So in the next section you will be taken through with more information on both the technologies. For user information, this article illustrates on both sides of the above topic and finally sum up with supporting facts that will help to make a decision.

2.0 Background Information

2.1 World Wide Web

The World Wide Web is considered as a major service over the Internet. This is achieved through connections of several web servers that contain with web pages. The heart of the web technology is the hyperlink which connects each document to each other. These web pages are accessible through web browser applications.

The Web represents the application of hypertext technology and a graphical interface to the Internet to retrieve information that is contained in specially formatted documents that may reside in the same computer or be distributed across many computers around the world. In this scenario servers that are networked, link together by a common protocol allowing access to vast amount of resources. This technology keeps on evolving whereas this uses relatively simple technologies with efficiency and growing across languages, culture and media.

2.2 Distributed System

Distributed System is known as the process of combined power of several computing devices to work together and run a single computational task in a transparent and logical way which blinds the user and appears as a single system. There are softwares which run on top of the operating system that bind all the computers together. Distributed system is more than WWW where it deals with more than a single machine.

For example, a database may exist in a system where the application will exist in another system. The user’s machine is the third machine which contains with presentation logic. All these machines are connected together and work as a single centralized machine. These systems provide the flexibility where different computers with different capabilities can be shared among users. So basically resource sharing is facilitated with these systems as well.

To be continued ....

Saturday, June 23, 2007

PHP Mailer with Attachments

Most recently I was able to write some php codes to send a mail with an attachment. The task is to get some input from the user using an html page and send a mail through the web page. This involved in file attachment as well, where it was equipped with 5 attachments but limited to 10mb. (I used the PEAR package to send the mail)

I wrote a separate page to input the mail configurations (mail_config.php) and a separate page to handle the mailing process (sendmail.php). Well, this is how it goes,

//mail_config.php
<?
// Mail sent to
$to="raji@email.com";
//The SMTP host to connect to.
$host = "mail.rajiserver.com";
//The port the SMTP server is on.
$port = 25;
//Mail account username
$username = "raji@rajimail.com";
//Mail account password
$password = "rajipassword";
//Mail from
$from = "raji@phpmail.com";?>

//sendmail.php
<?php

// --- PHP MULTIPLE MAIL ATTACHMENTs V 1.0 ---
// --- Visit Authors website at http://hotstepz.blogspot.com
// --- This Script needs PEAR package to send mails
// --- Written on : 12 June 2007
// --- All Rights Reserved ------------------------

require_once "Mail.php";
include "mail_config.php";

//This variable is to check the total size of the files added
//This works when the attaching code reads the file to attach
$tot_file_size = 0;

//Variables to send through email body, If you have something to read from
//read from a html page
//Examples
//Date and time of the mail sent
$datetime = date("F j, Y, g:i a");
$emailfrom = $_POST["email"];
$text1 = $_POST["text1"];
$text2 = $_POST["sid"];
$text3 = $_POST["service_status"];
$text4 = $_POST["text4"];
$text5 = $_POST["text5"];

//-- ---------------- HTML Table begins ---------------------

// Message HTML Format, values will be organized into a table
//was taken originally from the final product...
$message= '
<table cellspacing="0" cellpadding="8" border="0" width="400">
<tr>
<td colspan="2"><b>Service Request</b></td>
</tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>Date and Time</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$datetime.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>Email From</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$emailfrom.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>text1</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$text1.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>text2</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$text2.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"> </td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"> </td>
</tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>text3</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$text3.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>
<tr bgcolor="#eeeeee">
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>text4</strong></td>
<td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$text4.'</td>
</tr>
<tr><td colspan="2" style="padding:0px;"></td></tr>

<tr bgcolor="#eeeeee">
<td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">
<strong>text5</strong></td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$request.'</td>
</tr>

<tr><td colspan="2" style="padding:0px;"></td></tr>
</table>
';
//-- ---------------- HTML Table Ends---------------------

//Normal headers

$headers = "From: $from>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; ";
$headers .= "boundary=".$num."\r\n";
$headers .= "--$num\r\n";

// This two steps to help avoid spam

$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";

// With message

$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "".$message."\n";
$headers .= "--".$num."\n";

// Attachment headers

//Set attachment counter 0
$i=0;
for($i=0; $i < count($upfile); $i++)
{
if ($_FILES["upfile"]["name"][$i])
{
$filename=$_FILES["upfile"]["name"][$i];
$filetype=$_FILES["upfile"]["type"][$i];
$filesize=$_FILES["upfile"]["size"][$i];
//Converting the file size from bytes to megabytes
$att_file_size = round($filesize/(1024*1024));
$tot_file_size = $tot_file_size + $att_file_size ;
$filetemp=$_FILES["upfile"]["tmp_name"][$i];

//Check Uploaded File Type
//--- Specify manually the allowed file type ---
if(/*$filetype=="application/octet-stream" or */$filetype=="text/plain" or $filetype=="application/msword" or "application/pdf")
{
// MAIL HEADERS with attachments

$fp = fopen($upfile[$i], "rb");
$file = fread($fp, $upfile_size[$i]);
fclose($fp);
$file = chunk_split(base64_encode($file));
$num = md5(time());

$headers .= "--{$mime_boundary}\n" .
"Content-Type: {$upfile_type[$i]};\n" .
" name=\"{$upfile_name[$i]}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$upfile_name[$i]}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$file . "\n\n";
}
else
{
echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Incompatible file format uploaded at </font>';
$filenum = $i + 1;
echo "at File $filenum. ";
echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Mail was not sent. </font>';
}
}
}

// Check Uploaded File Size
if ($tot_file_size > 10)
{
echo "File uploads limit exceeded, Max 10MB total size allowed.
You uploaded $tot_file_size MB" ;
}
else
{
// MAIL SUBJECT
$subject = "This php email is from $emailfrom";

// SEND MAIL
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,$headers);

$smtp = Mail::factory('smtp',

array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $message);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else
{
echo("<p>Message successfully sent!</p>");
}
}

?>

I was able to send the mail successfully (using bluebottle mail service) and retrieved it in my gmail mailbox. Please leave your comments if there are any problems or errors in my code. Until next mail,

Cheers!

Friday, June 22, 2007

I'm Back

Jesus christ! would you guys believe that i was unable to log into my blogspot for sucha longtime and got access just now... tell me about the ride. Anyways I would like to start posting again. Currently my interest is in 'Grid Computing' the future technology around the world. Hope i could come up with my article soon, until then bye bye.

Saturday, October 14, 2006

Use of Interface class in Java

When we write an interface class, it should be always public. We can’t write private interface classes because there will be no use or can’t accomplish the purpose of writing it. As we know Java language supports only one inheritance of its parent class. We can’t inherit more than one class. For example,

We can write,
public class Civic extends Honda {}

We cannot write,
public class Civic extends Honda, CarAudio {}

In the above line Civic type car is created inheriting Honda class. Say, we want to use a method which resides in another class called CarAudio, which contains all the methods related to audio functions. In this case we can use an interface class called ICarAudio that contains all the methods related to audio functions, and this can be used to add the audio functions to the Civic class.

public class Civic extends Honda implements ICarAudio {}

Interface classes can be used for the purpose of multiple inheritances in Java programming language. But note an interface class should be defined with static or public scope.

Let me point of some facts about interface class.

1. interface class will contain the signature of the method without the implementation.

public void maxVol() {}

2. Any given class can inherit more than one interface, we can achieve multiple inheritance through this.

3. Any given class cannot instantiate an interface class.

4. Methods should be written public or abstract in an interface class. It doesn’t allow writing private methods.

5. Variables in an interface class should be public, static or final.

6. A class should use all the methods in an interface class if it inherits an interface class.

Above can be applied for C# also.

Cheers!

Monday, October 02, 2006

Mapping icons for documents in SharePoint document library

As a sharepoint developer, I have come across this small issue which is to have an image for the 'pdf's in the document library. As default, pdf file's image icon is not mapped with a 'pdf icon' image file, but we can do this manually.

Browse to the folder,

%SystemDrive%:\Program Files\Common Files\Microsoft Shared\web server extensions\60

First Step:
under IMAGES folder, insert the pdf icon file (basically a GIF file with 16 x 16 pixels to look consistent)

Second Step:
under XML folder, open DOCICON.XML xml file.
Insert another mapping element with variables key="pdf" and Value="pdf.gif" as shown below.

<Mapping Key="pdf" Value="pdf.gif"/>

Key is the document's extension and Value is the name of the image file.

This will simply solve the icon problem and the best thing is you can have any icon for any file type.

Try and enjoy :)

Cheers!

Starting another application using .Net code

In .Net, I came across to start an external program through scripting. This is a very simple task but should make sure that the external application has rights when it is called to run. For example, had an experience to call another console application which will be called by a web part for a web page in sharepoint. Web part is installed with InstallAssemblies program, which install it in the Global Assembly Cache (GAC) and the console application will triggger some functions when it is called by the webpart. OK, enough with the bla bla stuff and the simple line of code is,

[C#.Net]
System.Diagnostics.Process.Start(string filename,string arguments);


Cheers!

Friday, September 29, 2006

Disabling Back Button and URL Blocking

This was a hot topic for web enable application when we were doing our programming assignments for our degree (maybe when the due dates getting nearer). Students always came across this problem and were unable find a better solution. This issue came when or after a registered user logs out from the member’s area after viewing some member’s only pages, non registered users should not be able to see the restricted pages which was meant to be only for members.

What happens in a browser is as we know that all the pages viewed get cached, so later it can be viewed by anyone. This is mainly a problem when a computer is shared by many people. So to eliminate this problem we are suppose to use some kind of a mechanism to stop caching of these pages. This I am talking in java server side scripting point of view.

A solution is to insert some header tags in the html,Servlet or jsp (java server page) pages for stop caching. First we will look at the html header tags.

<!-- Forces caches to obtain a new copy of the page from the origin server -->
<meta http-equiv="Pragma" content="no cache">
<!-- Directs caches not to store the page under any circumstance -->
<meta http-equiv="Cache-Control" content="no-store">

<!-- Directs caches not to cache the page under any circumstance -->
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="expires" content="-1">


The same tags can be inserted in a java servlet page using the response object as follows.

response.setHeader("Pragma","no cache");
response.setHeader("Cache-Control","no-store");

response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires","-1");


The other solution is to have session variables to validate the user when entering a restricted page by directly typing the URL. Each page has to check the user type if there are many types of users (member, admin or moderator) who are authorized in accessing different kinds of pages which consist with different functions and for an user id. These values should be created in a successful login and stored in session variables to check them through out a session. Meanwhile intervals can be set to invalidate a session (session expire) when the session is not active for a particular moment.

First we’ll look at some servlet codes to set session variables for checking purpose.

HttpSession session = request.getSession(true); //creating a http session object
session.setAttribute("ID",""); //creating a session attribute to store the user’s id
session.setAttribute("Type",""); //another session attribute to store user type

try
{
//Authenticate the Member

if (user selection is equal to type Member)
{
*Get the password for the user’s input id and assign it to a string db_ password
if(user’s input password equals to db_ password)
{
//set session attribute ID with user’s ID
session.setAttribute("ID", **request.getParameter("ID"));
// Setting the type for security purpose - block browsing with an URL directly
//set session attribute type with user type
session.setAttribute("Type",request.getParameter("type"));
… //Any action to be performed
}
else
{
…//necessary action for the error
}
}
//End of If

else
{
... // Action for the error
} //End of Else

} //End of Try

catch(Exception e)
{

…//Action for the caught exception
} //End of Catch

* get the password through a method.
** getParameter is a method of the Request object to read a parameter.

Second, check these session variables in the restricted member’s page.

HttpSession session = request.getSession(true);
if (session.getAttribute("ID") == null)
{

... // necessary action
}
else
{
if (*String.valueOf(session.getAttribute("Type")).equals("Member"))
{
... // Rendering the page
}
else
{
... // necessary action
}
}


* Changing a session object to String type.

The same can be repeated to check the other member types too. I personally prefer to write these methods in a different class and invoke them every time using an object rather than writing in all the pages. And also I recommend write all restricted pages in jsp so that it can be used to write scripts to check the above.

Cheers!!!

Triple Menu Javascript

Populating dropdown values are always hard for me according to a chosen value for web applications. But most recently I went through a website which gave soem javascripts to build dropdowns. I'm saying hard because this involves in 3 dropdown menus. Second dropdown should populate according to the first dd's value and third according to the second.

This post post focuses only in creating triple menu and this needs a form and 3 dds. According to my script I have named form as '_form' and 3 dds accordingly 'menu','menuCat'and 'menuSubCat'. First dd should be filled with values and the script will populate the rest according to the selection.





/* ######## start of Triple menu code ############### */
function nullOptions(aMenu)
{
aMenu.options.length=0;
}

/* ########### Category starts here ########### */
/* Category for A */
function Cat1(aMenu)
{
nullOptions(aMenu);
with (aMenu){
options[0]=new Option("","");
options[1]=new Option("A.1.0","A.1.0");
options[0].selected=true
}
}
/* Category for B */
function Cat2(aMenu)
{
nullOptions(aMenu);
with (aMenu){
options[0]=new Option("","none");
options[1]=new Option("B.1.0","B.1.0");
options[2]=new Option("B.2.0","B.2.0");
options[3]=new Option("B.3.0","B.3.0");
options[0].selected=true
}
}
/* ############ Category Ends here ########### */

/* ########## Sub Category starts here ########### */

/* ########## lists of values for option 3 SubCategory:A.1.0 ######### */
function SubCat1c(aMenu)
{
nullOptions(aMenu)
with (aMenu){
options[0]=new Option("","");
options[1]=new Option("A.1.1","A.1.1");
options[0].selected=true
}
}
/* ######### end of values for option 3 SubCategory:A.1.0 ###### */

/* ########## lists of values for option 3 SubCategory:B.1.0 ########## */
// start of files for main option 3 B.1.0
function SubCat1(aMenu){
nullOptions(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("","");
options[1]=new Option("B.1.1","B.1.1");
options[0].selected=true
}
/*//Netscape likes a refresh, but Microsoft doesn't
if (navigator.appName.indexOf("Netscape")>-1)
history.go(0)*/
}
// Sub Category for B.2.0
function SubCat2(aMenu)
{
aMenu.options.length=0;
with (aMenu){
options[0]=new Option("","");
options[1]=new Option("B.2.1","B.2.1");
options[2]=new Option("B.2.2","B.2.2");
options[3]=new Option("B.2.3","B.2.3");
options[0].selected=true
}
}
// Sub Category for B.3.0
function SubCat3(aMenu)
{
aMenu.options.length=0;
with (aMenu){
options[0]=new Option("","");
options[1]=new Option("B.3.1","B.3.1");
options[2]=new Option("B.3.2","B.3.2");
options[3]=new Option("B.3.3","B.3.3");
options[0].selected=true
}
}
/* ######### end of values for option 3 SubCategory:B.1.0 ####### */

/* ########## Sub Category ends here ######### */

/* ############# change Categories ########### */
function changeCat(){
aMenu=document._form.menuCat;
aMenu2=document._form.menuSubCat;
aMenu3=document._form.menu;
with (aMenu3){
switch (selectedIndex) {

case 0:
nullOptions(aMenu)
nullOptions(aMenu2)
aMenu.options[0]=
new Option("","none")
aMenu3.options[0].selected=true;
break

case 1:
nullOptions(aMenu)
nullOptions(aMenu2)
aMenu2.options[0]=
new Option("","none")
aMenu2.options[0].selected=true;
Cat1(aMenu)
break

case 2:
nullOptions(aMenu)
nullOptions(aMenu2)
aMenu2.options[0]=
new Option("","none")
aMenu2.options[0].selected=true;
Cat2(aMenu)
break
}
}
}
/* ############ end of change Categories ################ */

/* ################ change SubCategories ############# */
function changeSubCat()
/** bookmark: starting { sign for the final } **/
{
aMenu=document._form.menuCat;
aMenu2=document._form.menuSubCat;
aMenu3=document._form.menu;

/* ######## set of values for option 3 - Sub Category for B.1.0 ###### */
if (aMenu3.selectedIndex==2)
{
with (aMenu){
switch (selectedIndex) {
case 0:
aMenu2.options.length=0;
aMenu2.options[0]=
new Option("","")
aMenu2.options[0].selected=true;
break

case 1:
SubCat1(aMenu2)
break

case 2:
SubCat2(aMenu2)
break

case 3:
SubCat3(aMenu2)
break
}
}
}

/* ######## set of values for option 3 Sub Category for A.1.0 ###### */

if (aMenu3.selectedIndex==1)
{
with (aMenu){
switch (selectedIndex) {

case 0:
aMenu2.options.length=0;
aMenu2.options[0]=
new Option("","")
aMenu2.options[0].selected=true;
break

case 1:
SubCat1c(aMenu2)
break
}
}
}

}
/* ############# end of Triplemenu code #############

For now I like to leave the exaplanation part. Will edit this post soon :).

Cheers!

Wednesday, September 27, 2006

SPS 2003 Installation Problem

We were installing SPS2003 in a freind's machine last time and came across a weird problem saying 'Service Unavailable'. Trying installing and uninstalling it over and over again, we got fedup. Ofcourse we got some solutions as a result of googling but they didn't help us at all. Strange! we had the same problem as they were saying but the workaround didn't help us at all.

The solutions were to check the credientials, specify the correct application pool, etc. We did all we could but still the answer was nope.

Finally we figured that this shows up if the operating system (Windows 2003 Server) is installed from an image. Yes! Installation and configuration is a time consuming task. IT department usually install the image file to the new machine so that the OS gets installed and ready to run in no time.

Unfortunately and sometimes, sharepoint doesn't go with this where it creates "Service Unavailable" problem. Once they installed the OS from the CD, we tried installing sharepoint again. Bingo! that worked. I still wonder whether this is sometimes or always???

For more information regarding operating system images refer Managing Your Operating Systems which was written by Douglas Steen.

Show/Hide html elements

Lot of sharepoint beginners have a problem in hiding the toolbar from the other users while rendering the page. This can be acheived by applying a style or a javascript to the element they want to hide.

The toolbar is always placed inside a column on a table. So the first method is applying a style to the column.

<!-- Column where the the toolbar is -->
<td style="display:none">


Or the second method where writing a javascript.

<script language="javascript">
document.getElementById(<column id>).style.display = 'none';
</script>


These two can apply to hide any element in a html file. But what if we want to display when its necessary or to display with a click event. For that, here goes the script;

<script language="javascript">
document.getElementById(<column id>).style.display = 'inline';
</script>


Simple isn't it? :)

Cheers!