Tech Insight !

Technical blog on ASP.Net, PHP, Web Development, Web hosting , Database Programming
Home » Archive by category 'Uncategorized'

PHP $_SERVER and $HTTP_SERVER_VARS

April 11th, 2011 Posted in PHP, Uncategorized

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these.

$HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)

$_SERVER ['PHP_SELF']

The filename of the currently executing script, relative to the document root.
For instance, $_SERVER ['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.

$_SERVER ['argv']

Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.

$_SERVER ['argc']
Contains the number of command line parameters passed to the script (if run on the command line).

$_SERVER ['SERVER_ADDR']

The IP address of the server under which the current script is executing.

$_SERVER ['SERVER_NAME']

The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

$_SERVER ['SERVER_SOFTWARE']

Server identification string, given in the headers when responding to requests.

$_SERVER ['SERVER_PROTOCOL']

Name and revision of the information protocol via which the page was requested;
i.e. ‘HTTP/1.0′;

$_SERVER ['REQUEST_METHOD']

Which request method was used to access the page?
i.e. ‘GET’, ‘HEAD’, ‘POST’, ‘PUT’.
Note: PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.

$_SERVER ['REQUEST_TIME']

The timestamp of the start of the request.

$_SERVER ['QUERY_STRING']

The query string, if any, via which the page was accessed.

$_SERVER ['DOCUMENT_ROOT']

The document root directory under which the current script is executing, as defined in the server’s configuration file.

$_SERVER ['HTTP_ACCEPT']

Contents of the Accept: header from the current request, if there is one.

$_SERVER ['HTTP_ACCEPT_CHARSET']

Contents of the Accept-Charset: header from the current request, if there is one.
Example: ‘iso-8859-1,*, utf-8′.

$_SERVER ['HTTP_ACCEPT_ENCODING']

Contents of the Accept-Encoding: header from the current request, if there is one.
Example: ‘gzip’.

$_SERVER ['HTTP_ACCEPT_LANGUAGE']

Contents of the Accept-Language: header from the current request, if there is one.
Example: ‘en’.

$_SERVER ['HTTP_CONNECTION']

Contents of the Connection: header from the current request, if there is one.
Example: ‘Keep-Alive’.

$_SERVER ['HTTP_HOST']

Contents of the Host: header from the current request, if there is one.


$_SERVER ['HTTP_REFERER']

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

$_SERVER ['HTTP_USER_AGENT']

Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser () to tailor your page’s output to the capabilities of the user agent.

$_SERVER ['HTTPS']

Set to a non-empty value if the script was queried through the HTTPS protocol.

Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.

$_SERVER ['REMOTE_ADDR']

The IP address from which the user is viewing the current page.

$_SERVER ['REMOTE_HOST']

The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user.

Note: Your web server must be configured to create this variable. For example in Apache you’ll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr ().

$_SERVER ['REMOTE_PORT']

The port being used on the user’s machine to communicate with the web server.

$_SERVER ['SCRIPT_FILENAME']

The absolute pathname of the currently executing script.

$_SERVER ['SERVER_ADMIN']

The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.

$_SERVER ['SERVER_PORT']

The port on the server machine being used by the web server for communication.
For default setups, this will be ‘80′. Using SSL, for instance, will change this to whatever your defined secure HTTP port is.

$_SERVER ['SERVER_SIGNATURE']

String containing the server version and virtual host name which are added to server-generated pages, if enabled.

$_SERVER ['PATH_TRANSLATED']

File system- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

$_SERVER ['SCRIPT_NAME']

Contains the current script’s path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

$_SERVER ['REQUEST_URI']

The URI which was given in order to access this page.
For instance, ‘/index.html’.

$_SERVER ['PHP_AUTH_DIGEST']

When running under Apache as module doing Digest HTTP authentication this variable is set to the ‘Authorization’ header sent by the client (which you should then use to make the appropriate validation).

$_SERVER ['PHP_AUTH_USER']

This variable is set to the username provided by the user.

$_SERVER ['PHP_AUTH_PW']

This variable is set to the password provided by the user.

$_SERVER ['AUTH_TYPE']

This variable is set to the authentication type.


NOTE : Also visit www.dhanashree.com


If you are in need of any
Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development,
Website designing
, Open Source customisation. Dhanashree Inc can be our offshore development company /
outsourcing web development company, hire dedicated web programmers.


Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.

how to import mysql dump to database-import mysql dumps

December 22nd, 2010 Posted in MySQL, PHP, Uncategorized Tags: ,

If you wanted to import large mysql dump file to database.

See below for how to import mysql dump using only one file.

Step 1: Download dump file. (e.g. demodb.sql).
Step 2: Change connection, username, password, database variable values.
Step 3: Change dump file name with proper path.
Step 4: Run this page.

Import mysql dump file code.

+++++++++++++++++++++++++++++++++++++++++++++++++++++

<?php

$host =”Your Host”;              // Change host (e.g localhost)
$dbusername =”Database username”; // Change Database Username
$dbpassword =”Database password”; // Change Database Password
$database =”Your database”;        // Change Database
$dumpfile = “Your Dump file”;        // Set dump file path (e.g. demodb.sql)
mysql_connect($host,$dbusername,$dbpassword);
mysql_select_db($dumpfile);
$file = fopen($dumpfile, ‘r’);
print ‘<pre>’;
print mysql_error();
$temp = ”;
$count = 0;

while($line = fgets($file)) {
if ((substr($line, 0, 2) != ‘–’) && (substr($line, 0, 2) != ‘/*’) && strlen($line) > 1) {
$last = trim(substr($line, -2, 1));
$temp .= trim(substr($line, 0, -1));
if ($last == ‘;’) {
mysql_query($temp);
$count++;
$temp = ”;
}
}
}

echo mysql_error();
echo “Total {$count} queries fire(s).\n”;
echo “Enjoing this fastest mysql dump importer..\n”;
echo ‘</pre>’;

?>

+++++++++++++++++++++++++++++++++++++++++++++++++++++

Enjoying this fastest mysql dump importer.


NOTE : Also visit www.dhanashree.com


If you are in need of any
Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development,
Website designing
, Open Source customisation. Dhanashree Inc can be our offshore development company /
outsourcing web development company, hire dedicated web programmers.


Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.

Communication – A developer point of view

July 15th, 2010 Posted in Communication, Management, Uncategorized

Introduction:

By definition communication means: “It is the process of passing information and understanding from one person to another. It is essentially a bridge of meaning between people. By using the bridge of meaning, a person can safely cross the river of misunderstanding that separates all the people.

History of communication says that it comes from a Latin word: “communicare”, which as three meaning imminent from it:

  • “To make common”, which is probably can be derived from 2 or 3.
  • “Cum + munus”, its like having a gift to share in mutual donation.
  • Building together a defence.

From the developer point of view (I hope reader is somewhere involved programming J ), communication is real important factor to improvise one’s potentiality. A good leader has to be a good communicator. It’s not so that communication skills means the way you talk, the way you present your idea to others. Communication skill involves many other areas. Like: Verbal communication, Non verbal communication, written communication, Gesture communication etc.

All these are nuts & bolts for being a good communicator.

Communication makes you perfect in demonstrating your ideas to front end people. Let’s take few examples that give you glimpse why communication skill is so important for a developer/leader.

  1. Think what if you are a technical leader and your client has given you a task. You are supposed to present him technical feasibility report or say you wanted to explain him/her flow of your system. If you are not have a good command over your English, collections vocabulary, you are not used to prepare & utilize MS word, then?
  2. In number of different occasions, we as developer/leader need to talk with different users. These users may be end users of system, stack holders, clients who have given as project to work on. Different people have different emotions and different style of communication. In these cases, you need to communicate in a balanced view.
  3. When I was a fresher, digging into the word of programming. We were instructed that when any CRUD operation is performed, you need to show users a message that operation successfully completed. When in an application someone create a PO from their site, I say them “operation successfully completed.” But what operation?
    J

Well, there are many many many other points that can be put here in list, but in that case you may avoid to read my article. And I don’t want to make that happen
J.

So let’s take a took some important characteristics of a good communication.

  1. It’s a two way process – It’s quite understandable. In any communication system there are two parties involved. One is
    Transmitter another is receiver. Overall motto of communication is to delivery your message to other parties. It may be comprising of debate, discussion etc.
  2. It’s continuous process – Communication process continues to the extent that ideas and messages are communicated and received. Like for e.g. if we are at system analysis stage for any project. Continues discussion is very important. As a analyst, we have to be in contact with stack holder to understand their requirement. We have to identify end user who is going to use the software/application.
  3. It can be in formal way or informal way, though it may be in different medium.

Elements of communication

Why communication is so important for us? It is important because….

  1. Making enterprise run smoothly.
  2. Quick decision and implementation.
  3. Project planning & coordination.
  4. Maximizing productivity.
  5. Morale building/Motivation tool and developing your democratic leadership style.

Properly recorded communication documents, system analysis docs., technical specification, ER diagrams, these are the documents that we generally prepare so that it make ease for any new comer in organization to get settle with his project. This makes organization to run smooth.

Moreover, properly maintained documents allow you to make quick discussion in hurry.

For proper co-ordination and maintenance, developer can utilize different project management tools. To name few here are some of them.

  1. www.mantisbt.org – MantisBT is a popular free web-based bug tracking system.
  2. Basecamp
  3. Central Desktop
  4. 5pm

You can get more information for such tools from this article.

http://tomuse.com/top-10-best-free-online-project-management-application-services/

There are different kinds of communication methods. Like…

  • Verbal or oral communication
  • Written communication
  • Formal communication, informal communication

Developers are used to choose from these methods according to availability of resources and situation. Mostly verbal or written communication is widely popular among us. Formal communication has special delegation of authority, which means a project leader has given sufficient rights to make certain decision without asking to their superiors. Where in informal communication, there is no authority defined. It is conveyed by simple gesture, glance, smile, silence.

Effective communication

  1. While you are in presentation, instructing to group of developers, doing video conferencing with other peers on remote location, Clarity of Thoughts
    is really important.
  2. Something just can’t be explained by words. You have to react with your body. It is important to attach importance to actions rather than words.
  3. Participation – as said earlier, it’s a two way process which require involvement of all the parties. If you are not involved mentally in communication process, you are not going to perform your task well. Your presence is must. If your leader informed you about coding standard to be maintained, and if you don’t remember those, you will in trouble.
  4. What to communicate? – Prepare the agenda that you need to talk about before you initiate. Collect all the required documents, technical specifications, proof reports, different analysis report before you talk with your superior or clients.
  5. When to communicate? – Mutually decide timing with your parties involved in. You can either initiate or let your parties to initiate and decide when to communicate. You can place meeting request in outlook, send them emails, take care of geographical difference in timing, ask for the availability and long will be the meeting etc.
  6. How to communicate? – Choose the medium that you want to communicate through. If discussion matter to be explained to a technical person, chat or peer to peer method can be best suited. If talking with non technical person, you have to represent your ideas to your parties in such a way that he can understand your thoughts. You may explain them using different diagrams, preparing documents and go through documents while you discuss, giving them references about what are trying to demonstrate him. There are no. of collaboration tools are there in market which you can use for this purpose. Like we have google wave, Webex, Skype voice chat, video conferencing through different tools etc.
  7. How often to communicate? – As I said that it’s a continuous process. You can’t make sure that having discussion for 5-6 hours, you will come out with your objective. It’s an iterative process. You should try to divide your agenda into groups. Discuss them at different time interval. Make all agenda clear step by step. Try to identify issues relating to each other and communicate them as well.
  8. What is the objective of communication? – It is almost similar to identifying communication goal/agenda. But the objective of communication here is in the term of what is the outcome we are expecting to come from it. When project is running out of time, meeting by team leader is to motivate developers to encourage them to get it done at right time.
  9. Keep the channel alive
  10. Cordial superior – Once finished communication, it should be conveyed to your superior that what was the outcome? What where the agenda? What are clients new requirements? What do you suggest for different points to client? How was the response from client etc.
  11. Get the feedback – Generally when you dial in to customer care of your cellular provider, right after you finish your talk with them, you receive message regarding feedback for the person you talked with. This is the process of evaluation. It’s not to make garbage employees collection. It’s about gathering customer’s response how they like customer care person to be behaved. So gathering those feedback we can evaluate and enhance process.

To make such effective communication, what should you do? Or what should you have? Here is answer for you.

  • Develop a positive attitude.
  • Bad feelings should not hamper discussion – Human is social animal. Different people have different mentality. All have different approach to grow and perform tasks. When we are working in organization, we work in a team. It is sometime obvious that different group member have conflict with other peers. When working as team, it is must that team show their team effort rather than individuals. So your bad feeling with others should not hinder communication.
  • Use logic to manage difficult situations
  • Develop Harmonious interpersonal relationships. It is secret of business relationship.

And for effective oral communication, you should have..

  • Understanding and use of appropriate language.
  • Organize and sequence of thoughts properly.
  • Vocabulary power.
  • Command over illustrations, examples.
  • Proper pronunciation.
  • Proper use of sound system/equipments.
  • Listening ability.
  • Effective telephonic talk.

And for written communication….

  • Command over the language.
  • Word power and spelling.
  • Correct grammar.
  • Proper structuring of the written message
  • Use of appropriate channels like courier, e-mail, etc.
  • Attention to hand writing, typing, printing.

And for non verbal communication….

  • Observation skills.
  • Awareness about the body movement.
  • Proper interpretation of the non-verbal message.

Well no system is perfect in the world. There is always barrier in everything we do. Effective communication itself has its own. It is said that 30% communication the word are failed to success due to loss in transmission. Inaccurate translation, false impression, fear, noise etc. are the elements as barrier of communication. Though I am not going to tell you all here J.

So here I would like to conclude my article, hope I covered all skills of written communication in my article J. I also hope that I am able to convey to my message.

So see you next time till then happy communication & happy programming…

Cheers..


NOTE : Also visit www.dhanashree.com


If you are in need of any
Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development,
Website designing
, Open Source customisation. Dhanashree Inc can be our offshore development company /
outsourcing web development company, hire dedicated web programmers.


Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.