Code, Explained

ABC on Internet

Introduction

The modern life is very much dependent on communicating with each other. How can we communicate with each other? Various media, like – Sending Mail through Post Office, Sending Message through Messenger, Say Hello by Land Phone or Mobile etc. At the ancient time we communicate each other with Pigeon or Messenger. But in the modern life we like to take advantages of digital technology. Internet is such a digital technology of modern life.

Elaboration of this Internet is “International Networking”. It’s a big network where computers are attached with each other all over the world. We know that, computer can attach with each other and can talk with each other, can share file with each other, can share music, can share video with each other. So, all the computer of the world is inter connecting with each other and makes a big network that virtually act as a big computer for a world. We don’t need to know how they communicate with each other. We just need to know how we can reach other computer that is outside of your computer or outside of your country. So, we can reach our friend’s computer easily to communicate with her.

Cyber café is such a place where you can use computer by paying money. Here all computers are pre-connected with internet. So, you don’t need to connect them. You need not to know how they connected, how a computer can open etc. You just need to know how you can use internet. You need to know a very basic knowledge about keyboard, mouse & monitor. Are you know, how a light is lighten by passing electricity? You just need to know where the switch to on that light is. How this switch is operated? And use this light by switch on. Internet is easy like switch on a light of your room.
Now the things you need to know for switching internet communication, is – Browser, Website, Email Address, Checking & Sending Mail, Searching or Surfing Internet for Information etc.

So, what about operating procedure of a computer? Nothing, we need not to know! Well, let me explain. When we were 2 years old, are we know about all the stuff of our room? No, not at all. But, we recognized the toy by which we can play.

About Browser & About Form

Now the most important part to use internet is browser. I like to compare browser as our “Table”. Where we can put our book for reading. It’s such a place where we can put our writing pad on it and write. So, it’s a workstation where we do our regular duties, isn’t it?

Now, what is the category of the table? Is it furniture? Yes, its furniture. In computer we can categorize “Browser” as program. If we think a computer like our room, then browser is a type of furniture like table.

Now, we already hear a word “website”. What does a website means? Website is such a place where certain information is written and can access from anywhere of the world through internet. Now, what types of information are written to the website? It’s may be the details of a product, about a place, any instruction etc. Well, let’s consider an example. Someone wants to know about “Sundarban”. Someone wants to know how he can reach to “Sundarban”. Now, if we can written all the information about “Sundarban” and put it a such open place from where anyone can access to that place and can read about “Sundarban” then she easily get all the answer about “Sundarban” from that place. That such place we call “website”. Now, what happen, if we can publish a book on “Sundarban”? Write all the information about “Sundarban” into that book. And keep that book on our table and read! Exactly, we compare our website as like as book. Where information is stored and people can read it by putting it on the table. It makes some sense about the relationship between browser and website, isn’t it?

Now, what about form? Form is nothing but a predefined question paper that need to collection information for a certain purpose. If you go to admit a school your parent need to fill up a form about you and your family. That form contains your name, your father’s name, mother’s name etc. etc. In that form we need to write but here at web form we need to type information by keyboard. After writing that form we need to submit it to school authority by handing over the filled up form. Here we need to submit it through a button that we call “Submit Button”. Its simple, we just need to know about the parts of the form. The main parts of a web form are – Text Box, Text Area, Select Box Multiple & Single, and Option Box Multiple & Single. No need to worry about form in this time. You will be familiar with web form while use net regularly.

About Mail Server & Storage Technique

As we already know that we have a common place where we preserve information for public access that is called server. We can store our information as webpage into server. Also we can store mail into that server.
Well, let’s consider a scenario. One of your friends wants to send a message through courier service. He will write a letter then go to courier service to post it. The courier service authority will send that letter to your friend’s city branch of that courier service. Then the postman will search you to give you that letter. If you don’t at home at that time the postman will drop it to your home. When you come to your home you will get that letter of your friend. Here server is act like as your home. All the mail is stored into server until you read it.

About User ID & Password

I’m trying to make you understood with some real life example. It will help the issue to understand easily. Now think you admitted into a new school and meet with your new friend. There you found that there has another friend who has the same name of you. Suppose your name “Mithila” now what other identified you? Its simple, they make a new name of you like “New Mithila” or something else. And it’s your identity at your school. In server the unique name is called “User ID”.

Now what is password? It simple, it’s a secret phrases that only known by you! Now why you need password? Basically computers don’t know you. It’s a machine. So if your friend claims that her name is “Mithila” then what happen? Cause you and your friend Mithila are using same computer. So you need a secret word or code to claim your uniqueness, isn’t it? That’s password need.

Mail Header / Parts of Mail Message

Mail header is the information about mail. You all know about traditional letter. In that letter you will find from whom you receive that letter and when you received that letter. This is called the information about letter. As like as every email have this information. We called those information as “Mail Header”.

Now what about a gift? Suppose your elder brother send a nice gift like a “Barbie Doll” to you. What you think, isn’t it nice? Your elder brother may send that gift and write a letter to you. Now what is the scenario? You getting letter with a gift. Here in electronics system we have same approach. Suppose we need to send a song with a letter. What can we do? We just need to attach that song with that email. And that is called “Attachment”. It’s also a part of email.

Now you have two another term of email header, they are – CC & BCC. CC means Carbon Copy. You all know about carbon. When we need a document more then one copy for preserving purpose or another purpose we use this carbon to copy it. In the modern technology we can photocopy that document as much as we need. So, what about CC? When you need to send your same mail to many of your friend then you need to use this option. Suppose you want to send “Eid Greetings” to your entire friends. What you will do? You will type your message and send to a friend. For another friend you need to type again and send it to that friend. May be you can copy the message text for sending the same message. But with CC option you can send the same mail to as many as you can. Just type the friends email address separated with comma and send it. It simple! Now what about BCC? You don’t need to use this BCC option now. Its elaboration is Broadcasting Carbon Copy. Its same as CC but with little functioning difference. You can use it as CC. You will learn it by using I think.

About Yahoo Profile, Yahoo Mail Account & Address Book

Yahoo profile is a profile that keeping by Yahoo. Information about you is kept by Yahoo called Yahoo Profile. In the profile it contain your name, from where you from, from where you surfing or accessing the site etc.

Yahoo Mail Account is a space where your mail stored. If someone sent you mail the mail will stored into that area until you read it. You can also store it permanently in to this account. It’s also an identification to reach you or to send you email.

Address Book is the register of email address. In this book you can save your friends email address for future use.

About Search Engine

Search engine is a special site where you can find the address of your desire word. Suppose you want to know about “123 Sisimpur”, but you don’t know where you can get information. So, first of all you need to search the address related on “123 Sisimpur” then you can go to that website to get the information about “123 Sisimpur”. From which you get the address by searching them we called it search engine. Those search engines is maintain the name of all other website. The search engine will provide the list of website that is related with your keyword. You need to put your keyword into specific text box to search. After getting the list you can easily find out your desired website.

Conclusion

Internet is easy to use & very cheap communication facilities with each other. But its global. The main fact of internet defend our real life is, if we have a permanent address we can use it to get any letter from our friend. But when we are on travel, then how can we get those letters instantly? But with email address we can get mail from anywhere anytime.

Disclaimer:

This article is written for a primary concept on internet who have no idea about internet. Basically I’m trying to establish a relationship between our real lives with internet. Internet is a vast subject. It’s not possible to give a greater knowledge at the very first time.

by-

| Md. Shahadat Hossain Khan
|
Web Developer, Square InformatiX Ltd.

Posted in internet, study, webdevelopmentTagged , , , , , , , , , , , , , , , , , , , , , ,

Prepare USB printer for print through DOS based program like FoxPro

DOS based applications like FoxPro doesn’t detect an USB printer. One way of directing output to USB is by using “net use” at command line

We will use a little trick to work out. We fist share our printer with a share name within 8 digit name. Cause DOS didn’t support more then 8 characters. Then we will use above command. But we need to ensure that we will use text print only.

Now follow these instructions…

  • Share your USB printer and give its name at printer share name
  • Open the printer properties, select ADVANCE tab select “Print Processor” select TEXT and save the change
  • Now use “net use” command
    e.g. NET USE LPT1 \\<computer name>\<printer share name> /persistent:yes

At the command prompt type “DIR >PRN” this must give you print from USB printer, then try printing from your application.

That’s all folk. Now you can write a small batch file to active the printer every time before you go to FoxPro or any other DOS program

Posted in foxpro, windowsTagged , , , , , ,

Apache (httpd) 403 errors & SELinux in RHLE5

The “targeted” policy confines certain network daemons to run in their own specific “security domain”. These daemons include dhcpd, httpd (apache), named, nscd, ntpd, portmap, snmpd, squid, and syslogd.

When I setup apache on a system where it wil be utilized, I have a habit of not using /var/www/html as my starting point for document roots, but rather create a dir at /home/websites and place my document roots in there. In the good ol’ days of Discretionary Access Controls (DAC) just making sure that apache had the perms it needed to read the documents in there was enough (using chmod, chown, and the like).

Not so with SELinux enabled. In addition to the regular DAC we’re all used to, we now have Mandatory Access Controls (MAC) that define security contexts for files/directories etc. Turns out it looks like by default, apache only has access to /var/www/html when it’s fired up…. I’m guessing that and probably /var/log/httpd (which is exactly as it should be). To enable apache to view my files in /home/websites, I had to apply a new security context to these files. The answer to this is the chcon command. To be brief, the full command I executed was:

chcon -R -t httpd_sys_content_t /home/websites

After executing this, apache could read my files.

I like where this SELinux thing is going. Permissions done right, for sure. This doesn’t come with out growing pains though. It’s complex (or so it seems to me after only working with it for a couple days) and will take some time to learn. I’m prepared for some frustration….

Now many of you are probably asking yourself why would anyone (let alone me) want to bother with this? Well I think a simple example of one of the cool things is that even though something like /etc/passwd has DAC octal perms of 644 (rw-r–r–), apache still can’t read it because that file is not with in apache’s security context. So any users on your system can’t write a little script that reads your /etc/passwd file and basically posts it on a web page for the world to see (giving potential crackers a list of valid user accounts on the system).

Actually this is a little bit extra security that provide by SELinux e.g. Security Enhanced!

Ohh, one more tips to change the direcotry live…

chcon --reference=/var/www <your website directory>
chcon --reference=/var/www/html <your public_html directory>

I suggest you to make a shell script to put it together… with following commands…

useradd <your website user name> #password and other necessary staff to point home directory
chmod --reference=/var/www /home/<your website user name>
mkdir /home/<your website user name>/public_html
# most probably the following line need not to execute
chmod --reference=/var/www/html /home/<your website user name>/public_html
# then do other necessary staff for your website suppose add virtual host, ftp user, database user etc.

nJoy…

Posted in linuxTagged , , , , , , , , , 2 Comments on Apache (httpd) 403 errors & SELinux in RHLE5

scope into smarty template

i’m very much fan of smarty templating. though it has many draw back but it tiny and strait froward for a small project. for smarty the varaible scope within template is very much complex. you cannot change a variable value from outside of the template.

let me explain the senario…

suppose i have a base template. named “main.tpl”

<html>
<head><title>title of the page</title></head>
<body>
<h1>your page head</h1>
{assign var="client_cur_location" value="You are now at home page."}
{include file="products.tpl" scope="global"}
<div id="pagloc">{$client_cur_location}</div>
</body>
</html>

now your products.tpl

{assign var="client_cur_location" value="<a href=\"index.php\">Home</a> &gt;&gt; Product"}
this is product listing page.

so you need to display the current location but from your included page. its not possible by smarty engin through included page. cause included page variable scope is totally local variable. here i found a solution from php mailing list. but unfortunatly it have bug when php function array_marge is changed for PHP 5

following is the complete modified, tested and working code…

/* Smarty_Compiler.class.php [near line # 950 ~ 975] */
 function _compile_include_tag($tag_args)
 {
 $attrs = $this->_parse_attrs($tag_args);

 // ADD NEXT LINE (default value of the param scope = local).
 $scope_action = "\$this->_tpl_vars = array_merge((array)\$_smarty_tpl_vars, (array)\$GLOBALS[\"_smarty_tpl_vars_temp\"]);\n";

 $arg_list = array();

 if (empty($attrs['file'])) {
 $this->_syntax_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
 }

 foreach ($attrs as $arg_name => $arg_value) {
 if ($arg_name == 'file') {
 $include_file = $arg_value;
 continue;
 } else if ($arg_name == 'assign') {
 $assign_var = $arg_value;
 continue;
 }
 // ADD: Startin block
 else if( $arg_name == 'scope' )
 {
 $scope = @$this->_dequote($arg_value);
 if( $scope != 'local' &&
 $scope != 'parent' &&
 $scope != 'global')
 $this->_syntax_error("invalid 'scope' attribute value");
 if( $scope == 'parent' )
 $scope_action = "";
 if( $scope == 'global' )
 {
 $scope_action = "".
 "\$array_diff = array_diff( array_keys(\$this->_tpl_vars), array_keys(\$_smarty_tpl_vars) );".
 "foreach( \$array_diff as \$key=>\$value ){".
 "\$GLOBALS[\"_smarty_tpl_vars_temp\"][\$value] = \$this->_tpl_vars[\$value];\n".
 "}";
 }
 }
 // Ending block

 if (is_bool($arg_value))
 $arg_value = $arg_value ? 'true' : 'false';
 // REPLACE THIS LINE WITH THE NEXT TWO
 // $arg_list[] = "'$arg_name' => $arg_value";
 if( $arg_name != 'scope' )
 $arg_list[] = "'$arg_name' => $arg_value";

 }

 $output = '<?php ';

 if (isset($assign_var)) {
 $output .= "ob_start();\n";
 }

 $output .=
 "\$_smarty_tpl_vars = \$this->_tpl_vars;\n";

 $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
 $output .= "\$this->_smarty_include($_params);\n" .

 // REPLACE THIS LINE WITH THE NEXT ONE
 // "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
 $scope_action."\n".

 "unset(\$_smarty_tpl_vars);\n";
/*        original code
 "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
 "unset(\$_smarty_tpl_vars);\n";        */

 if (isset($assign_var)) {
 $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n";
 }

 $output .= ' ?>';

 return $output;

 }

The value accepted for the *scope* param are: global|parent|local.
default value is *local*.

please add your valuable comment how can we improve our scope usability into our code.

please note, above php code originally is not mine. i just modified and fix the bug.

Posted in php, smarty, study, webdevelopmentTagged , , , , ,