tag:blogger.com,1999:blog-90203706518460000842024-03-05T04:29:38.691-08:00Astucesis about informatic tips & tricks astuces ms office word excel access php mysql ajax jquery css html oop advenced tutorials cours reseau top how to plugin add abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.comBlogger92125tag:blogger.com,1999:blog-9020370651846000084.post-23954302423371775392013-08-19T13:55:00.003-07:002013-08-19T13:55:56.010-07:00 PHP Tutorial<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<img alt="http://websiteexpert.com/wp-content/uploads/PHP-Development.jpg" class="decoded" src="http://websiteexpert.com/wp-content/uploads/PHP-Development.jpg" /><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><span style="color: #000099; font-family: Arial;"><big><b> </b></big></span></span></div>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><span style="color: #000099; font-family: Arial;"><big><b>Introduction</b></big></span><br />
<br />
Up until recently, scripting on the internet was something which very
few people even attempted, let alone mastered. Recently though, more and
more people have been building their own websites and scripting
languages have become more important. Because of this, scripting
languages are becomming easier to learn and PHP is one of the easiest
and most powerful yet.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>What Is PHP?</b></big></span><br />
<br />
PHP stands for Hypertext Preprocessor and is a server-side language.
This means that the script is run on your web server, not on the user's
browser, so you do not need to worry about compatibility issues. PHP is
relatively new (compared to languages such as Perl (CGI) and Java) but
is quickly becomming one of the most popular scripting languages on the
internet.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Why PHP?</b></big></span><br />
<br />
You may be wondering why you should choose PHP over other languages such
as Perl or even why you should learn a scripting language at all. I
will deal with learning scripting languages first. Learning a scripting
language, or even understanding one, can open up huge new possibilities
for your website. Although you can download pre-made scripts from sites
like Hotscripts, these will often contain advertising for the author or
will not do exactly what you want. With an understanding of a scripting
language you can easily edit these scripts to do what you want, or even
create your own scripts.<br />
<br />
Using scripts on your website allows you to add many new 'interactive'
features like feedback forms, guestbooks, message boards, counters and
even more advanced features like portal systems, content management,
advertising managers etc. With these sort of things on your website you
will find that it gives a more professional image. As well as this,
anyone wanting to work in the site development industry will find that
it is much easier to get a job if they know a scripting language.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>What Do I Need?</b></big></span><br />
<br />
As mentioned earlier, PHP is a server-side scripting language. This
means that, although your users will not need to install new software,
you web host will need to have PHP set up on their server. It should be
listed as part of your package but if you don't know if it is installed
you can find out using the first script in this tutorial. If you server
does not support PHP you can ask your web host to install it for you as
it is free to download and install. If you need a low cost web host
which supports PHP I would recommmend HostRocket.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Writing PHP</b></big></span><br />
<br />
Writing PHP on your computer is actually very simple. You don't need any
specail software, except for a text editor (like Notepad in Windows).
Run this and you are ready to write your first PHP script.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Declaring PHP</b></big></span><br />
<br />
PHP scripts are always enclosed in between two PHP tags. This tells your
server to parse the information between them as PHP. The three
different forms are as follows:<br />
<span style="color: blue; font-family: Arial;"><br />
<?<br />
PHP Code In Here<br />
?><br />
<br />
<?php<br />
PHP Code In Here<br />
php?><br />
<br />
<script language="php"><br />
PHP Code In Here<br />
</script><br />
</span><br />
All of these work in exactly the same way but in this tutorial I will be
using the first option (<? and ?>). There is no particular reason
for this, though, and you can use either of the options. You must
remember, though, to start and end your code with the same tag (you
can't start with <? and end with </script> for example).<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Your First Script</b></big></span><br />
<br />
The first PHP script you will be writing is very basic. All it will do
is print out all the information about PHP on your server. Type the
following code into your text editor:<br />
<span style="color: blue; font-family: Arial;"><br />
<?<br />
phpinfo();<br />
?><br />
</span><br />
As you can see this actually just one line of code. It is a standard PHP
function called phpinfo which will tell the server to print out a
standard table of information giving you information on the setup of the
server.<br />
<br />
One other thing you should notice in this example is th<br />
at the line ends in a semicolon. This is very important. As with many
other scripting and programming languages nearly all lines are ended
with a semicolon and if you miss it out you will get an error.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Finishing and Testing Your Script</b></big></span><br />
<br />
Now you have finished your script save it as phpinfo.php and upload it
to your server in the normal way. Now, using your browser, go the the
URL of the script. If it has worked (and if PHP is installed on your
server) you should get a huge page full of the information about PHP on
your server.<br />
<br />
If your script doesn't work and a blank page displays, you have either
mistyped your code or your server does not support this function
(although I have not yet found a server that does not). If, instead of a
page being displayed, you are prompted to download the file, PHP is not
installed on your server and you should either serach for a new web
host or ask your current host to install PHP.<br />
<br />
It is a good idea to keep this script for future reference.<br />
<br />
<span style="color: #000099; font-family: Arial;"><big><b>Part 2</b></big></span><br />
<br />
In this part I have introduced you to the basics of writing and running
PHP. By this time you should now know if your host supports PHP and
should have a basic understanding of how PHP scripts are structured. In
part 2 I will show you how to print out information to the browser.<br />
<br />
PHP 5.x is standard on <a href="http://www.ipagetraining.com/">iPage™ hosting</a> (see tutorials for website setup help), which supports the most popular PHP scripts and content management systems.</span></div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-56231298007277256912013-08-19T13:48:00.001-07:002013-08-19T13:48:23.733-07:00 A PHP Times Table Programme<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="leftMargin">
In the <a href="http://www.homeandlearn.co.uk/php/php5p1.html">previous part</a>, you saw what a For Loop was.
In this section, we'll write a times table programme to illustrate how for
loops work.<br />
There's a script called timesTable.php amongst the files you downloaded (in
the scripts folder). When loaded into the browser, it looks like this:<br />
There's a script called <b>timesTable.php</b> amongst the <a href="http://www.homeandlearn.co.uk/downloads.html">files
you downloaded</a> (in the <b>scripts</b> folder.). When loaded into the browser,
it looks like this:<br />
<div align="center">
<img alt="Times Table Programme" border="1" height="175" src="http://www.homeandlearn.co.uk/php/images/times.jpg" width="441" /></div>
</div>
<div class="leftMargin">
What we're going to do is to get the values from the textboxes and create
a Times Table proramme. When the button is clicked, the output will be something
like this:<br />
<div align="center">
<img border="1" height="366" src="http://www.homeandlearn.co.uk/php/images/times2.jpg" width="452" /></div>
In other words, when the button is clicked we'll print the Times Table to
the page. You can have a different Times Table, depending on what values you
enter in the textboxes. To make a start with the coding, move on to the next
part.<br />
</div>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-47090127064327950042013-08-19T13:47:00.002-07:002013-08-19T13:47:34.398-07:00 Some Practise with PHP If Statements<div dir="ltr" style="text-align: left;" trbidi="on">
<img alt="http://www.nusphere.com/graphics/php_smarty/php_smarty_code.png" class="shrinkToFit decoded" height="619" src="http://www.nusphere.com/graphics/php_smarty/php_smarty_code.png" width="820" />We can use an if statement to display our image, from the previous
section. If the user selected "church", then display the church
image. If the user selected "kitten", then display another image (the
kitten image, which is also in your images folder).
Here's some code:<br />
<div class="TextIndent2">
<?PHP</div>
<div class="TextIndent2">
$kitten_image = 1;<br />
$church_image = 0;</div>
<div class="TextIndent2">
if ($kitten_image == 1) {</div>
<div class="TextIndent3">
print ("<IMG SRC =images/kitten.jpg>");</div>
<div class="TextIndent2">
}</div>
<div class="TextIndent2">
?></div>
Type that out, and save it as <b>testImages.php</b>. (Notice how there's no
HTML!) <br />
When you run the script, the kitten image should display. Let's look at the
code and see what's happening.<br />
The first two lines just set up some variables:<br />
<div class="TextIndent3">
$kitten_image = 1;<br />
$church_image = 0;</div>
A value of 1 has been assigned to the variable called <b>$kitten_image</b>.
A value of 0 has been assigned to the variable called <b>$church_image</b>.
Then we have our if statement. Here it is without the print statement:<br />
<div class="TextIndent3">
if ($kitten_image == 1) {</div>
<div class="TextIndent3">
}</div>
Notice how there's no semi-colon at the end of the first line - you don't need
one. After the word "if" we have a round bracket. Then comes our variable
name:<b> $kitten_image</b>. We want to test what's inside of this variable.
Specifically, we want to test if it has a value of 1. So we need the double
equals sign (<b>==</b>). The double equals sign doesn’t really mean “equals”.
It means “has a value of”.<br />
What we want to say is:<br />
<div align="center">
<b>"If the variable called $kitten_image has a value of
1 then execute some code."</b></div>
To complete the first line of the if statement we have another round bracket,
and a left curly bracket. Miss any of these out, and you'll probably get the
dreaded parse error!<br />
The code we want to execute, though, is the print statement, so that our kitten
image will display. This goes inside of the if statement:<br />
<div class="TextIndent2">
if ($kitten_image == 1) {</div>
<div class="TextIndent3">
print ("<IMG SRC =images/kitten.jpg>");</div>
<div class="TextIndent2">
}</div>
You need the semi-colon at the end of the print statement.<br />
But if your if statement only runs to one line, you can just do this:<br />
<div align="center">
<b>if ($kitten_image == 1) { print ("<IMG SRC = images/kitten.jpg>");
}</b></div>
In other words, keep everything on one line. PHP doesn't care about your spaces,
so it's perfectly acceptable code. Not very readable, but acceptable!<br />
To make use of the church image, here's some new code to try:<br />
<div class="TextIndent2">
<?PHP</div>
<div class="TextIndent1">
$kitten_image = 0;<br />
$church_image = 1;</div>
<div class="TextIndent1">
if ($kitten_image == 1) {</div>
<div class="TextIndent3">
print ("<IMG SRC =images/kitten.jpg>");</div>
<div class="TextIndent1">
}</div>
<div class="TextIndent1">
if ($church_image == 1) {</div>
<div class="TextIndent3">
print ("<IMG SRC =images/church.jpg>");</div>
<div class="TextIndent1">
}</div>
<div class="TextIndent2">
?></div>
Notice that the <b>$kitten_image</b> variable now has a value of 0 and that
<b>$church_image</b> is 1. The new if statement is just the same as the first.
When you run the script, however, the church image will display. That's because
of this line:<br />
<div class="TextIndent3">
if ($kitten_image == 1) {</div>
That says, "If the variable called $kitten_image has a value of 1 ...
". PHP doesn't bother reading the rest of the if statement, because $kitten_image
has a value of 0. It will jump down to our second if statement and test that:<br />
<div class="TextIndent3">
if ($church_image == 1) {</div>
Since the variable called <b>$church_image</b> does indeed have a value of
1, then the code inside of the if statement gets executed. That code prints
out the HTML for the church image:<br />
<div class="TextIndent3">
print ("<IMG SRC =images/church.jpg>");</div>
<br />
In the next section, we'll take a look at<b> if ... else </b>statements.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-26723980080134425272013-08-19T13:46:00.002-07:002013-08-19T13:46:17.113-07:00What you need to get started with PHP<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://webinfobazar.com/wp-content/uploads/2012/03/PHP.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="http://webinfobazar.com/wp-content/uploads/2012/03/PHP.png" border="0" class="decoded" src="http://webinfobazar.com/wp-content/uploads/2012/03/PHP.png" /></a>Before you can write and test your PHP scripts, there's one thing you'll need
- a server! Fortunately, you don't need to go out and buy one. In fact, you
won't be spending any extra money. That's why PHP is so popular! But because
PHP is a server-sided scripting language, you either have to get some web space
with a hosting company that supports PHP, or make your computer pretend that
it has a server installed. This is because PHP is not run on your PC - it's
executed on the server. The results are then sent back to the client PC (your
computer). <br />
Don't worry if this all sounds a little daunting - we've come across an easier
way to get you up and running. We're going to be using some software called
Wampserver. This allows you to test your PHP scripts on your own computer. It
installs everything you need, if you have a Windows PC. We'll explain how to
get it installed in a moment, and where to get it from. But just a word for
non-windows users.<br />
<h3>
<br />
Apple Users</h3>
If you have OS X, then try these sites to get up and running with PHP:<br />
<div align="center">
http://www.onlamp.com/pub/a/mac/2001/12/07/apache.html</div>
<div align="center">
http://www.entropy.ch/software/macosx/php/</div>
What you're doing here is getting the apache server up and running, so that
you can run PHP scripts offline. Pay particular attention to where files are
stored, and to the "localhost" address. <br />
<h3>
Linux Users</h3>
There are quite a few sites out there to help Linux users get up and running
with the Apache server and PHP. Here are three sites that are worth checking
out:<br />
<div align="center">
http://en.wikipedia.org/wiki/LAMP_(software_bundle)</div>
<div align="center">
http://www.php-mysql-tutorial.com/wikis/php-tutorial/installing-php-and-mysql.aspx</div>
<div align="center">
http://www.phpfreaks.com/tutorials/12/0.php</div>
If you know any better ones, we'd be interested in hearing from you!<br />
<h3>
Windows Users</h3>
OK, back to Wampserver and Windows. First, you need to download the software.
You can get it from here (this site is nothing to do with ours, by the way):<br />
<div align="center">
<a href="http://www.wampserver.com/en/download.php" target="_blank">Download
Wampserver</a></div>
Be sure to click the link for Presentation, as well as the link for Downloads.
The Presentation page shows you how to install the file.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-35785882029940428382013-08-19T13:45:00.001-07:002013-08-19T13:45:07.668-07:00What is PHP?<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: x-large;">P</span>HP is probably the most popular scripting language on the web. It is used
to enhance web pages. With PHP, you can do things like create username and password
login pages, check details from a form, create forums, picture galleries, surveys,
and a whole lot more. If you've come across a web page that ends in PHP, then
the author has written some programming code to liven up the plain, old HTML.<br />
PHP is known as a server-sided language. That's because the PHP doesn't get
executed on your computer, but on the computer you requested the page from.
The results are then handed over to you, and displayed in your browser. Other
scripting languages you may have heard of are ASP, Python and Perl. (You don't
need to know any of these to make a start on PHP. In fact, these tutorials assume
that you have no programming experience at all.)<br />
The most popular explanation of just what PHP stands for is "Hypertext
Pre-processor". But that would make it HPP, surely? An alternative explanation
is that the initials come from the earliest version of the program, which was
called Personal Home Page Tools. At least you get the letters "PHP"
in the right order!<br />
But PHP is so popular that if you're looking for a career in the web design/web
scripting industry then you just have to know it! In these tutorials, we'll
get you up and running. And, hopefully, it will be a lot easier than you think.<br />
<h3>
<br /></h3>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-69139111272962916482013-04-18T20:03:00.003-07:002013-04-18T20:03:45.274-07:00JavaScript: Password Validation using regular expressions and HTML5<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 id="section_0">
. Guidelines for Secure Password Input</h2>
<h3>
Use the "password" input type</h3>
Instead of <input type="text"> you should always use
<input type="password"> as this lets the browser (and
the user) know that the contents of that field need to be secured. Your
password won't appear on the screen as you type and most browsers also
won't 'remember' the values entered in <tt>password</tt> fields as they
do with other form elements.<br />
<h3>
Confirm password input</h3>
Because the <tt>password</tt> input type obscures the text typed, you
should let the user confirm that they haven't made a mistake. The
simplest way to do this is to have the password entered twice, and then
check that they are identical.<br />
Another method is to display what they've entered as part of a
'confirmation page'. The problem here is that you're making the
password visible in the browser, browser cache, proxy, etc. For
security a password should <b>never</b> be displayed in HTML or even
sent by email.<br />
<h3>
Enforce 'strong' passwords</h3>
If you're concerned about security you should have some policy on
what constitutes a valid password. Some common restrictions are:<br />
<ul>
<li>at least <i>n</i> characters</li>
<li>combination of upper- and lower-case characters</li>
<li>one or more digits</li>
<li>not related to other user data (name, address, username, ...)</li>
<li>not a dictionary word</li>
</ul>
Leaving the last requirement for now, as it requires a server-side
script, let's see what's possible using just client-side HTML and
JavaScript.<br />
<h3>
Server security</h3>
While having a strong password is a good first step, it needs to be
backed up by additional measures on the server that prevent brute-force
attacks. One popular approach is to install Fail2Ban to monitor log
files and lock out repeat offendors. Of course that only works if your
login system reports failed login attempts to a system log file.
Otherwise your application needs to provide this function.<br />
<h2 id="section_1">
2. Basic Demonstration</h2>
The form below has three input fields: username, pwd1 and pwd2.
When the form is submitted the <tt>checkForm</tt> script parses the
input values and returns either <tt>true</tt> or <tt>false</tt>. If a
false value is returned then the form submission is cancelled.<br />
This code will work for browsers as far back as Netscape 4 (circa
1997).<br />
<form action="/javascript/validate-password/" method="POST">
<fieldset>
<legend>Change Password</legend>
<label>Username</label><span><input name="username" type="text" /></span>
<label>Password</label><span><input name="pwd1" type="password" /></span>
<label>Confirm Password</label><span><input name="pwd2" type="password" /></span>
<span></span>
</fieldset>
</form>
The code behind the form is as follows. If you're not sure how to
place this on your page, you might need to read the preceding article on
Form Validation, or view the HTML
source of this page.<br />
<code id="box1" style="height: 400px;"><script type="text/javascript">
function checkForm(form)
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(form.pwd1.value.length < 6) {
alert("Error: Password must contain at least six characters!");
form.pwd1.focus();
return false;
}
if(form.pwd1.value == form.username.value) {
alert("Error: Password must be different from Username!");
form.pwd1.focus();
return false;
}
re = /[0-9]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one number (0-9)!");
form.pwd1.focus();
return false;
}
re = /[a-z]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one lowercase letter (a-z)!");
form.pwd1.focus();
return false;
}
re = /[A-Z]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one uppercase letter (A-Z)!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}
alert("You entered a valid password: " + form.pwd1.value);
return true;
}
</script>
</code>
<div style="margin-top: 0; text-align: right;">
<small>expand code box</small></div>
Remember that, as JavaScript isn't available in all browsers, you
should user server-side scripting to validate all data before recording
it in a database or text file. You might also want to spice up your
forms using HTML5 Form
Validation as we've done further down the page.<br />
<h2 id="section_2">
3. Advanced regular expressions</h2>
In the latest browsers - those that support JavaScript 1.5 (Firefox,
Netscape 6/7, Mozilla, Safari and Opera 7) - you can use more powerful
regular expressions. Older browsers <b>will not recognise these
patterns</b> so the following is mostly useful for intranet rather than
Internet applications.<br />
The code presented above is fine in that it checks everything that we
wanted to check, but uses a lot of code to test each requirement
individually and present different error messages. We're going to show
you now how to apply the password tests using a single regular
expression.<br />
Consider the following:<br />
<code><script type="text/javascript">
<i>// at least one number, one lowercase and one uppercase letter
// at least six characters</i>
var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;
var validPassword = re.test(input);
</script></code>
The type of expression used here is called a 'look-ahead' which tries
to match the contained regexp against the 'future' part of the
string.<br />
<b>Translation:</b><br />
<ul>
<li>matches a string of six or more characters;</li>
<li>that contains at least one digit (\d is shorthand for [0-9]);</li>
<li>at least one uppercase character; and</li>
<li>at least one lowercase character:</li>
</ul>
<table cellpadding="3" class="collapse">
<thead>
<tr><th>input</th><th>result of test</th><th>reason</th></tr>
</thead>
<tbody>
<tr><td>abcABC</td><td style="text-align: center;">false</td><td>no numbers</td></tr>
<tr><td>abc123</td><td style="text-align: center;">false</td><td>no uppercase characters</td></tr>
<tr><td>abAB1</td><td style="text-align: center;">false</td><td>too short</td></tr>
<tr><td>abAB12</td><td style="text-align: center;">true</td><td>-</td></tr>
<tr><td>Aa123456</td><td style="text-align: center;">true</td><td>-</td></tr>
</tbody>
</table>
<b>If you are using a supported browser</b> you can use the form
below to test the regular expression:<br />
<form action="/javascript/validate-password/" method="POST">
<fieldset>
<legend>Password Regexp Test</legend>
<input name="input" size="12" type="text" /> <br /><small>(input must contain at least one digit/lowercase/uppercase letter and be at least six characters long)</small>
</fieldset>
</form>
If you want to restrict the password to ONLY letters and numbers (no
spaces or other characters) then only a slight change is required.
Instead of using <tt>.</tt> (the wildcard) we use <tt>\w</tt>:<br />
<code class="final"><script type="text/javascript">
<i>// at least one number, one lowercase and one uppercase letter
// at least six characters that are letters, numbers or the underscore</i>
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])<span>\w</span>{6,}$/;
var validPassword = re.test(input);
</script></code>
The <tt>\w</tt> is shorthand for 'any letter, number or the
underscore character'.<br />
Again, you can use the form below to test this regular expression:<br />
<form action="/javascript/validate-password/" method="POST">
<fieldset>
<legend>Password Regexp Test 2</legend>
<input name="input" size="12" type="text" /> <br /><small>(as above, but this time ONLY letters and numbers are allowed)</small>
</fieldset>
</form>
<h2 id="section_3">
4. Sample HTML and JavaScript code</h2>
You might implement this code on your own website as follows:<br />
<code><script type="text/javascript">
function <span>checkPassword(str)</span>
{
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}$/;
return re.test(str);
}
function <span>checkForm(form)</span>
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(!<span>checkPassword(form.pwd1.value)</span>) {
alert("The password you have entered is not valid!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}
return true;
}
</script>
<form method="POST" action="<i>form-handler.php</i>" onsubmit="<span>return checkForm(this);</span>">
<p>Username: <input type="text" name="username"></p>
<p>Password: <input type="password" name="pwd1"></p>
<p>Confirm Password: <input type="password" name="pwd2"></p>
<p><input type="submit"></p>
</form></code>
As you can see, it's well worth learning the intricacies of regular
expressions. They can be used not just in JavaScript, but also PHP,
Perl, Java and many other languages. Some text editors (not just vi)
also allow them when searching for or replacing text.<br />
<h2 id="section_4">
5. HTML5 Form Validation</h2>
We earlier mentioned HTML5 form validation. This is a new technique
available in modern browsers and definitely the way of the future. A
few simple form attributes can have the same effect as reams of
JavaScript code libraries.<br />
Here we have an enhanced version of the above code where we've added
HTML5 <tt>required</tt> and <tt>pattern</tt> elements to apply regular
expression tests within the form itself in supporting browsers.
Helpfully the regular expression syntax is identical with just the
<tt>/^</tt> and <tt>$/</tt> removed.<br />
We've also added a tricky little <tt>onchange</tt> handler to the
first password field which updates the pattern required by the second
password field - in effect forcing them to be identical:<br />
<form action="/javascript/validate-password/" method="POST">
<fieldset>
<legend>Change Password</legend>
<label for="field_username">Username</label><span><input id="field_username" name="username" pattern="\w+" required="" type="text" /></span>
<label for="field_pwd1">Password</label><span><input id="field_pwd1" name="pwd1" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" required="" type="password" /></span>
<label for="field_pwd2">Confirm Password</label><span><input id="field_pwd2" name="pwd2" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" required="" type="password" /></span>
<span></span>
</fieldset>
</form>
Here you can see a screen shot from Safari of the form being
completed. The red/green markers have been implemented using CSS:<br />
<div style="text-align: center;">
<img alt="" height="139" src="http://www.the-art-of-web.com/images/html5-password.jpg" width="408" /></div>
In this example it should be clear to the user that the form can only
be submitted once all three green ticks appear. In any case browsers
such as Firefox and Opera will enforce the HTML5 validation rules and
present messages as shown here:<br />
<div style="text-align: center;">
<img alt="" height="144" src="http://www.the-art-of-web.com/images/html5-password-ff.jpg" width="408" /></div>
Presumably the browser messages will change according to the users
language - something that would never be possible using only
JavaScript.<br />
All we have changed from the previous example is to add some extra
attributes to the form input fields. The rest of the HTML and
JavaScript remains unaltered:<br />
<code>...
<p>Username: <input type="text" <span>required</span> <span>pattern="<i>\w+</i>"</span> name="username"></p>
<p>Password: <input type="password" <span>required</span> <span>pattern="<i>(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}</i>"</span> name="pwd1" <span>onchange="form.pwd2.pattern = this.value;"</span>></p>
<p>Confirm Password: <input type="password" <span>required</span> <span>pattern="<i>(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}</i>"</span> name="pwd2"></p>
...</code>
The best thing about HTML5 attributes is that they have no effect
whatsoever on unsupported browsers, so Internet Explorer will act as if
they are not present and simply run the JavaScript as before.<br />
At this stage both Firefox and Opera enforce HTML5 validation
attributes in the browser while Safari only lets you use them in
combination with CSS effects.<br />
<h2 id="section_5">
6. Customised HTML5 browser alerts</h2>
As you can see from the screenshot above the alert message in Firefox
for when the input doesn't match the <tt>pattern</tt> attribute is
simply "Please match the requested format.". Not entirely
helpful in this case where we have a number of different
requirements.<br />
Fortunately it is possible to customise this message using just a
touch of JavaScript.<br />
<form action="/javascript/validate-password/" method="POST">
<fieldset>
<legend>Change Password</legend>
<label for="field_username2">Username</label><span><input id="field_username2" name="username" pattern="\w+" required="" type="text" /></span>
<label for="field_pwd3">Password</label><span><input id="field_pwd3" name="pwd1" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" required="" type="password" /></span>
<label for="field_pwd4">Confirm Password</label><span><input id="field_pwd4" name="pwd2" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" required="" type="password" /></span>
<span></span>
</fieldset>
</form>
The only change between this and the previous example is that we've
modified the <tt>onchange</tt> handler for the Password input and added
one for Confirm Password:<br />
<code>...
<p>Password: <input type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="pwd1" onchange="
this.<span>setCustomValidity</span>(this.<span>validity.patternMismatch</span> ? 'Password must contain at least 6 characters, including UPPER/lowercase and numbers' : '');
if(this.<span>checkValidity()</span>) form.pwd2.pattern = this.value;
"></p>
<p>Confirm Password: <input type="password" required
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="pwd2" onchange="
this.setCustomValidity(this.validity.patternMismatch ? 'Please enter
the same Password as above' : '');
"></p>
...</code>
When the Password input is changed we check its
<tt>validity.patternMismatch</tt> flag to see whether it matches the
<tt>pattern</tt> attribute. If it doesn't match we set a custom error
message to appear when the form is submitted.<br />
Whenever <tt>setCustomValidity()</tt> has been used to set a custom
message the field in question will be regarded as invalid and prevent
the form from submitting (at least in Firefox and Opera). To reverse
this it needs to be set to blank, which we do when the input matches our
regex rules.<br />
The custom message we have set appears in Firefox as shown here:<br />
<div style="text-align: center;">
<img alt="" height="158" src="http://www.the-art-of-web.com/images/html5-custom-alert.jpg" width="488" /></div>
You can see from the code that we have applied a similar technique to
the Confirm Password field so it will now display "Please enter the
same Password as above" if there is a mismatch between the two
fields. Basically what we've achieved here is to replicate our
JavaScript validation script using HTML5.<br />
Because we are only checking for <tt>patternMismatch</tt> we are not
affecting the other default validation options - namely the
<tt>required</tt> attribute - so submitting the form with blank fields
will still display the generic "Please fill out this field"
alert message. To override those errors you would need to check the
<tt>validity.valueMissing</tt> flag.<br />
<br />
<h2 id="section_6">
7. Conclusions</h2>
As you can see there's a lot involved in providing a rich user
experience even for something as simple as changing a password. To
summarise what we've covered:<br />
<ul>
<li>Always start by emailing new users a random password or unique activation link;</li>
<li>Use the <tt>password</tt> input type to prevent passwords appearing on screen;</li>
<li>Decide what constitutes a 'strong' password for your system and enforce it:<ul>
<li>server-side for spambots and users with JavaScript disabled;</li>
<li>using JavaScript for browsers that don't support HTML5 validation;</li>
<li>using HTML5 for a more user-friendly experience;</li>
</ul>
</li>
<li>Use CSS rules to highlight valid/invalid input for browsers that don't have alerts built-in; and</li>
<li>Customise the HTML5 error messages where appropriate for improved usability;</li>
</ul>
Most of all don't feel you have to install massive JavaScript or
jQuery libraries just to validate a form. By taking advantage of new
browser standards as show in this article you can save time and
resources and at the same time provide a better user experience.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com7tag:blogger.com,1999:blog-9020370651846000084.post-88371694267052725392013-04-18T19:29:00.000-07:002013-04-18T19:29:29.010-07:00Passing variables to JavaScript usin php<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 id="section_0">
</h2>
<h2 id="section_0">
</h2>
<h2 id="section_0">
<img alt="http://blog.outsourcing-partners.com/wp-content/uploads/2012/11/javascript.jpg" src="http://blog.outsourcing-partners.com/wp-content/uploads/2012/11/javascript.jpg" /></h2>
<h2 id="section_0">
</h2>
<h2 id="section_0">
1. Escaping Quotes and Line Breaks</h2>
Suppose you start with a PHP variable that needs to be displayed in a
JavaScript alert or confirmation dialog:<br />
<code> $message = "a short piece of text
spanning more than one line
and containing \"double\" & 'single' quotes";
</code>
The obvious way to turn this into an alert is:<br />
<code><script type="text/javascript">
alert("<?PHP echo $message ?>");
</script>
</code>
but that results in invalid JavaScript code:
<code><script type="text/javascript">
alert("a short piece of text
spanning more than one line
and containing "double" & 'single' quotes");
</script>
</code>
<br />
There are two problems. Firstly, having line breaks inside a
JavaScript variable is not an option. They'll need to be replaced with
<tt>\n</tt> (character representation of a line break). Secondly, the
double quotes inside the text conflict with the outer quotes of the
alert call.<br />
Learning from our mistakes, here's some code that actually works:<br />
<code><script type="text/javascript">
alert("<?php echo <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">preg_replace</a>("/\r?\n/", "\\n", <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">addslashes</a>($message)); ?>");
</script>
</code>
The above code relies on PHP being embedded within HTML code. If
you're outputting the entire page from PHP then you need to go a step
further:<br />
<code class="final"> $message = preg_replace("/\r?\n/", "\\n", addslashes($message));
echo "<script type=\"text/javascript\">\n";
echo " alert(\"$message\");\n";
echo "</script>\n\n";
</code>
The output is now:<br />
<code><script type="text/javascript">
alert("a short piece of text\nspanning more than one line\nand containing \"double\" & \'single\' quotes");
</script>
</code>
The same approach can be applied in pretty much any situation where
PHP needs to pass variables to JavaScript.<br />
When trying to debug this kind of code you should <b>always</b> check
first what's valid in JavaScript (most modern browsers have a built-in
debugger for this) and only then see how it can be generated from
PHP.<br />
<small><b>Note:</b> It's not necessary to encode characters such as
<tt>&</tt> and <tt>"</tt> to their HTML entities as JavaScript is a
separate language from HTML and can handle them without
problem.</small></div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-76522878449095815502013-04-18T19:04:00.000-07:002013-04-18T19:04:45.394-07:00Exporting Data to Excel usin php<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 id="section_0">
1. Preparing the data</h2>
The following examples use the dataset created for Sorting Arrays of Arrays which is defined as
follows:<br />
<code><?PHP
$data = array(
array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25),
array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18),
array("firstname" => "James", "lastname" => "Brown", "age" => 31),
array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7),
array("firstname" => "Michael", "lastname" => "Davis", "age" => 43),
array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24),
array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27)
);
?></code>
<small><b>Note:</b> Further down this page you can find an example on
creating an export from an SQL query.</small><br />
The first step is to output the data in a tab-delimited format (CSV
can also be used but is slightly more complicated). To achieve this we
use the following code:<br />
<code><?PHP
<a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">header</a>("Content-Type: text/plain");
$flag = false;
foreach($data as $row) {
if(!$flag) {
<i>// display field/column names as first row</i>
echo <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">implode</a>("\t", <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">array_keys</a>($row)) . "\r\n";
$flag = true;
}
echo implode("\t", <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">array_values</a>($row)) . "\r\n";
}
exit;
?></code>
We set the content type to <tt>text/plain</tt> so that the output can
more easily be viewed in the browser. Otherwise, because there is no
HTML formatting, the output would appear as a single line of text.<br />
The first line of output will be the column headings (in this case
the field names are used). Values are separated with a tab <tt>\t</tt>
and rows with a line break <tt>\n</tt>. The output should look
something like the following:<br />
<code>firstname lastname age
Mary Johnson 25
Amanda Miller 18
James Brown 31
Patricia Williams 7
Michael Davis 43
Sarah Miller 24
Patrick Miller 27
</code>
There's already a weakness in this code that may not be immediately
obvious. What if one of the fields to be ouput already contains one or
more tab characters, or worse, a newline? That's going to throw the
whole process out as we rely on those characters to indicate column- and
line-breaks.<br />
The solution is to 'escape' the tab characters. In this case we're
going to replace tabs with a literal <tt>\t</tt> and line breaks with a
literal <tt>\n</tt> so they don't affect the formatting:<br />
<code><?PHP
<span> function cleanData(&$str)
{
$str = <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">preg_replace</a>("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
}</span>
header("Content-Type: text/plain");
$flag = false;
foreach($data as $row) {
if(!$flag) {
<i>// display field/column names as first row</i>
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
<span> <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">array_walk</a>($row, 'cleanData');</span>
echo implode("\t", array_values($row)) . "\r\n";
}
exit;
?></code>
Now, before each row is echoed any tab characters are replaced
"\t" so that our columns aren't broken up. Also any line
breaks within the data are replaced with "\n". Now, how to
set this up as a download...<br />
<h2 id="section_1">
2. Triggering a download</h2>
What many programmers don't realise is that you don't have to create
a file, even a temporary one, in order for one to be downloaded. It's
sufficient to 'mimic' a download by passing the equivalent HTTP headers
followed by the data.<br />
If we create a PHP file with the following code then when it's called
a file will be downloaded which can be opened directly using Excel.<br />
<code><?PHP
function cleanData(&$str)
{
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
<span> if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';</span>
}
<span> <i>// filename for download</i>
$filename = "website_data_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");</span>
$flag = false;
foreach($data as $row) {
if(!$flag) {
<i>// display field/column names as first row</i>
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
array_walk($row, 'cleanData');
echo implode("\t", array_values($row)) . "\r\n";
}
exit;
?></code>
Note that we've added an extra line to the <tt>cleanData</tt>
function to detect double-quotes and escape any value that contains
them. Without this an uneven number of quotes in a string can confuse
Excel.<br />
<div style="text-align: center;">
<br /></div>
This should result in a file being downloaded and saved to your
computer. If all goes well then the filename will be
named "website_data_20130419.xls" and will open in Excel looking something like this:<br />
<div style="text-align: center;">
<img alt="screenshot showing data in Excel colums" border="1" height="166" src="http://www.the-art-of-web.com/images/dataexport_excel.jpg" width="300" /></div>
How does it work? Setting the headers tells the browser to expect a
file with a given name and type. The data is then echoed, but instead
of appearing on the page it becomes the downloaded file.<br />
Because of the <tt>.xls</tt> extension and the <tt>ms-excel</tt> file
type, most computers will associate it with Excel and double-clicking
will cause that program to open. You could also modify the file name
and mime type to indicate a different spreadsheet package or database
application.<br />
<b>There is no way to specify data or cell formatting, column
widths, etc, using this method. We are only passing a tab-delimited
text file. To include formatting try generating HTML code or a script
that actually builds an Excel file. Or create your own macro in Excel
that applies formatting after the import.</b><br />
A similar technique can be used to allow users to download files that
have been uploaded previously using PHP and stored with different names.
More on that later...<br />
<h2 id="section_2">
3. Exporting from an SQL database</h2>
If your goal is to allow data to be exported from a query result
then the changes are relatively simple:<br />
<code class="final"><?PHP
<i>// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.</i>
function cleanData(&$str)
{
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
<i>// filename for download</i>
$filename = "website_data_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
<span> $result = <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">pg_query</a>("SELECT * FROM <i>table</i> ORDER BY <i>field</i>") or die('Query failed!');
while(false !== ($row = <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">pg_fetch_assoc</a>($result))) {</span>
if(!$flag) {
<i>// display field/column names as first row</i>
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
array_walk($row, 'cleanData');
echo implode("\t", array_values($row)) . "\r\n";
}
exit;
?></code>
This would be the entire file required to query the database and
trigger the file download. The database functions need to match the
database you're using. <b>MySQL users for example will need to use <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">mysql_query</a>
and either <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">mysql_fetch_assoc</a> or <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">mysqli_fetch_assoc</a></b> in place of the PostgreSQL
functions.<br />
For other databases see under User Comments
below or check the PHP documentation. <b>If you are seeing duplicate
columns (numbered as well as labeled) you need to change the fetch call
to return only the associative (ASSOC) array</b>.<br />
If you're having trouble at this stage, remove the
Content-Disposition header and change the Content-Type back to
<tt>text/plain</tt>. This makes debugging a lot easier as you can see
the output in your browser rather than having to download and open the
generated file every time you edit the script.<br />
<h2 id="section_3">
4. Preventing Excel's ridiculous auto-format</h2>
When importing from a text file as we're essentially doing here,
Excel has a nasty habit of mangling dates, timestamps, phone numbers and
similar input values.<br />
For our purposes, some simple additions to the <tt>cleanData</tt>
function take care of most of the problems:<br />
<code class="final"><?PHP
<i>// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.</i>
function cleanData(&$str)
{
<i>// escape tab characters</i>
$str = preg_replace("/\t/", "\\t", $str);
<i>// escape new lines</i>
$str = preg_replace("/\r?\n/", "\\n", $str);
<i>// convert 't' and 'f' to boolean values</i>
if($str == 't') $str = 'TRUE';
if($str == 'f') $str = 'FALSE';
<i>// force certain number/date formats to be imported as strings</i>
if(preg_match("<span>/^0/</span>", $str) || preg_match("<span>/^\+?\d{8,}$/</span>", $str) || preg_match("<span>/^\d{4}.\d{1,2}.\d{1,2}/</span>", $str)) {
$str = "'$str";
}
<i>// escape fields that include double quotes</i>
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
?></code>
The section that prevents values being scrambled does so by inserting
an apostrophe at the start of the cell. When you open the resuling file
in Excel you may see the apostrophe, but editing the field will make it
disappear while retaining the string format. Excel is strange that way.<br />
The types of values being escape this way are: values starting with a
zero; values starting with an optional <tt>+</tt> and at least 8
consecutive digits (phone numbers); and values starting with numbers in
YYYY-MM-DD format (timestamps). The relevant regular expressions have
been highlighted in the code above.<br />
<h2 id="section_4">
5. Formatting - colours, numbers, dates</h2>
Again, this script generates and triggers the download of a
tab-delimited <b>text file</b> with an <tt>.xls</tt> extension and Excel
Mime-Type. We are <b>not</b> building an actual Excel document.<br />
Defining styles, colours, column widths, etc, is not possible using
this technique. You may be able to generate an HTML table with some
formatted data that Excel will recognise, otherwise you need a much
more complicated script.<br />
<h2 id="section_5">
6. Exporting to CSV format</h2>
The tab-delimited text options describe above may be a bit limiting
if your data contains newlines or tab breaks that you want to preserve
when opened in Excel or another spreadsheet application.<br />
A better format then is comma-separated variables (CSV) which can be
generated as follows:<br />
<code class="final"><?PHP
function cleanData(&$str)
{
if($str == 't') $str = 'TRUE';
if($str == 'f') $str = 'FALSE';
if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
$str = "'$str";
}
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
<i>// filename for download</i>
$filename = "website_data_" . date('Ymd') . "<span>.csv</span>";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: text/csv;");
<span>$out</span> = <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">fopen</a>("php://output", 'w');
$flag = false;
$result = pg_query("SELECT * FROM table ORDER BY field") or die('Query failed!');
while(false !== ($row = pg_fetch_assoc($result))) {
if(!$flag) {
<i>// display field/column names as first row</i>
<a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">fputcsv</a>(<span>$out</span>, array_keys($row), ',', '"');
$flag = true;
}
array_walk($row, 'cleanData');
fputcsv(<span>$out</span>, array_values($row), ',', '"');
}
fclose(<span>$out</span>);
exit;
?></code>
Normally the <tt>fputcsv</tt> command is used to write data in CSV
format to a separate file. In this script we're tricking it into
writing directly to the page by telling it to write to
<tt>php://output</tt> instead of a regular file.<br />
<h2 id="section_6">
7. Exporting to CSV with Unicode intact</h2>
If like us your data contains UTF-8 characters you will notice that
Excel doesn't handle them very well. Other applications can open UTF-8
content without problems, but for some reason Microsoft wants to keep
you in the dark ages.<br />
Fortunately, there is a trick you can use. Below you can see how we
modify the script to convert everything from UTF-8 to UTF-16 Lower
Endian (UTF-16LE) format which Excel, at least on Windows, will recognise.<br />
<small><b>Please Note:</b> When you open the file in Excel you might
find all the data bunched into the first column. This should be fixable
using the "Text to Columns..." command in the Data menu.</small><br />
<code class="final"><?PHP
function cleanData(&$str)
{
if($str == 't') $str = 'TRUE';
if($str == 'f') $str = 'FALSE';
if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
$str = "'$str";
}
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
<span>$str = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8');</span>
}
<i>// filename for download</i>
$filename = "website_data_" . date('Ymd') . ".csv";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: text/csv;<span> charset=UTF-16LE</span>");
$out = fopen("php://output", 'w');
$flag = false;
$result = pg_query("SELECT * FROM table ORDER BY field") or die('Query failed!');
while(false !== ($row = pg_fetch_assoc($result))) {
if(!$flag) {
<i>// display field/column names as first row</i>
fputcsv($out, array_keys($row), ',', '"');
$flag = true;
}
array_walk($row, 'cleanData');
fputcsv($out, array_values($row), ',', '"');
}
fclose($out);
exit;
?></code>
This script may not work for all versions of Excel. Please let us
know using the Feedback form below if you encounter problems or come up
with a better solution.<br />
<h2 id="section_7">
8. Specifying column headings</h2>
The above database download examples all use the database field
names for the first row of the exported file which may not be what you
want. If you want to specify your own more user-friendly headings you
can modify the code as follow:<br />
<code><PHP
$colnames = array(
<i> 'memberno' => "Member No.",
'date_joined' => "Date joined",
'title' => "Title",
'firstname' => "First name",
'lastname' => "Last name",
'address' => "Address",
'postcode' => "Postcode",
'city' => "City",
'country' => "Country",
'phone' => "Telephone",
'mobile' => "Mobile",
'fax' => "Facsimile",
'email' => "Email address",
'notes' => "Notes"</i>
);
function <tt>map_colnames</tt>($input)
{
global $colnames;
return isset($colnames[$input]) ? $colnames[$input] : $input;
}
<i>// filename for download</i>
$filename = "website_data_" . date('Ymd') . ".csv";
...
if(!$flag) {
<i>// display field/column names as first row</i>
<span> $firstline = <a href="http://www.blogger.com/blogger.g?blogID=9020370651846000084" target="_blank">array_map</a>("<tt>map_colnames</tt>", array_keys($row));
fputcsv($outstream, $firstline, ',', '"');</span>
$flag = true;
}
...
?></code>
The values in the first row will be mapped according to the
<tt>$colnames</tt> associative array. If no mapping is provided for a
fieldname it will remain unchanged. Of course you will want to provide
your own list of suitable headings. They don't have to be in order.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com11tag:blogger.com,1999:blog-9020370651846000084.post-53520867976965775692013-03-26T06:23:00.000-07:002013-03-26T06:23:02.805-07:00Why do you need an Ecommerce website?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.ecommerce-webmarketing.com/wp-content/uploads/2012/09/e-commerce-mod%C3%A8le-%C3%A9conomique1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.ecommerce-webmarketing.com/wp-content/uploads/2012/09/e-commerce-mod%C3%A8le-%C3%A9conomique1.jpg" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
If you’re looking to sell your products
online, you would need an Ecommerce store. Who does not want a fully
featured site or portal for less money? We can provide you tailor made
solutions for your online shopping needs matching your budget. You can
easily make profits with our custom Ecommerce solutions.</div>
<div style="text-align: left;">
At Infilon, we keep in mind the target audience while designing and developing
any Ecommerce store. Our designs are influenced by who is going to buy
your products. All the websites we build are user friendly and creative.
We do not do what everybody does and that makes us distinguish from the
crowd. We can make your Ecommerce website stand out from the pool of
websites.</div>
<div style="text-align: justify;">
We have helped many small and large
businesses make huge profits with having an online presence. Once you
come to us, you can get tension-free about the development and you can
focus on your core business. Now, you don’t need to spend thousands of
dollars for having an Ecommerce store. We provide cost effective
solutions for all your Ecommerce needs.</div>
<div style="text-align: justify;">
There might be countless competitors in
your business. So standing out of the competition is mandatory. We
analyse the markets and then come to an idea and plan to design an
Ecommerce website for you. At Infilon, we can help you build a larger
turn over in no time. The experts at Infilon always strive to create new
ways to enhance our services and help our clients to get the maximum
Returns on Investment.</div>
<div style="text-align: justify;">
The key to a successful Ecommerce website
is easy navigation, user-friendly, multiple payment options and
content. After the development, you would obviously need branding. We
prepare a good marketing strategy for your website or portal. The key to
a successful and profit-generating ecommerce website is easy navigable,
user friendly, multiple payment options and easy search options.</div>
<div style="text-align: justify;">
You should make your website customers’
favorite and their shopping experience with your website memorable. With
years of experience, we know how to offer a high conversion ratio for
your products. By using our Ecommerce solutions, showcase your products to the world and build a flourishing online business.</div>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-91459008575310329472013-03-23T18:15:00.003-07:002013-03-23T18:15:36.616-07:00what is new in windows 8 server ?<div dir="ltr" style="text-align: left;" trbidi="on">
Hello again. This is another article about Windows 8. But this time I
will talk about the server version of this operating system. As you all
know, approximately 1 month ago, Microsoft made the Developer Preview
of its next generation operating system available through its MSDN
website. The installation of the operating system is somehow similar
(but shorter) to the installation of its client version brother. But the
interior is different of course. Let me first show you the installation
and then I will talk about new features coming with the Server 8.<br />
<div style="margin: 40px 0 0 0;">
<span id="more-316"></span></div>
<div style="padding-left: 70px;">
</div>
The ISO file of the setup DVD for Windows 8 Server is reachable
through the MSDN site as I mentioned before. Therefore if you are an
MSDN subscriber, you can download it via <a href="http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx">http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx</a>
. As you can see in Figure 1, you have to sign in to the website and
you must have the permission to download this server product.<br />
<div class="wp-caption aligncenter" style="width: 605px;">
<img alt="" height="299" src="http://mstip.ipsure.com/images/mstip/pic0120112001.jpg" width="595" /><div class="wp-caption-text">
Figure 1: MSDN Subscriber webpage</div>
</div>
You may want to read the system requirements for Windows Server 8
Developer Preview installation first. This information can be reached
through <a href="http://msdn.microsoft.com/en-us/windowsserver/hh440457">http://msdn.microsoft.com/en-us/windowsserver/hh440457</a>
webpage (actually using resources less than the ones mentioned in the
webpage doesn’t prevent the installation to be completed).<br />
OK. Let me start with the installation process now. After I insert my
installation DVD into my server, I boot the server with it and the
first screen is (as usual) time/keyboard/language selection screen as
seen in Figure 2. After I complete the selections, I begin to install
Windows 8 Server by pressing “Install Now” button on the next screen
(Figure 3).<br />
<div class="wp-caption aligncenter" style="width: 567px;">
<img alt="" height="413" src="http://mstip.ipsure.com/images/mstip/pic0120112002.jpg" width="557" /><div class="wp-caption-text">
Figure 2: Time/keyboard/language selection screen</div>
</div>
<div class="wp-caption aligncenter" style="width: 568px;">
<img alt="" height="412" src="http://mstip.ipsure.com/images/mstip/pic0120112003.jpg" width="558" /><div class="wp-caption-text">
Figure 3: “Install now”</div>
</div>
The following screen is the selection of the operating system type
screen. Here, I have three types of operating system to install and I
select the first choice which is full installation (Figure 4). In here, a
very new installation type “Features on Demand” is also listed (which I
am not very familiar with for now). The next 3 screens are License
Agreement, type of installation (upgrade or Custom) and disk selection
screens. After a couple of Next buttons, I finish the installation of
Developer Preview edition of the new Windows operating system. The first
screen represented after a reboot is “Settings” screen which is
actually the place that I decide the administrators password (Figure 5).
That is all :) . No more questions. This represents me the CTRL+ALT+DEL
screen (Figure 6) and I logon to my new server.<br />
<div class="wp-caption aligncenter" style="width: 610px;">
<img alt="" height="450" src="http://mstip.ipsure.com/images/mstip/pic0120112004.jpg" width="600" /><div class="wp-caption-text">
Figure 4: Operating System types</div>
</div>
<div class="wp-caption aligncenter" style="width: 610px;">
<img alt="" height="450" src="http://mstip.ipsure.com/images/mstip/pic0120112005.jpg" width="600" /><div class="wp-caption-text">
Figure 5: Settings screen</div>
</div>
<div class="wp-caption aligncenter" style="width: 610px;">
<img alt="" height="450" src="http://mstip.ipsure.com/images/mstip/pic0120112006.jpg" width="600" /><div class="wp-caption-text">
Figure 6: CTRL+ALT+DEL screen</div>
</div>
After I logon to the operating system, “Server Manager” window is
opened automatically. It is completely different than its predecessors
as you can see in Figure 7. I will not get into detail about it now
because we will play with it in future articles. Therefore that is end
of installation part. Not that difficult, huh?<br />
<div class="wp-caption aligncenter" style="width: 610px;">
<img alt="" height="421" src="http://mstip.ipsure.com/images/mstip/pic0120112007.jpg" width="600" /><div class="wp-caption-text">
Figure 7: New “Server manager” interface</div>
</div>
Now I want to talk about the new features coming with this new
operating system. According to the Windows guys, there are 300 new
features/improvements in this version but I couldn’t explain all of them
of course :) . Therefore I will talk about the most important ones
(according to me).<br />
You saw Server Manager in Figure 7 and as you understand it had a new
Metro Style interface. That is not I am going to talk about Server
Manager but it has a new capability now. You can do multiserver
management via Server Manager of Windows 8 Server (Figure 8). What I
mean by this? With Server Manager, you can (for example) install
updates, reboot and load File Services Role or DNS role on four servers
simultaneously. No need to do one by one.<br />
<div class="wp-caption aligncenter" style="width: 592px;">
<img alt="" height="418" src="http://mstip.ipsure.com/images/mstip/pic0120112008.jpg" width="582" /><div class="wp-caption-text">
Figure 8: You can put additional servers in the list to add the same role simultaneously</div>
</div>
Another new feature (actually an improvement) is Hyper-V version 3.
It has new specifications now (and may change with RTM). Hyper-V version
3 supports 160 CPU cores and 2TB memory on host machines. It supports
32 CPU cores and 512 GB memory per virtual machine. Another feature it
has is the new file format VHDX. VHDX can exceed 2TB in size and runs
faster than VHD format. Hyper-V version 3 can grow up to 63 nodes in a
cluster and supports 4000 virtual machines per cluster.<br />
Windows 8 Server can team the network cards natively. Before Windows 8
Server, we can team the network cards with the manufacturer’s teaming
tools/softwares but now it is not needed. Most importantly, we can team
NICs that have totally different chipsets. Therefore Windows can load
balance the network job and if one of the NICs fails, It continues its
job seamlessly.<br />
One of the coolest feature that Windows 8 Server introduces is
Dynamic Access Control. It is a new approach for file/folder
permissions. To be clear, it uses <strong>tags</strong> for file/folder
access (like Microsoft Office Tags). For example, you can give each
personnel of the Finance department a specific title in Active Directory
and Windows 8 File Server can use the Active Directory Title Attribute
as a tag. As a result, it lets the personnel reach the files and folders
which are classified for this tag. This feature may rescue
administrators from too many security groups which are created just for
giving permissions on file server.<br />
The last feature that I want to mention in this article is
de-duplication feature. If there are files with multiple copies in the
hard drive, Windows 8 Server can save space by keeping one real copy of
them and pointer for the rest. For example, you have multiple Windows
Server 2003 virtual machines created on your Windows 8 Hyper-V server
and each of these virtual machines have calculator.exe file. Windows 8
Server knows about these redundant files and keep only one of them. The
rest is just pointers to this kept one. I think you got the idea ;)<br />
Hopefully and most probably, there will be more stuff in Windows 8
Server when it is released. I tried to mention the most important ones
(in my opinion) in this article. I hope you enjoyed it. See you next
time.<br />
<a href="http://www.linkwithin.com/"><img alt="Related Posts with Thumbnails" src="http://www.linkwithin.com/pixel.png" style="border: 0;" /></a></div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com3tag:blogger.com,1999:blog-9020370651846000084.post-17329658978174855342013-03-23T18:13:00.001-07:002013-03-23T18:13:11.374-07:00what is new in windows 8 ?<div dir="ltr" style="text-align: left;" trbidi="on">
Last weeks Microsoft released the Developer Preview for its new
operating system, Windows 8, to public. It is known that Windows 8 Final
Release will be available in 2012. As all new operating systems come
with improvements and differences, Windows 8 promises to give customers a
new and improved Windows experience. Throughout this article, I want to
show you some of these new features of Windows 8.<br />
<div style="margin: 40px 0 0 0;">
<span id="more-302"></span></div>
<div style="padding-left: 70px;">
</div>
Windows 8 Developer Preview can be downloaded through the link <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516">http://msdn.microsoft.com/en-us/windows/apps/br229516</a>
. The operating system is coming with 32bit and 64 bit options. I will
explain the main differences of Windows 8 but you can reach a long list
of new Windows 8 features in <a href="http://www.winrumors.com/heres-a-list-of-300-windows-8-features-that-microsoft-didnt-show/">winrumors.com</a> website. So what are the main newly coming features of Windows 8?<br />
The first thing a user will notice is metro style user interface
(Figure 1). This interface is mainly designed for tablets and is build
for touch. You can access your applications (Apps) from this single
interface with a fingertip. This interface is a personalized layout with
clean animations and writings to make the user interact with his/her PC
fluid. The new Start screen puts everything you want and you need in
front of you for immediate access. It is also alive! What I mean by that
is the Apps show user up-to-date information as long as your device is
connected to the internet. Therefore, you can access the information as
it produced.<br />
<div class="wp-caption aligncenter" style="width: 610px;">
<img alt="" height="450" src="http://mstip.ipsure.com/images/mstip/pic0120111501.jpg" width="600" /><div class="wp-caption-text">
Figure 1: Metro Style start screen</div>
</div>
Previous Windows client operating systems support x86 or x64
platforms. Another new feature of Windows 8 is its ARM support. As the
new Windows 8 operating system is mainly designed for mobile devices, it
supports ARM-based chipsets now. The users will experience their new
Windows in various types of devices such as a 10-inch tablet or ultra
lightweight laptops.<br />
Cloud computing is seen as the future of computing world today and
Applications (as in the Android operating system) is the new trend in IT
world. Therefore Microsoft implements its application solution to
Windows 8 (Apps). Windows Store (identical to Google Android Market)
will serve as a central point for application downloads. Windows Apps
can work together by the way; making it easy to search, share, and send
content between them. As I said before, when a user is connected to the
Internet, Apps come alive with activity and show the latest content.
May be the most powerful side of Windows Apps is their ability to come
with the user! As a user sign in with his connected Microsoft account
(LiveID) to another PC running Windows 8, his Metro style apps and
settings go with him, so it’s just like using his own PC.<br />
Another improvement Windows 8 has is the faster boot start. In
windows8center.com website, there is a good explanation of why it is
faster than its predecessors. Figure 2 shows the comparison of Windows 8
and Windows 7 boot up speeds for various PC configurations. Therefore,
one of the most frastrating downside (long startup time) of Windows
operating systems is not a downside anymore. :)<br />
<div class="wp-caption aligncenter" style="width: 539px;">
<img alt="" height="229" src="http://mstip.ipsure.com/images/mstip/pic0120111502.jpg" width="529" /><div class="wp-caption-text">
Figure 2: Windows 8 vs Windows 7 boot start comparison (taken from windows8center.com)</div>
</div>
Windows 8 supports USB 3.0 standard natively. As I talked about USB
standard, there is a big improvement that Windows 8 can be booted from a
USB memory stick. This feature which is called “Windows To Go” will be
very helpful especially for system administrators I think. You can boot a
corrupted or infected machine with Windows 8 and perform administrative
tasks on that. Also a user can bring his operating system with him
wherever he wants. Just plug the stick in, work as he wants, finish the
job and plug the operating system out. :)<br />
Uptil now, I talked about the general changes that the new operating
system has over the previous one. But what about the user experience? Is
there any changes or improvements in Windows while we are using it? Let
me talk about it from now on.<br />
Task Manager looks different now (Figure3). It is easy-to-use and
all-in-one dashboard for monitoring the PC’s resources and services. The
data is presented in color-coded tiles to point out the items that are
using the bulk of a resource. There are 7 tabs included in Task Manager
now which are; Processes, Performance, App History, Startup, Users,
Details and Services.<br />
<div class="wp-caption aligncenter" style="width: 599px;">
<img alt="" height="502" src="http://mstip.ipsure.com/images/mstip/pic0120111503.jpg" width="589" /><div class="wp-caption-text">
Figure 3: New Task Manager</div>
</div>
Another new feature (which is not a big one but very important in my
opinion) is the ability to mount ISO and VHD files natively. From now on
with Windows 8, you can mount your ISO files as CD-Drive and your VHD
files as harddisks without needing a third party solution. As an
administrator, one of the first things that I’ve done is to install a
mounting software to my operating system. With Windows 8, I don’t need
it anymore (Figure 4).<br />
<div class="wp-caption aligncenter" style="width: 589px;">
<img alt="" height="320" src="http://mstip.ipsure.com/images/mstip/pic0120111504.jpg" width="579" /><div class="wp-caption-text">
Figure 4: Mounting ISO and VHD files</div>
</div>
Windows Explorer has a big difference now because it has a ribbon bar
which organizes the rich functionality of Explorer (Figure 5). Mostly
used commands are now organized in ribbon and users can reach most of
the functionalities with one mouse click.<br />
<div class="wp-caption aligncenter" style="width: 606px;">
<img alt="" height="264" src="http://mstip.ipsure.com/images/mstip/pic0120111505.jpg" width="596" /><div class="wp-caption-text">
Figure 5: Ribbon bar of Windows Explorer</div>
</div>
Other than these, few additional changes that the users experience at
first glance are Internet Explorer 10, Push-button Reset, Lock Screen
& Notifications, LiveID logon. As I said before there will be lots
of improvements when Windows 8 is on the market. You can read more
explanation about the new features in <a href="http://download.microsoft.com/download/1/E/4/1E455D53-C382-4A39-BA73-55413F183333/Windows_Developer_Preview-Windows8_guide.pdf">http://download.microsoft.com/download/1/E/4/1E455D53-C382-4A39-BA73-55413F183333/Windows_Developer_Preview-Windows8_guide.pdf</a> .<br />
I think Windows 8 will be a realistic change for Microsoft and the
real first step to cloud computing on the client side. It seems that
user habits will change with this new release. Users will get what they
want from the operating system more easily and friendly. I hope the
article is helpful to you. See you next time.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-48910895802608956582013-03-22T19:03:00.003-07:002013-03-22T19:03:57.085-07:00top 10 favorite Twitter tips and tricks<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://prochef360blog.com/wp-content/uploads/2011/03/twitter-tips.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="http://prochef360blog.com/wp-content/uploads/2011/03/twitter-tips.jpg" width="320" /></a></div>
<div style="text-align: center;">
<br /></div>
<br />
Below
is a listing of our top 10 favorite Twitter tips and tricks. These tips will
help make your Twitter experience more enjoyable and can help increase your
followers.
<br />
<span class="bb">Customize</span><br />
<ul>
<li>Change your profile picture. Use a picture of yourself to make it
seem more personalized if this is your personal Twitter account.</li>
<li>Utilize as much of the 160-character limit Twitter
BIO space allows. Include keywords your followers or potential followers may be
searching for.</li>
<li>Create your own background image. However, do not
make the image too much like an ad or sales pitch. The background image must be
less than 800k and we recommend a size of 1600x1200 for a large image or smaller
if you plan on tiling the image or just having it on the left-hand
side. Finally, keep in mind that smaller resolutions and
monitor sizes will hide much of the background.</li>
</ul>
<span class="bb">Third-party tools</span><br />
<div class="tab">
Take advantage of the hundreds of different third-party online
tools and services that enhance your Twitter experience. Below are a few of our
favorites.</div>
<ul>
<li><b><a href="http://twitpic.com/" target="_blank">TwitPic</a></b> - Take
advantage of TwitPic to post pictures on your tweets. If you want to post
pictures while away from the computer, use the <b>Twitterific</b> app.</li>
<li><b><a href="http://useqwitter.com/" target="_blank">Qwitter</a></b> - Great
service that sends an e-mail any time someone unsubscribes from your Twitter
profile and mentions a possible Twitter post you made that may have caused them to leave.</li>
<li><b><a href="http://manageflitter.com/" target="_blank">Manageflitter</a></b>
- Fantastic site for managing your followers and getting an easy to read
overview of people not following you back, quiet users, and inactive users.</li>
<li><strong><a href="http://wefollow.com/" target="_blank">WeFollow</a></strong>
- Great website that allows you to add yourself to a listing of Twitter users by
tags you find interesting.</li>
<li><b><a href="http://www.socialoomph.com/">SocialOomph</a></b> - Another great
service with a collection of free Twitter tools including the ability
to schedule when a tweets gets posted.</li>
<li><b><a href="http://tweetbeat.com/" target="_blank">Tweetbeat</a></b> - An
excellent site that takes the trending topics on Twitter and gives
you a clearer explanation of present and past trending topics.</li>
<li><b><a href="http://tweetmeme.com/" target="_blank">TwitterMeme</a></b> -
Another great location to find the hottest links on Twitter.</li>
<li><b><a href="http://twittergrader.com/">Twitter Grader</a></b> - Great
service that grades any Twitter account and gives you additional details and
ranking information.</li>
<li><b><a href="http://twitter.pbworks.com/w/page/1779726/Apps" target="_blank">
Twitter Fan Wiki Apps</a></b> - Finally, this wiki has a listing of several
hundred different Twitter applications and tools for users
wanting more.</li>
</ul>
<span class="bb">Use Twitter search</span><br />
<div class="tab">
Take full advantage of the Twitter search tool. Below are just a
few tips that can help improve your search capabilities on Twitter.</div>
<ul>
<li>Search for your website or blog URL and see if others are mentioning your
page.</li>
<li>Search for anything near you by adding near:"city state". For example,
typing <b>near:"Salt lake city Utah" club</b> would return current tweets that
have happened in Salt Lake City, Utah with the keyword club in them.</li>
<li>Find people who you may enjoy following by searching for keywords that interested
you.</li>
<li>If you do not want tweets with links add <b>? -filter:links</b>
at the end of your search query.</li>
<li>Need more options, use the
<a href="http://search.twitter.com/advanced">Advanced Twitter search</a>.</li>
<li>Any time you get excellent results click the "Save this search" button to
save that search. These searches can then be found under "Saved Searches" on the
right-hand part of your profile on the old Twitter interface or under the
"Searches" tab next to your timeline on the new Twitter interface.</li>
</ul>
<span class="bb">Followers</span><br />
<ul>
<li>Engage followers.</li>
<li>Do not follow too many people. No one is going to follow someone who is
following thousands of people but only has 10 followers.</li>
<li>Retweet interesting posts.</li>
<li>Retweet and participate in conversations with people with a lot of
followers.</li>
<li>Realize it is impossible for anyone to read
every tweet.</li>
<li>When first joining do not follow hundreds of people, doing this
may mark you as a bot.</li>
</ul>
<span class="bb">Create useful and interesting tweets</span><br />
<ul>
<li>Try making all your tweets informative, useful, or funny.</li>
<li>Do not post mundane posts, e.g. eating a bowl of cereal.</li>
<li>Add hastags to your tweets. For
example, if your tweet is about computers, consider adding #computer in the tweet.</li>
<li>Tweet frequently. No one is going to follow someone they do not know who
has not tweeted in months. Try at the very least to tweet a few times a week or
daily if you can manage.</li>
<li>Do not whine or complain. Everyone will unfollow anyone who constantly
whines or complains.</li>
<li>Try making your valuable tweets during the times people will most likely see them.</li>
<li>Keep some space available in your tweet in case someone
retweets your post.</li>
<li>Use special characters in your tweets.</li>
</ul>
<span class="bb">Know the lingo</span><br />
<div class="tab">
Know the Twitter lingo, these are just a few
examples: @reply,
Direct Message (DM),
Follower,
Hashtag,
Retweet (RT), Trending Topics,
and
Tweet. See the
Twitter description
for a full listing of Twitter terms and Lingo and related terms.</div>
<span class="bb">Follow the masters</span><br />
<div class="tab">
Following a few of the masters of Twitter and Social Networking
will give you an understanding of how to tweet better, posts to RT, and
inspiration for tweets of your own. Below are the top ten Twitters we recommend
following.</div>
<div class="tab bld">
<a href="http://twitter.com/#%21/GuyKawasaki" target="_blank">
@GuyKawasaki</a><br /><a href="http://twitter.com/#%21/Scobleizer" target="_blank">
@Scobleizer</a><br /><span class="screen-name screen-name-jeffbullas pill">
<a href="http://twitter.com/#%21/jeffbullas" target="_blank">@jeffbullas</a></span><br />
<span class="screen-name screen-name-briansolis pill">
<a href="http://twitter.com/#%21/briansolis" target="_blank">@briansolis</a></span><br />
<span class="screen-name screen-name-tonyrobbins pill">
<a href="http://twitter.com/#%21/tonyrobbins" target="_blank">@tonyrobbins</a></span><br />
<span class="screen-name screen-name-kevinrose pill">
<a href="http://twitter.com/#%21/kevinrose" target="_blank">@kevinrose</a></span><br />
<span class="screen-name screen-name-timoreilly pill">
<a href="http://twitter.com/#%21/timoreilly" target="_blank">@timoreilly</a></span><br />
<span class="screen-name screen-name-donttrythis pill">
<a href="http://twitter.com/#%21/donttrythis" target="_blank">@donttrythis</a></span><br />
<span class="screen-name screen-name-zappos pill">
<a href="http://twitter.com/#%21/zappos" target="_blank">@zappos</a></span><br />
<span class="screen-name screen-name-brainpicker pill">
<a href="http://twitter.com/#%21/brainpicker" target="_blank">@brainpicker</a></span></div>
<ul>
<li><b><a href="http://twitaholic.com/" target="_blank">Twitaholic</a></b> - A
full listing of the top users on Twitter based on Followers. This is a terrific
service to find and follow the top users and possibly incorporate some of the ideas they are doing on their account.</li>
</ul>
<div class="tab">
<span class="tips">Tip:</span> Many of the
first few hundred people are celebrities on Twitaholic, if they do not interest
you skip the first page.</div>
<span class="bb">Create and use lists</span><br />
<div class="tab">
<img alt="Twitter list icon" class="floatRight" height="30" src="http://www.computerhope.com/tips/images/list.jpg" width="44" />Twitter
lists are an excellent method of filtering filter through the people you follow.
To create a list, click the <b>Lists</b> link and then <b>Create a list</b>.
After creating a list visit the persons profile page you wish to add and click
the list icon, as shown in the picture to the right. Our
<a href="http://twitter.com/#%21/list/computerhope/computers-and-tech">Computers
and Tech</a> list is an example of a public list we created.</div>
<span class="bb">Go Mobile</span><br />
<div class="tab">
Apple iPhones, Blackberry phones, Android phones, Windows phone 7
phones, and most of the other smart phones have Twitter
applications. Take full advantage of these applications. For users who do not have
smart phones Twitter also has extensive support for
SMS, which can send tweets over a text message.</div>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-7509099661319004652013-03-22T18:51:00.000-07:002013-03-22T18:51:58.113-07:00Display Twitter RSS feed using PHP<div dir="ltr" style="text-align: left;" trbidi="on">
Most of the bloggers(and developers), have at least once needed to
display a twitter feed on their pages. There are a variety of ways of
doing that, but today I`ll write about including a twitter feed in your
blog using PHP. The code is pretty much straight-forward. The only thing
you have to adjust is the amount of tweets you want shown and the
username, which feed you`ll be displaying.
<br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td class="gutter"><div class="line number1 index0 alt2">
1</div>
<div class="line number2 index1 alt1">
2</div>
<div class="line number3 index2 alt2">
3</div>
<div class="line number4 index3 alt1">
4</div>
<div class="line number5 index4 alt2">
5</div>
<div class="line number6 index5 alt1">
6</div>
<div class="line number7 index6 alt2">
7</div>
<div class="line number8 index7 alt1">
8</div>
<div class="line number9 index8 alt2">
9</div>
<div class="line number10 index9 alt1">
10</div>
<div class="line number11 index10 alt2">
11</div>
<div class="line number12 index11 alt1">
12</div>
<div class="line number13 index12 alt2">
13</div>
<div class="line number14 index13 alt1">
14</div>
<div class="line number15 index14 alt2">
15</div>
<div class="line number16 index15 alt1">
16</div>
<div class="line number17 index16 alt2">
17</div>
<div class="line number18 index17 alt1">
18</div>
<div class="line number19 index18 alt2">
19</div>
<div class="line number20 index19 alt1">
20</div>
<div class="line number21 index20 alt2">
21</div>
<div class="line number22 index21 alt1">
22</div>
<div class="line number23 index22 alt2">
23</div>
<div class="line number24 index23 alt1">
24</div>
<div class="line number25 index24 alt2">
25</div>
<div class="line number26 index25 alt1">
26</div>
<div class="line number27 index26 alt2">
27</div>
<div class="line number28 index27 alt1">
28</div>
<div class="line number29 index28 alt2">
29</div>
<div class="line number30 index29 alt1">
30</div>
<div class="line number31 index30 alt2">
31</div>
<div class="line number32 index31 alt1">
32</div>
<div class="line number33 index32 alt2">
33</div>
<div class="line number34 index33 alt1">
34</div>
<div class="line number35 index34 alt2">
35</div>
<div class="line number36 index35 alt1">
36</div>
<div class="line number37 index36 alt2">
37</div>
<div class="line number38 index37 alt1">
38</div>
<div class="line number39 index38 alt2">
39</div>
<div class="line number40 index39 alt1">
40</div>
<div class="line number41 index40 alt2">
41</div>
<div class="line number42 index41 alt1">
42</div>
<div class="line number43 index42 alt2">
43</div>
<div class="line number44 index43 alt1">
44</div>
<div class="line number45 index44 alt2">
45</div>
<div class="line number46 index45 alt1">
46</div>
<div class="line number47 index46 alt2">
47</div>
<div class="line number48 index47 alt1">
48</div>
<div class="line number49 index48 alt2">
49</div>
<div class="line number50 index49 alt1">
50</div>
<div class="line number51 index50 alt2">
51</div>
<div class="line number52 index51 alt1">
52</div>
<div class="line number53 index52 alt2">
53</div>
<div class="line number54 index53 alt1">
54</div>
<div class="line number55 index54 alt2">
55</div>
</td><td class="code" style="background-color: yellow;"><div class="container">
<div class="line number1 index0 alt2">
<code class="php plain"><?php</code></div>
<div class="line number2 index1 alt1">
<code class="php variable">$twitterUsername</code> <code class="php plain">= </code><code class="php string">"earthquake_jp"</code><code class="php plain">;</code></div>
<div class="line number3 index2 alt2">
<code class="php variable">$amountToShow</code> <code class="php plain">= 5;</code></div>
<div class="line number4 index3 alt1">
<code class="php variable">$twitterRssFeedUrl</code> <code class="php plain">= </code><code class="php string">'<a href="https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=">https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=</a>'</code><code class="php plain">.</code><code class="php variable">$twitterUsername</code><code class="php plain">.</code><code class="php string">'&count='</code><code class="php plain">.</code><code class="php variable">$amountToShow</code><code class="php plain">;</code></div>
<div class="line number5 index4 alt2">
</div>
<div class="line number6 index5 alt1">
<code class="php variable">$twitterPosts</code> <code class="php plain">= false;</code></div>
<div class="line number7 index6 alt2">
<code class="php variable">$xml</code> <code class="php plain">= @simplexml_load_file(</code><code class="php variable">$twitterRssFeedUrl</code><code class="php plain">);</code></div>
<div class="line number8 index7 alt1">
<code class="php keyword">if</code><code class="php plain">(</code><code class="php functions">is_object</code><code class="php plain">(</code><code class="php variable">$xml</code><code class="php plain">)){</code></div>
<div class="line number9 index8 alt2">
<code class="php keyword">foreach</code><code class="php plain">(</code><code class="php variable">$xml</code><code class="php plain">->channel->item </code><code class="php keyword">as</code> <code class="php variable">$twit</code><code class="php plain">){</code></div>
<div class="line number10 index9 alt1">
<code class="php keyword">if</code><code class="php plain">(</code><code class="php functions">is_array</code><code class="php plain">(</code><code class="php variable">$twitterPosts</code><code class="php plain">) && </code><code class="php functions">count</code><code class="php plain">(</code><code class="php variable">$twitterPosts</code><code class="php plain">)==</code><code class="php variable">$amountToShow</code><code class="php plain">){</code></div>
<div class="line number11 index10 alt2">
<code class="php keyword">break</code><code class="php plain">;</code></div>
<div class="line number12 index11 alt1">
<code class="php plain">}</code></div>
<div class="line number13 index12 alt2">
<code class="php variable">$d</code><code class="php plain">[</code><code class="php string">'title'</code><code class="php plain">] = </code><code class="php functions">stripslashes</code><code class="php plain">(htmlentities(</code><code class="php variable">$twit</code><code class="php plain">->title,ENT_QUOTES,</code><code class="php string">'UTF-8'</code><code class="php plain">));</code></div>
<div class="line number14 index13 alt1">
<code class="php variable">$description</code> <code class="php plain">= </code><code class="php functions">stripslashes</code><code class="php plain">(htmlentities(</code><code class="php variable">$twit</code><code class="php plain">->description,ENT_QUOTES,</code><code class="php string">'UTF-8'</code><code class="php plain">));</code></div>
<div class="line number15 index14 alt2">
<code class="php keyword">if</code><code class="php plain">(</code><code class="php functions">strtolower</code><code class="php plain">(</code><code class="php functions">substr</code><code class="php plain">(</code><code class="php variable">$description</code><code class="php plain">,0,</code><code class="php functions">strlen</code><code class="php plain">(</code><code class="php variable">$twitterUsername</code><code class="php plain">))) == </code><code class="php functions">strtolower</code><code class="php plain">(</code><code class="php variable">$twitterUsername</code><code class="php plain">)){</code></div>
<div class="line number16 index15 alt1">
<code class="php variable">$description</code> <code class="php plain">= </code><code class="php functions">substr</code><code class="php plain">(</code><code class="php variable">$description</code><code class="php plain">,</code><code class="php functions">strlen</code><code class="php plain">(</code><code class="php variable">$twitterUsername</code><code class="php plain">)+1);</code></div>
<div class="line number17 index16 alt2">
<code class="php plain">}</code></div>
<div class="line number18 index17 alt1">
<code class="php variable">$d</code><code class="php plain">[</code><code class="php string">'description'</code><code class="php plain">] = </code><code class="php variable">$description</code><code class="php plain">;</code></div>
<div class="line number19 index18 alt2">
<code class="php variable">$d</code><code class="php plain">[</code><code class="php string">'pubdate'</code><code class="php plain">] = </code><code class="php functions">strtotime</code><code class="php plain">(</code><code class="php variable">$twit</code><code class="php plain">->pubDate);</code></div>
<div class="line number20 index19 alt1">
<code class="php variable">$d</code><code class="php plain">[</code><code class="php string">'guid'</code><code class="php plain">] = </code><code class="php functions">stripslashes</code><code class="php plain">(htmlentities(</code><code class="php variable">$twit</code><code class="php plain">->guid,ENT_QUOTES,</code><code class="php string">'UTF-8'</code><code class="php plain">));</code></div>
<div class="line number21 index20 alt2">
<code class="php variable">$d</code><code class="php plain">[</code><code class="php string">'link'</code><code class="php plain">] = </code><code class="php functions">stripslashes</code><code class="php plain">(htmlentities(</code><code class="php variable">$twit</code><code class="php plain">->link,ENT_QUOTES,</code><code class="php string">'UTF-8'</code><code class="php plain">));</code></div>
<div class="line number22 index21 alt1">
<code class="php variable">$twitterPosts</code><code class="php plain">[]=</code><code class="php variable">$d</code><code class="php plain">;</code></div>
<div class="line number23 index22 alt2">
<code class="php plain">}</code></div>
<div class="line number24 index23 alt1">
<code class="php plain">}</code><code class="php keyword">else</code><code class="php plain">{</code></div>
<div class="line number25 index24 alt2">
</div>
<div class="line number26 index25 alt1">
<code class="php keyword">die</code><code class="php plain">(</code><code class="php string">'Can`t fetch the feed you requested'</code><code class="php plain">);</code></div>
<div class="line number27 index26 alt2">
<code class="php plain">}</code></div>
<div class="line number28 index27 alt1">
</div>
<div class="line number29 index28 alt2">
<code class="php plain">?></code></div>
<div class="line number30 index29 alt1">
<code class="php plain"><style></code></div>
<div class="line number31 index30 alt2">
<code class="php plain">a, a:link, a:visited, a:hover {</code></div>
<div class="line number32 index31 alt1">
<code class="php spaces"> </code><code class="php plain">color:#000;</code></div>
<div class="line number33 index32 alt2">
<code class="php plain">}</code></div>
<div class="line number34 index33 alt1">
<code class="php plain">.twitter {</code></div>
<div class="line number35 index34 alt2">
<code class="php spaces"> </code><code class="php plain">display:table-cell; vertical-align:middle;</code></div>
<div class="line number36 index35 alt1">
<code class="php spaces"> </code><code class="php plain">float:left;</code></div>
<div class="line number37 index36 alt2">
<code class="php spaces"> </code><code class="php plain">width:250px;</code></div>
<div class="line number38 index37 alt1">
<code class="php plain">}</code></div>
<div class="line number39 index38 alt2">
<code class="php plain"></style></code></div>
<div class="line number40 index39 alt1">
<code class="php plain"><!-- Insert your html here --></code></div>
<div class="line number41 index40 alt2">
<code class="php plain"><div </code><code class="php keyword">class</code><code class="php plain">=</code><code class="php string">"twitter"</code> <code class="php plain">id=</code><code class="php string">"jstweets"</code><code class="php plain">></code></div>
<div class="line number42 index41 alt1">
<code class="php spaces"> </code><code class="php plain"><?php</code></div>
<div class="line number43 index42 alt2">
<code class="php spaces"> </code><code class="php keyword">if</code><code class="php plain">(</code><code class="php functions">is_array</code><code class="php plain">(</code><code class="php variable">$twitterPosts</code><code class="php plain">)){</code></div>
<div class="line number44 index43 alt1">
<code class="php spaces"> </code><code class="php functions">echo</code> <code class="php string">''</code><code class="php plain">;</code></div>
<div class="line number45 index44 alt2">
<code class="php spaces"> </code><code class="php keyword">foreach</code><code class="php plain">(</code><code class="php variable">$twitterPosts</code> <code class="php keyword">as</code> <code class="php variable">$post</code><code class="php plain">){</code></div>
<div class="line number46 index45 alt1">
<code class="php variable">$data</code> <code class="php plain">= </code><code class="php variable">$post</code><code class="php plain">[</code><code class="php string">'description'</code><code class="php plain">];</code></div>
<div class="line number47 index46 alt2">
</div>
<div class="line number48 index47 alt1">
<code class="php functions">echo</code> <code class="php string">'<a href="{$post['</code><code class="php plain">link</code><code class="php string">']}">'</code><code class="php plain">.</code><code class="php variable">$data</code><code class="php plain">.</code><code class="php string">"<br >Updated on: "</code><code class="php plain">.</code><code class="php functions">date</code><code class="php plain">(</code><code class="php string">'l jS of F Y h:i:s A'</code><code class="php plain">,</code><code class="php variable">$post</code><code class="php plain">[</code><code class="php string">'pubdate'</code><code class="php plain">]).</code><code class="php string">'</a><br ><br >'</code><code class="php plain">;</code></div>
<div class="line number49 index48 alt2">
<code class="php spaces"> </code><code class="php plain">}</code></div>
<div class="line number50 index49 alt1">
<code class="php spaces"> </code><code class="php functions">echo</code> <code class="php string">''</code><code class="php plain">;</code></div>
<div class="line number51 index50 alt2">
<code class="php spaces"> </code><code class="php plain">}</code><code class="php keyword">else</code><code class="php plain">{</code></div>
<div class="line number52 index51 alt1">
<code class="php spaces"> </code><code class="php functions">echo</code> <code class="php string">'No Twitter posts have been made'</code><code class="php plain">;</code><code class="php comments">//Error message</code></div>
<div class="line number53 index52 alt2">
<code class="php spaces"> </code><code class="php plain">}</code></div>
<div class="line number54 index53 alt1">
<code class="php spaces"> </code><code class="php plain">?></code></div>
<div class="line number55 index54 alt2">
<code class="php plain"></div></code></div>
</div>
</td></tr>
</tbody></table>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-8436323971742330812013-02-18T16:07:00.001-08:002013-02-18T16:07:51.960-08:00Swing: User Interfaces in Java<div dir="ltr" style="text-align: left;" trbidi="on">
<div id="irc_mimg">
</div>
<div id="irc_mimg" style="text-align: center;">
<a data-ved="0CAgQjRwwAA" href="http://www.google.com/url?sa=i&source=images&cd=&docid=q6QUYUVU8IYLFM&tbnid=6ZfaV96Wd9qbjM:&ved=0CAgQjRwwAA&url=http%3A%2F%2Ffr.wikipedia.org%2Fwiki%2FFichier%3AJava_Logo.svg&ei=OMIiUaSUAcakrQHZy4DoBg&psig=AFQjCNEvwtDWHH0FizoMeoEoaEhDdt99HQ&ust=1361318840073005" id="irc_mil" style="border: 0px none;"><img height="579" id="irc_mi" src="http://upload.wikimedia.org/wikipedia/fr/2/2e/Java_Logo.svg" style="margin-top: 0px;" width="311" /></a></div>
<h1>
Swing: User Interfaces in Java</h1>
Java has a fairly rich framework for creating user interfaces "out of the box". That
framework is called <b>Swing</b>. Before learning Swing, it's worth making sure
that you really understand the following:<br />
<ul>
<li> the basic concepts of object-oriented programming (e.g. the notion
of classes, object creation, inheritance);
</li>
<li> basic Java syntax: how to call methods, how to create loops etc;
</li>
<li> <b>interfaces</b>, in the programming sense.
</li>
</ul>
Why am I being so insistent? Essentially, because the Swing framework
is highly object-oriented. It contains various classes that extend one another, and
the notion of extending a base class to add required functionality to that class is
key to user interface programming in Java (and indeed in other languages).
Another key part of Swing programming is the notion of <b>listeners</b>:
classes or components that "listen out for" a particular event happening such as a button
being clicked. And listeners are generally implemented as Java <i>interfaces</i> (in the
programming sense), so they're also an important notion to understand. We'll give
a brief review of interfaces as we go along, but it helps if you've come
across them before.
<br />
<div>
<div style="float: right; width: 404px;">
<img border="0" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=6EfLWVV23K8&bids=145238.168359&type=2&subid=0" width="1" />
</div>
<h2>
Introduction to the Swing and user interface packages</h2>
Many of the Swing classes representing windows, lists, buttons etc live
in the <tt>javax.swing</tt> package and subpackages. The names of most Swing classes
start with the letter <b>J</b>: <b>JFrame</b>, <b>JPanel</b>, <b>JButton</b>,
<b>JList</b> etc. In general, if you're looking for the class that represents some
visual component in Swing, its name will start with <b>J</b>.
<br />
A few classes also live in the <tt>java.awt</tt> package and subpackages.
AWT stands for <b>Abstract Window Toolkit</b> and was in some sense the precursor to
Swing. AWT provides a bare-bones way of creating a user interface, based
directly on "native" user interface components of the operating system. Swing actually
builds on AWT, and some AWT classes are still used directly in Swing programming. For
example, many of the classes responsible for laying out user interface components
lie inside the <tt>java.awt</tt> package, and many classes to do with handling
events live in <tt>java.awt.event</tt>; the <tt>Graphics</tt> interface, which represents
a graphics context and is key to rendering graphics inside a window or component,
is also originally part of the AWT package.
<br />
</div>
<h2>
Example: a first Swing application</h2>
By way of a vary basic example which we will extent on the next page,
the following application displays a window:
<br />
<div class="codefragment">
<pre>import javax.swing.JFrame;
public class MyApp {
public static void main(String[] args) {
// Actually slightly incorrect from a threading point of view
<b>JFrame frame = new JFrame("My Swing app");</b>
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
<b>frame.setVisible(true);</b>
}
}
</pre>
</div>
The
lines that arguably do most of the work are the ones in bold which construct
the window, specifically an instance of <b>JFrame</b>, and then make it visible.
We mentioned that user interface components are generally represented by classes
inside the <tt>javax.swing</tt> package with names beginning with <b>J</b>. In
this case, a "window with decorations" is strictly speaking called a <i>frame</i>,
and represented by the <b>JFrame</b> class. So creating a window means creating
an instance of <b>JFrame</b>. We construct one just like most Java objects: by
calling its constructor. Note that, as with many constructors, most allow us to
specify some common parameters: in this case, the title of the window.
<br />
The call to set the size of the window is hopefully self-explanatory once you see it;
let us just comment for now that in general, you need to think about the size (and
potentially layout) of all windows/components when you're programming with Swing.
The call to <tt>setDefaultCloseOperation()</tt> is a shortcut we can use in the
very simple case where we want our application to exit when the window is closed: Swing
will dutifully call <tt>System.exit()</tt> for us. We'll see later that we can
customise what happens when a window is closed.
<br />
<br /></div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-4385300230609077872013-01-31T14:04:00.002-08:002013-01-31T14:04:41.131-08:00Understanding HTTP Web Proxy Caching<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<img height="300" id="il_fi" src="http://www.journaldugeek.com/files/2013/01/http.jpg" style="padding-bottom: 8px; padding-right: 8px; padding-top: 8px;" width="400" /></div>
<br />
Internet users direct their requests to web servers all over the Internet.
A caching server must act as a <strong>web proxy server</strong> so it can serve those requests.
After a web proxy server receives requests for web objects, it either serves
the requests or forwards them to the <strong>origin server</strong> (the web server that
contains the original copy of the requested information). The Traffic Server
proxy supports <strong>explicit proxy caching</strong>, in which the user's client software
must be configured to send requests directly to the Traffic Server proxy. The
following overview illustrates how Traffic Server serves a request.<br />
<ol>
<li>
Traffic Server receives a client request for a web object. <br />
</li>
<li>
Using the object address, Traffic Server tries to locate the requested
object in its object database (<strong>cache</strong>). <br />
</li>
<li>
If the object is in the cache, then Traffic Server checks to see
if the object is fresh enough to serve. If it is fresh, then Traffic Server
serves it to the client as a <strong>cache hit</strong> (see the figure below).<br />
<img alt="A cache hit" src="http://trafficserver.apache.org/images/admin/cache_hit.jpg" /><br />
</li>
<li>
If the data in the cache is stale, then Traffic Server connects
to the origin server and checks if the object is still fresh (a <strong>revalidation</strong>).
If it is, then Traffic Server immediately sends the cached copy to the client. <br />
</li>
<li>
If the object is not in the cache (a <strong>cache miss</strong>) or if the server
indicates the cached copy is no longer valid, then Traffic Server obtains the
object from the origin server. The object is then simultaneously streamed to
the client and the Traffic Server local cache (see the figure below). Subsequent
requests for the object can be served faster because the object is retrieved
directly from cache.<br />
<img alt="A cache miss" src="http://trafficserver.apache.org/images/admin/cache_miss.jpg" /><br />
</li>
</ol>
Caching is typically more complex than the preceding overview suggests. In
particular, the overview does not discuss how Traffic Server ensures freshness,
serves correct HTTP alternates, and treats requests for objects that cannot/should
not be cached. The following sections discuss these issues in greater detail. <br />
<h1 id="EnsuringCachedObjectFreshness">
Ensuring Cached Object Freshness</h1>
When Traffic Server receives a request for a web object, it first tries to
locate the requested object in its cache. If the object is in cache, then Traffic
Server checks to see if the object is fresh enough to serve. For HTTP objects,
Traffic Server supports optional author-specified expiration dates. Traffic
Server adheres to these expiration dates; otherwise, it picks an expiration
date based on how frequently the object is changing and on administrator-chosen
freshness guidelines. Objects can also be revalidated by checking with the
origin server to see if an object is still fresh. <br />
<h2 id="HTTPObjectFreshness">
HTTP Object Freshness</h2>
Traffic Server determines whether an HTTP object in the cache is fresh by: <br />
<ul>
<li>
<strong>Checking the <code>Expires</code> or <code>max-age</code> header</strong><br />
Some HTTP objects contain <code>Expires</code> headers or <code>max-age</code> headers that
explicitly define how long the object can be cached. Traffic Server
compares the current time with the expiration time to determine if the
object is still fresh.<br />
</li>
<li>
<strong>Checking the <code>Last-Modified</code> / <code>Date</code> header</strong><br />
If an HTTP object has no <code>Expires</code> header or <code>max-age</code> header, then
Traffic Server can calculate a freshness limit using the following formula: <br />
<br />
<div class="codehilite">
<pre><span class="n">freshness_limit</span> <span class="o">=</span> <span class="p">(</span> <span class="n">date</span> <span class="o">-</span> <span class="n">last_modified</span> <span class="p">)</span> <span class="o">*</span> <span class="mf">0.10</span>
</pre>
</div>
where <em><code>date</code></em> is the date in the object's server response header and <em><code>last_modified</code></em>
is the date in the <code>Last-Modified</code> header. If there is no <code>Last-Modified</code> header, then
Traffic Server uses the date the object was written to cache. The value <code>0.10</code>
(10 percent) can be increased or reduced to better suit your needs (refer to
<a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ModifyingAgingFactorFreshnessComputations">Modifying the Aging Factor for Freshness Computations</a>).<br />
<br />
The computed freshness limit is bound by a minimum and maximum value - refer to
<a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#SettingAbsoluteFreshnessLimit">Setting an Absolute Freshness Limit</a> for more information.<br />
</li>
<li>
<strong>Checking the absolute freshness limit</strong><br />
For HTTP objects that do not have <code>Expires</code> headers or do not have both <code>Last-Modified</code>
and <code>Date</code> headers, Traffic Server uses a maximum and minimum freshness limit
(refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#SettingAbsoluteFreshnessLimit">Setting an Absolute Freshness Limit</a>).<br />
</li>
<li>
<strong>Checking revalidate rules in the <code>cache.config</code> file</strong><br />
Revalidate rules apply freshness limits to specific HTTP objects. You can set freshness
limits for objects originating from particular domains or IP addresses, objects with URLs
that contain specified regular expressions, objects requested by particular clients,
and so on (refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config"><code>cache.config</code></a>).<br />
</li>
</ul>
<h2 id="ModifyingAgingFactorFreshnessComputations">
Modifying Aging Factor for Freshness Computations</h2>
If an object does not contain any expiration information, then Traffic Server
can estimate its freshness from the <code>Last-Modified</code> and <code>Date</code> headers. By
default, Traffic Server stores an object for 10% of the time that elapsed since
it last changed. You can increase or reduce the percentage according to your
needs. <br />
To modify the aging factor for freshness computations<br />
<ol>
<li>Edit the following variables in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.heuristic_lm_factor"><em><code>proxy.config.http.cache.heuristic_lm_factor</code></em></a></li>
</ul>
</li>
<li>Run the <code>traffic_line -x</code> command to apply the configuration changes.</li>
</ol>
<h2 id="SettinganAbsoluteFreshnessLimit">
Setting absolute Freshness Limits</h2>
Some objects do not have <code>Expires</code> headers or do not have both <code>Last-Modified</code>
and <code>Date</code> headers. To control how long these objects are considered fresh
in the cache, specify an <strong>absolute freshness limit</strong>.<br />
To specify an absolute freshness limit<br />
<ol>
<li>Edit the following variables in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.heuristic_min_lifetime"><em><code>proxy.config.http.cache.heuristic_min_lifetime</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.heuristic_max_lifetime"><em><code>proxy.config.http.cache.heuristic_max_lifetime</code></em></a></li>
</ul>
</li>
<li>Run the <code>traffic_line -x</code> command to apply the configuration changes.</li>
</ol>
<h2 id="SpecifyingHeaderRequirements">
Specifying Header Requirements</h2>
To further ensure freshness of the objects in the cache, configure Traffic
Server to cache only objects with specific headers. By default, Traffic Server
caches all objects (including objects with no headers); you should change the
default setting only for specialized proxy situations. If you configure Traffic
Server to cache only HTTP objects with <code>Expires</code> or <code>max-age</code> headers, then
the cache hit rate will be noticeably reduced (since very few objects will
have explicit expiration information).<br />
To configure Traffic Server to cache objects with specific headers<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.required_headers"><em><code>proxy.config.http.cache.required_headers</code></em></a></li>
</ul>
</li>
<li>Run the <code>traffic_line -x</code> command to apply the configuration changes.</li>
</ol>
<h2 id="Cache-ControlHeaders">
Cache-Control Headers</h2>
Even though an object might be fresh in the cache, clients or servers often
impose their own constraints that preclude retrieval of the object from the
cache. For example, a client might request that a object <em>not</em> be retrieved
from a cache, or if it does, then it cannot have been cached for more than
10 minutes. Traffic Server bases the servability of a cached object on <code>Cache-Control</code>
headers that appear in both client requests and server responses. The following
<code>Cache-Control</code> headers affect whether objects are served from cache: <br />
<ul>
<li>
The <code>no-cache</code> header, sent by clients, tells Traffic Server that it should
not to serve any objects directly from the cache; therefore, Traffic Server will
always obtain the object from the origin server. You can configure Traffic Server
to ignore client <code>no-cache</code> headers - refer to
<a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ConfiguringTSIgnoreClientnocacheHeaders">Configuring Traffic Server to Ignore Client no-cache Headers</a> for more information.<br />
</li>
<li>
The <code>max-age</code> header, sent by servers, is compared to the object age.
If the age is less than <code>max-age</code>, then the object is fresh and can be served.<br />
</li>
<li>
The <code>min-fresh</code> header, sent by clients, is an <strong>acceptable freshness tolerance</strong>.
This means that the client wants the object to be at least this fresh.
Unless a cached object remains fresh at least this long in the future, it is revalidated. <br />
</li>
<li>
The <code>max-stale</code> header, sent by clients, permits Traffic Server to serve stale
objects provided they are not too old. Some browsers might be willing to take
slightly stale objects in exchange for improved performance, especially during
periods of poor Internet availability. <br />
</li>
</ul>
Traffic Server applies <code>Cache-Control</code> servability criteria <strong><em>after</em></strong> HTTP freshness
criteria. For example, an object might be considered fresh but will not be
served if its age is greater than its <code>max-age</code>.<br />
<h2 id="RevalidatingHTTPObjects">
Revalidating HTTP Objects</h2>
When a client requests an HTTP object that is stale in the cache, Traffic Server
revalidates the object. A <strong>revalidation</strong> is a query to the origin server
to check if the object is unchanged. The result of a revalidation is one of
the following:<br />
<ul>
<li>
If the object is still fresh, then Traffic Server resets its freshness
limit and serves the object. <br />
</li>
<li>
If a new copy of the object is available, then Traffic Server caches the
new object (thereby replacing the stale copy) and simultaneously serves the object to the client. <br />
</li>
<li>
If the object no longer exists on the origin server, then Traffic Server
does not serve the cached copy. <br />
</li>
<li>
If the origin server does not respond to the revalidation query, then
Traffic Server serves the stale object along with a <code>111 Revalidation Failed</code> warning. <br />
</li>
</ul>
By default, Traffic Server revalidates a requested HTTP object in the cache
if it considers the object to be stale. Traffic Server evaluates object freshness
as described in <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#HTTPObjectFreshness">HTTP Object Freshness</a>. You can reconfigure
how Traffic Server evaluates freshness by selecting one of the following options: <br />
<ul>
<li>Traffic Server considers all HTTP objects in the cache to be stale:
always revalidate HTTP objects in the cache with the origin server.</li>
<li>Traffic Server considers all HTTP objects in the cache to be fresh:
never revalidate HTTP objects in the cache with the origin server. </li>
<li>Traffic Server considers all HTTP objects without <code>Expires</code> or <code>Cache-control</code> headers to be stale: revalidate all HTTP objects without <code>Expires</code> or <code>Cache-Control</code> headers. </li>
</ul>
To configure how Traffic Server revalidates objects in the cache, you can set
specific revalidation rules in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>cache.config</code></a>. <br />
To configure revalidation options<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.when_to_revalidate"><em><code>proxy.config.http.cache.when_to_revalidate</code></em></a></li>
</ul>
</li>
<li>Run the <code>traffic_line -x</code> command to apply the configuration changes.</li>
</ol>
<h1 id="SchedulingUpdatesLocalCacheContent">
Scheduling Updates to Local Cache Content</h1>
To further increase performance and to ensure that HTTP objects are fresh in
the cache, you can use the <strong>Scheduled Update</strong> option. This configures Traffic
Server to load specific objects into the cache at scheduled times. You might
find this especially beneficial in a reverse proxy setup, where you can
<em>preload</em> content you anticipate will be in demand. <br />
To use the Scheduled Update option, you must perform the following tasks. <br />
<ul>
<li>Specify the list of URLs that contain the objects you want to schedule for update,</li>
<li>the time the update should take place,</li>
<li>and the recursion depth for the URL.</li>
<li>Enable the scheduled update option and configure optional retry settings.</li>
</ul>
Traffic Server uses the information you specify to determine URLs for which
it is responsible. For each URL, Traffic Server derives all recursive URLs
(if applicable) and then generates a unique URL list. Using this list, Traffic
Server initiates an HTTP <code>GET</code> for each unaccessed URL. It ensures that it remains
within the user-defined limits for HTTP concurrency at any given time. The
system logs the completion of all HTTP <code>GET</code> operations so you can monitor
the performance of this feature. <br />
Traffic Server also provides a <strong>Force Immediate Update</strong> option that enables
you to update URLs immediately without waiting for the specified update time
to occur. You can use this option to test your scheduled update configuration
(refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ForcingImmediateUpdate">Forcing an Immediate Update</a>). <br />
<h2 id="ConfiguringScheduledUpdateOption">
Configuring the Scheduled Update Option</h2>
To configure the scheduled update option<br />
<ol>
<li>Edit <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/update.config"><code>update.config</code></a> to enter a line in the file for each URL you want to update.</li>
<li>Edit the following variables in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.enabled"><em><code>proxy.config.update.enabled</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.retry_count"><em><code>proxy.config.update.retry_count</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.retry_interval"><em><code>proxy.config.update.retry_interval</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.concurrent_updates"><em><code>proxy.config.update.concurrent_updates</code></em></a></li>
</ul>
</li>
<li>Run the <code>traffic_line -x</code> command to apply the configuration changes.</li>
</ol>
<h2 id="ForcingImmediateUpdate">
Forcing an Immediate Update</h2>
Traffic Server provides a <strong>Force Immediate Update</strong> option that enables you
to immediately verify the URLs listed in the <code>update.config</code> file. The Force
Immediate Update option disregards the offset hour and interval set in the
<code>update.config</code> file and immediately updates the URLs listed. <br />
To configure the Force Immediate Update option<br />
<ol>
<li>Edit the following variables in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.force"><em><code>proxy.config.update.force</code></em></a></li>
<li>Make sure the variable <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.enabled"><em><code>proxy.config.update.enabled</code></em></a> is set to 1.</li>
</ul>
</li>
<li>Run the <code>command traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<strong>IMPORTANT:</strong> When you enable the Force Immediate Update option, Traffic Server
continually updates the URLs specified in the <code>update.config</code> file until you
disable the option. To disable the Force Immediate Update option, set the variable
<a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.update.force"><em><code>proxy.config.update.force</code></em></a> to <code>0</code> (zero).<br />
<h1 id="PushingContentintoCache">
Pushing Content into the Cache</h1>
Traffic Server supports the HTTP <code>PUSH</code> method of content delivery. Using HTTP
<code>PUSH</code>, you can deliver content directly into the cache without client requests. <br />
<h2 id="ConfiguringTSPUSHRequests">
Configuring Traffic Server for PUSH Requests</h2>
Before you can deliver content into your cache using HTTP <code>PUSH</code>, you must
configure Traffic Server to accept <code>PUSH</code> requests.<br />
To configure Traffic Server to accept <code>PUSH</code> requests<br />
<ol>
<li>Edit <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a>, modify the super mask to allow <code>PUSH</code> request.<ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.quick_filter.mask"><em><code>proxy.config.http.quick_filter.mask</code></em></a></li>
</ul>
</li>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a>, enable the push_method.<ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.push_method_enabled"><em><code>proxy.config.http.push_method_enabled</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h2 id="UnderstandingHTTPPUSH">
Understanding HTTP PUSH</h2>
<code>PUSH</code> uses the HTTP 1.1 message format. The body of a <code>PUSH</code> request contains
the response header and response body that you want to place in the cache.
The following is an example of a <code>PUSH</code> request: <br />
<div class="codehilite">
<pre>PUSH http://www.company.com HTTP/1.0
Content-length: 84
HTTP/1.0 200 OK
Content-type: text/html
Content-length: 17
<span class="nt"><HTML></span>
a
<span class="nt"></HTML></span>
</pre>
</div>
<strong>IMPORTANT:</strong> Your header must include <code>Content-length</code> - <code>Content-length</code>
must include both <code>header</code> and <code>body byte count</code>.<br />
<h2 id="ToolsForHTTPPUSH">
Tools that will help manage pushing</h2>
There is a perl script for pushing, <a href="http://git-wip-us.apache.org/repos/asf?p=trafficserver.git;a=blob;f=tools/push.pl"><code>tools/push.pl</code></a>, which can help you understanding how to write some script for pushing content.<br />
<h1 id="PinningContentinCache">
Pinning Content in the Cache</h1>
The <strong>Cache Pinning Option</strong> configures Traffic Server to keep certain HTTP
objects in the cache for a specified time. You can use this option to ensure
that the most popular objects are in cache when needed and to prevent Traffic
Server from deleting important objects. Traffic Server observes <code>Cache-Control</code>
headers and pins an object in the cache only if it is indeed cacheable.<br />
To set cache pinning rules<br />
<ol>
<li>
Make sure the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a> is set<br />
<ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.permit.pinning"><em><code>proxy.config.cache.permit.pinning</code></em></a></li>
</ul>
</li>
<li>
Add a rule in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config"><code>cache.config</code></a> for each URL you want Traffic Server to pin in the cache. For example:<br />
<div class="codehilite">
<pre>url_regex=^https?://(www.)?apache.org/dev/ pin-in-cache=12h
</pre>
</div>
</li>
<li>
Run the command <code>traffic_line -x</code> to apply the configuration changes. <br />
</li>
</ol>
<h1 id="CacheNotCache">
To Cache or Not to Cache?</h1>
When Traffic Server receives a request for a web object that is not in the
cache, it retrieves the object from the origin server and serves it to the
client. At the same time, Traffic Server checks if the object is cacheable
before storing it in its cache to serve future requests. <br />
<h1 id="CachingHTTPObjects">
Caching HTTP Objects</h1>
Traffic Server responds to caching directives from clients and origin servers,
as well as directives you specify through configuration options and files. <br />
<h2 id="ClientDirectives">
Client Directives</h2>
By default, Traffic Server does <em>not</em> cache objects with the following <strong>request
headers</strong>: <br />
<ul>
<li>
<code>Authorization</code>: header <br />
</li>
<li>
<code>Cache-Control: no-store</code> header <br />
</li>
<li>
<code>Cache-Control: no-cache</code> header<br />
To configure Traffic Server to ignore the <code>Cache-Control: no-cache</code> header,
refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ConfiguringTSIgnoreClientnocacheHeaders">Configuring Traffic Server to Ignore Client no-cache Headers</a>. <br />
</li>
<li>
<code>Cookie</code>: header (for text objects) <br />
By default, Traffic Server caches objects served in response to requests that
contain cookies (unless the object is text). You can configure Traffic Server
to not cache cookied content of any type, cache all cookied content, or cache
cookied content that is of image type only. For more information,
refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#CachingCookiedObjects">Caching Cookied Objects</a>.<br />
</li>
</ul>
<h3 id="ConfiguringTSIgnoreClientnocacheHeaders">
Configuring Traffic Server to Ignore Client no-cache Headers</h3>
By default, Traffic Server strictly observes client <code>Cache-Control: no-cache</code>
directives. If a requested object contains a <code>no-cache</code> header, then Traffic
Server forwards the request to the origin server even if it has a fresh copy
in cache. You can configure Traffic Server to ignore client <code>no-cache</code> directives
such that it ignores <code>no-cache</code> headers from client requests and serves the
object from its cache. <br />
To configure Traffic Server to ignore client <code>no-cache</code> headers<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.ignore_client_no_cache"><em><code>proxy.config.cache.ignore_client_no_cache</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h2 id="OriginServerDirectives">
Origin Server Directives</h2>
By default, Traffic Server does <em>not</em> cache objects with the following <strong>response</strong>
<strong>headers</strong>: <br />
<ul>
<li><code>Cache-Control: no-store</code> header </li>
<li><code>Cache-Control: private</code> header </li>
<li>
<code>WWW-Authenticate</code>: header<br />
To configure Traffic Server to ignore<code>WWW-Authenticate</code> headers,
refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ConfiguringTrafficEdgeIgnoreWWWAuthenticateHeaders">Configuring Traffic Server to Ignore WWW-Authenticate Headers</a>. <br />
</li>
<li>
<code>Set-Cookie</code>: header <br />
</li>
<li>
<code>Cache-Control: no-cache</code> headers<br />
To configure Traffic Server to ignore <code>no-cache</code> headers,
refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#ConfiguringTrafficEdgeIgnoreServerNoCacheHeaders">Configuring Traffic Server to Ignore Server no-cache Headers</a>. <br />
</li>
<li>
<code>Expires</code>: header with value of 0 (zero) or a past date <br />
</li>
</ul>
<h3 id="ConfiguringTSIgnoreServernocacheHeaders">
Configuring Traffic Server to Ignore Server no-cache Headers</h3>
By default, Traffic Server strictly observes <code>Cache-Control: no-cache</code> directives.
A response from an origin server with a <code>no-cache</code> header is not stored in
the cache and any previous copy of the object in the cache is removed. If you
configure Traffic Server to ignore <code>no-cache</code> headers, then Traffic Server
also ignores <code>no-</code><strong><code>store</code></strong> headers. The default behavior of observing <code>no-cache</code>
directives is appropriate in most cases. <br />
To configure Traffic Server to ignore server <code>no-cache</code> headers<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.ignore_server_no_cache"><em><code>proxy.config.cache.ignore_server_no_cache</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h3 id="ConfiguringTSIgnoreWWWAuthenticateHeaders">
Configuring Traffic Server to Ignore WWW-Authenticate Headers</h3>
By default, Traffic Server does not cache objects that contain <code>WWW-Authenticate</code>
response headers. The <code>WWW-Authenticate</code> header contains authentication parameters
the client uses when preparing the authentication challenge response to an
origin server. <br />
When you configure Traffic Server to ignore origin server <code>WWW-Authenticate</code>
headers, all objects with <code>WWW-Authenticate</code> headers are stored in the cache
for future requests. However, the default behavior of not caching objects with
<code>WWW-Authenticate</code> headers is appropriate in most cases. Only configure Traffic
Server to ignore server <code>WWW-Authenticate</code> headers if you are knowledgeable
about HTTP 1.1.<br />
To configure Traffic Server to ignore server <code>WWW-Authenticate</code> headers<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.ignore_authentication"><em><code>proxy.config.cache.ignore_authentication</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h2 id="ConfigurationDirectives">
Configuration Directives</h2>
In addition to client and origin server directives, Traffic Server responds to directives
you specify through configuration options and files.<br />
You can configure Traffic Server to do the following: <br />
<ul>
<li><em>Not</em> cache any HTTP objects (refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#DisablingHTTPObjectCaching">Disabling HTTP Object Caching</a>).</li>
<li>Cache <strong>dynamic content</strong> - that is, objects with URLs that end in <strong><code>.asp</code></strong> or contain a question mark (<strong><code>?</code></strong>),
semicolon (<strong><code>;</code></strong>), or <strong><code>cgi</code></strong>. For more information, refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#CachingDynamicContent">Caching Dynamic Content</a>. </li>
<li>Cache objects served in response to the <code>Cookie:</code> header (refer to <a href="http://trafficserver.apache.org/docs/trunk/admin/http-proxy-caching/index.en.html#CachingCookiedObjects">Caching Cookied Objects)</a>. </li>
<li>Observe <code>never-cache</code> rules in the <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config"><code>cache.config</code></a> file.</li>
</ul>
<h3 id="DisablingHTTPObjectCaching">
Disabling HTTP Object Caching</h3>
By default, Traffic Server caches all HTTP objects except those for which you
have set <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config#action"><code>never-cache</code></a> rules in the
<a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config"><code>cache.config</code></a> file. You can disable HTTP
object caching so that all HTTP objects are served directly from the origin
server and never cached, as detailed below.<br />
To disable HTTP object caching manually<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.http"><em><code>proxy.config.cache.http</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes.</li>
</ol>
<h3 id="CachingDynamicContent">
Caching Dynamic Content</h3>
A URL is considered <strong>dynamic</strong> if it ends in <strong><code>.asp</code></strong> or contains a question
mark (<strong><code>?</code></strong>), a semicolon (<strong><code>;</code></strong>), or <strong><code>cgi</code></strong>. By default, Traffic Server
caches dynamic content. You can configure the system to ignore dyanamic looking
content, although this is recommended only if the content is <em>truely</em> dyanamic,
but fails to advertise so with appropriate <code>Cache-Control</code> headers.<br />
To configure Traffic Server's cache behaviour in regard to dynamic content<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.cache_urls_that_look_dynamic"><em><code>proxy.config.http.cache.cache_urls_that_look_dynamic</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes.</li>
</ol>
<h3 id="CachingCookiedObjects">
Caching Cookied Objects</h3>
By default, Traffic Server caches objects served in response to requests that
contain cookies. This is true for all types of objects except for text.
Traffic Server does not cache cookied text content because object headers are
stored along with the object, and personalized cookie header values could be
saved with the object. With non-text objects, it is unlikely that personalized
headers are delivered or used. <br />
You can reconfigure Traffic Server to: <br />
<ul>
<li><em>Not</em> cache cookied content of any type. </li>
<li>Cache cookied content that is of image type only. </li>
<li>Cache all cookied content regardless of type.</li>
</ul>
To configure how Traffic Server caches cookied content<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache_responses_to_cookies"><em><code>proxy.config.cache_responses_to_cookies</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h1 id="ForcingObjectCaching">
Forcing Object Caching</h1>
You can force Traffic Server to cache specific URLs (including dynamic URLs)
for a specified duration, regardless of <code>Cache-Control</code> response headers. <br />
To force document caching<br />
<ol>
<li>
Add a rule for each URL you want Traffic Server to pin to the cache <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/cache.config"><code>cache.config</code></a>:<br />
<div class="codehilite">
<pre>url_regex=^https?://(www.)?apache.org/dev/ ttl-in-cache=6h
</pre>
</div>
</li>
<li>
Run the command <code>traffic_line -x</code> to apply the configuration changes. <br />
</li>
</ol>
<h1 id="CachingHTTPAlternates">
Caching HTTP Alternates</h1>
Some origin servers answer requests to the same URL with a variety of objects.
The content of these objects can vary widely, according to whether a server
delivers content for different languages, targets different browsers with different
presentation styles, or provides different document formats (HTML, XML). Different
versions of the same object are termed <strong>alternates</strong> and are cached by Traffic
Server based on <code>Vary</code> response headers. You can specify additional request
and response headers for specific <code>Content-Type</code>s that Traffic Server will identify
as alternates for caching. You can also limit the number of alternate versions
of an object allowed in the cache. <br />
<h2 id="ConfiguringHowTSCachesAlternates">
Configuring How Traffic Server Caches Alternates</h2>
To configure how Traffic Server caches alternates, follow the steps below<br />
<ol>
<li>Edit the following variables in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.enable_default_vary_headers"><em><code>proxy.config.http.cache.enable_default_vary_headers</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.vary_default_text"><em><code>proxy.config.http.cache.vary_default_text</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.vary_default_images"><em><code>proxy.config.http.cache.vary_default_images</code></em></a></li>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.cache.vary_default_other"><em><code>proxy.config.http.cache.vary_default_other</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<strong>Note:</strong> If you specify <code>Cookie</code> as the header field on which to vary in the above variables,
make sure that the variable <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.cache_responses_to_cookies"><em><code>proxy.config.cache.cache_responses_to_cookies</code></em></a> is set appropriately.<br />
<h2 id="LimitingNumberofAlternatesforanObject">
Limiting the Number of Alternates for an Object</h2>
You can limit the number of alternates Traffic Server can cache per object
(the default is 3). <br />
<strong>IMPORTANT:</strong> Large numbers of alternates can affect Traffic Server cache
performance because all alternates have the same URL. Although Traffic Server
can look up the URL in the index very quickly, it must scan sequentially through
available alternates in the object store.<br />
To limit the number of alternates<br />
<ol>
<li>Edit the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.cache.limits.http.max_alts"><em><code>proxy.config.cache.limits.http.max_alts</code></em></a></li>
</ul>
</li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
<h1 id="UsingCongestionControl">
Using Congestion Control</h1>
The <strong>Congestion Control</strong> option enables you to configure Traffic Server to
stop forwarding HTTP requests to origin servers when they become congested.
Traffic Server then sends the client a message to retry the congested origin
server later. <br />
To use the <strong>Congestion Control</strong> option, you must perform the following tasks: <br />
<ol>
<li>Set the following variable in <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config"><code>records.config</code></a><ul>
<li><a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/records.config#proxy.config.http.congestion_control.enabled"><em><code>proxy.config.http.congestion_control.enabled</code></em></a> to <code>1</code></li>
</ul>
</li>
<li>Create rules in the <a href="http://trafficserver.apache.org/docs/trunk/admin/configuration-files/congestion.config"><code>congestion.config</code></a> file to specify: </li>
<li>which origin servers Traffic Server tracks for congestion</li>
<li>the timeouts Traffic Server uses, depending on whether a server is congested </li>
<li>the page Traffic Server sends to the client when a server becomes congested </li>
<li>if Traffic Server tracks the origin servers per IP address or per hostname </li>
<li>Run the command <code>traffic_line -x</code> to apply the configuration changes. </li>
</ol>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-25649405584795360852013-01-31T12:39:00.002-08:002013-01-31T12:39:47.003-08:00Microsoft Word 2010 Tips And Tricks<div dir="ltr" style="text-align: left;" trbidi="on">
Microsoft Word 2010 is one of our favorite text editors. With such a
big array of features, Microsoft Office Word 2010 can look complicated.
There are many hidden tricks and shortcuts that make text editing
easier. Here are some tips I think will help you when you are using
Microsoft Word 2010.<br />
<h2>
Microsoft Word 2010 Tips And Tricks</h2>
<strong>1. Vertical Selection Of Text</strong><br />
Normally, we select a character, a word, a sentence or a paragraph.
All these selections are horizontal selections. Sometimes you may need
to select vertically. For example, if your text has numbers in the
beginning, you may want to select only the numbers to delete them at one
go (see figure).<br />
<img alt="Fig 1 Vertical Selection 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-full wp-image-50121" height="196" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-1-Vertical-Selection.png" title="Fig 1 Vertical Selection" width="285" /><br />
To select text horizontally, press ALT and click to drag and make a
selection. Remember to release ALT key before releasing mouse else it
will open the Research dialog. Check out the different uses of vertical
selections and let us know what all you did with this feature.<br />
<strong>2. Default Line Spacing</strong><br />
The default line spacing in Microsoft Word 2010 is 1.15 against 1 in
Microsoft Word 2003. Microsoft changed the line spacing to make your
text more readable. If you want the default line spacing as 1, follow
this procedure:<br />
<ol>
<li>While on the Home tab, right click on the Normal quick style button and select Modify</li>
<li>In the Format list that appears, select Paragraph</li>
<li>Under spacing, change the line spacing from 1.15 to 1</li>
<li>Click OK</li>
<li>Check the box against “New documents based on this template”</li>
<li>Click OK</li>
</ol>
<img alt="Fig 2 Change Default Line Spacing 373x400 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-medium wp-image-50122" height="400" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-2-Change-Default-Line-Spacing-373x400.png" title="Fig 2 Change Default Line Spacing 373x400" width="373" /><br />
<strong>3. Changing The Default Save Location</strong><br />
By default, MS Word opens Documents folder when you press CTRL+S for
first time. If you think this is irritating you, you can change the
default file location to some other place where you normally store your
documents.<br />
<ol>
<li>Click on File</li>
<li>Click on Options</li>
<li>Click Advanced in the left side of the window that appears</li>
<li>In the right part of the window, scroll down to the button that says “File Locations”</li>
<li>Select Documents and click on Modify</li>
<li>In the Save File dialog box that appears, enter or select the new path and click on OK to close the Save File dialog box.</li>
<li>Click OK to close the window.</li>
</ol>
<img alt="Fig 3 Change Default Word Save Location 400x321 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-medium wp-image-50123" height="321" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-3-Change-Default-Word-Save-Location-400x321.png" title="Fig 3 Change Default Word Save Location 400x321" width="400" /><br />
<strong>4. Change Default Font</strong><br />
The default font for new documents in MS Word 2010 is Calibri. Though
the font is good for online viewing, it creates problems when printing.
You may be using Times New Roman or Arial for print jobs. One method is
to change the font manually each time after you have typed the
document. But then, it would involve formatting the document again.
Another method is to change the default font.<br />
<ol>
<li>Right click on the Normal quick style button on Home tab.</li>
<li>Click Modify</li>
<li>In the dialog box that appears, click on Format… to open the drop down menu and select Font</li>
<li>In the Font dialog box, select the font you wish to use with every document.</li>
<li>Make any other changes you wish such as font size etc</li>
<li>Click OK</li>
<li>Click to select “New documents based on this template”</li>
<li>Click OK to close the Modify dialog box.</li>
</ol>
<img alt="Fig 4 Change Default Font In MS Word 2010 400x355 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-medium wp-image-50124" height="355" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-4-Change-Default-Font-In-MS-Word-2010-400x355.png" title="Fig 4 Change Default Font In MS Word 2010 400x355" width="400" /><br />
<strong>5. Move Rows Of Text In Table</strong><br />
Sometimes when you are working on the table, you may want to move one
or more rows in the table up or down without having to change the table
formatting. One method is copy pasting but that risks formatting.<br />
Another method is using ALT+SHIFT+UP arrow key to move entire row up.
Similarly, to move the entire row down, use ALT+SHIFT+DN arrow key.
Note that you have to select the row before you can move it using the
ALT+SHIFT+Arrow keys. This method makes sure the formatting is not
disturbed.<br />
<strong>6. Quickly Change Line Spacing</strong><br />
Sometimes need arises that you have to change line spacing among different paragraphs. Here are the shortcut keys:<br />
CTRL + 1 –> Change line spacing to 1<br />
CTRL + 2 –> Change line spacing to 2<br />
CTRL + 5 –> Change line spacing to 1.5<br />
Note that you just need to place the cursor on the paragraph that needs to be styled. You need not select the paragraph.<br />
<strong>7. Quickly Adding Borders to Paragraphs</strong><br />
If you wish to add borders to some paragraph, you can use the Borders
and Shading dialog box. However, if your need is just to add bottom
border to text/paragraph, you can do it by adding three special
characters and hitting Enter.<br />
Press – (hyphen) three times and press Enter to draw an underline border of 3/4 points<br />
Press _ (underscore) three times and press Enter to draw an underline border of 1.5 points<br />
Press ~ (tilde) three times and press Enter to draw a zigzag underline border<br />
Press * (asterisk) three times and press Enter to draw a dotted underline border<br />
Press = (equal to) three times and press Enter to draw a double underline border<br />
<strong>8. Find Special Formatting</strong><br />
You can find text that is specially formatted. For example, you can
find highlighted text or text whose font is Times New Roman. You can
also search for bold text or italics. There are many more options when
you use the Find option.<br />
<ol>
<li>Press CTRL+F to open the Find pane. In Word 2010 it appears to the left side of the window.</li>
<li>Click on the down facing triangle next to magnifying glass and click on Advanced Find…</li>
<li>In the Find dialog box that appears, click on More.</li>
<li>You can see plenty of options under Format.</li>
<li>When you select anything, it appears under the “Find What” textbox.
When you click Find Next without entering anything in the “Find What”
text box, it searches for the format you have selected. For example, you
can select Font and in the Font dialog box, select a font and its
properties (bold, italics etc).</li>
</ol>
<img alt="Fig 5 Find Special Formatting 400x334 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-medium wp-image-50125" height="334" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-5-Find-Special-Formatting-400x334.png" title="Fig 5 Find Special Formatting 400x334" width="400" /><br />
<strong>9. Merging Formatting When Pasting Across Documents</strong><br />
When you copy anything from another document and paste it in the
current document, you will want the copied text to match the formatting
of the current document. While you can manually format each time you
copy text from other documents to the current one, you can also set the
default paste to merge formatting so that the text copied from other
sources acquires formatting of current document.<br />
<ol>
<li>To set the default formatting, click on the down facing triangle below Paste on Home tab</li>
<li>Click Set Default Paste</li>
<li>In the window that appears, Select Merge Destinations in: 1: When
Pasting in Same Document and 2: When Pasting between Documents.</li>
<li>Click OK to close the window</li>
</ol>
<img alt="Fig 5 Paste defaults 400x326 10 Most Useful Microsoft Word 2010 Tips & Tricks" class="aligncenter size-medium wp-image-50126" height="326" src="http://www.thewindowsclub.com/wp-content/uploads/2012/06/Fig-5-Paste-defaults-400x326.png" title="Fig 5 Paste defaults 400x326" width="400" /><br />
<strong>10. Copy Only Formatting</strong><br />
Sometimes you may want to apply an already existing formatting from
one part of your document to another part. You have the Format Painter
for the purpose. Using the Format Painter can be irritating when dealing
with long documents. Here is another method that is easier to use.<br />
Press CTRL+SHIFT+C instead of CTRL+C. This will copy only the formatting and leave the text.<br />
Move to the destination where the formatting is to be applied. Select
the text to which formatting is to be applied. Press CTRL+SHIFT+V to
paste the formatting to the selection.<br />
<em>Above are some Microsoft Word 2010 tips and tricks that make your
working on the editor easy. If you have anything to share, please use
the comments section.</em></div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-15698280622037088922013-01-31T12:28:00.004-08:002013-01-31T12:28:32.859-08:0010 cool Microsoft Word tips and tricks<div dir="ltr" style="text-align: left;" trbidi="on">
<figure class="img" data-url="/images/zoom/905849-a/1"><img alt="10 cool Microsoft Word tips and tricks" itemprop="image" src="http://cdn0.mos.techradar.futurecdn.net///Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.document_comparison-580-75.jpg" /><figcaption>If you are a Word power-user, then these tips may well help you get more done</figcaption></figure><aside class="related-articles"><br /></aside>Despite the many alternatives that are out there, Microsoft Word remains one of the most popular word processors available. <br />
However, most of us barely scratch the surface of its abilities.<br />
With this selection of Microsoft Word tips, you can really step up your
game, no matter which version you use, and you'll be able to work more
efficiently than ever before.<br />
<strong>1. Configure paste options</strong><br />
Word
tries to be helpful when copied text is pasted into a document by
automatically retaining the source formatting, while providing the
option to change the text to match the formatting of the current
document. <br />
<figure><img alt="paste options" src="http://cdn2.mos.techradar.futurecdn.net//Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.paste_options-580-90.jpg" width="580" /></figure>To
avoid having to choose formatting options every time text is pasted,
click the 'Office' button, followed by 'Word Options', then move to the
'Advanced' section. Under the 'Cut, copy and paste' heading, use the
first four dropdown menus to choose a default setting for format
pasting. <br />
While configuring these options, untick the box labelled
'Show Paste Options Buttons' to prevent the formatting options pop-up
from being displayed in the future.<br />
<strong>2. Change full-justification formatting</strong><br />
When
full justification is applied to a paragraph, Word ensures that text is
vertically aligned on the left and right of the page by adjusting the
spacing between words. While this usually isn't a problem, there are
occasions when it can lead to a lot of visible white space.<br />
By
opting to use the justification style that's utilised in WordPerfect,
the spacing between individual letters on each line is adjusted to allow
for better-looking text when it spans from margin to margin. <br />
To
activate this option, click the 'Office' button, followed by 'Word
Options', and then click the 'Advanced' link on the left. Scroll to the
bottom of the advanced options and expand the 'Layout Options' entry.
Now you just need to tick the box labelled 'Do Full Justification The
Way WordPerfect 6.x For Windows Does', then click 'OK'.<br />
<strong>3. Use a hanging indent</strong><br />
One
of the less frequently used means of formatting paragraphs is the
hanging indent. This is where the first line is not indented, but all of
the rest are. <br />
<figure><img alt="hanging indent" src="http://cdn2.mos.techradar.futurecdn.net//Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.hanging_indents-580-90.jpg" width="580" /></figure>Select
the paragraph you'd like to format in this way, move to the Home tab
and double-click the arrow icon in the lower right-hand corner of the
'Paragraph' pane. <br />
On the Indents and Spacing tab, use the
'Special' dropdown menu in the middle of the dialog to select the
'Hanging' option and then indicate the indentation level. To apply the
indent, click 'OK'.<br />
<strong>4. Show and hide the ribbon</strong><br />
For many people, the ribbon interface used in Office 2007 is a great
step forward, while others find it somewhat overwhelming. If you fall
into the latter category, you'll be happy to know that the ribbon can be
temporarily hidden to provide you with a larger working area and clear
away the clutter. <br />
It's also worth noting that the ribbon can
quite easily be hidden by accident, so if this has happened, these tips
can be used to show and hide it as required. <br />
The first option is
to click the down arrow icon at the end of the Quick Access Toolbar and
tick or untick the 'Minimize the Ribbon' option. This menu can also be
accessed by right-clicking anywhere on the ribbon. <br />
The third
option is to double-click one of the tabs at the top of the ribbon to
toggle the ribbon on and off. Finally, you can always use the keyboard
shortcut – simply press [Ctrl]+[F1].<br />
<strong>5. Number pages</strong><br />
It's
easy to configure a header and footer for your Word document so the
page number is displayed on every page. In many instances, though, a
document will have a title page for which a number is not required. <br />
<figure><img alt="page numbering" src="http://cdn1.mos.techradar.futurecdn.net//Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.page_numbering-580-90.jpg" width="580" /></figure>Set
up page numbering as required and then in Word 2007 and 2010, move to
the Page Layout tab before clicking the button in the lower right-hand
corner. Switch to the Layout tab and tick the box labelled 'Different
first page', before clicking OK.<br />
<strong>6. Back up the Quick Access Toolbar</strong><br />
If
you've spent a great deal of time customising the Quick Access Toolbar
(QAT), it's all too easy to forget about it if you ever need to
reinstall Windows. Thankfully, you can create a backup of the toolbar,
which means it can be brought back without any hassle, or copied to
other machines that you work with.<br />
In Windows XP, use Explorer to
navigate to 'C:\Documents and Settings\[username]\Local
Settings\Application Data\ Microsoft\Office', while in Windows Vista or
7, you should head to 'C:\Users\[username]\ AppData\Local\Microsoft\
Office'. <br />
Here you'll find a file called 'Word.qat' – this can be duplicated for backup purposes, or copied to another computer.<br />
<strong>7. Remove formatting</strong><br />
If
text has been formatted and you change your mind about how it should
appear, click the word in question, or select a section of text, and
press [Ctrl]+[Space] simultaneously. If the formatting has been applied
with a style, press [Ctrl]+[Shift]+[N] and it will then revert to the
default style. <br />
<strong>8. Adjust font spacing in headings</strong><br />
Text
space can be adjusted to help ensure that a heading fits on a single
line, rather than wrapping onto a second, or expanded to reduce the
amount of white space in a line.<br />
Select a line of text, right
click and select Font from the context menu. Letter widths can be
adjusted by selecting a new size from the Scale dropdown menu, but it's
also possible to adjust spacing. Use the up and down arrows in the
Spacing section to expand or compress it. <br />
<strong>9. Compare documents</strong><br />
There
are various reasons why you might want to compare two documents and
Word provides the option to open two files side by side for this very
purpose. However, if you're using a monitor in portrait mode,
side-by-side document comparison is less useful than having one document
displayed above the other. <br />
<figure><img alt="compare documents" src="http://cdn2.mos.techradar.futurecdn.net//Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.document_comparison-580-90.jpg" width="580" /></figure>Thankfully,
this arrangement option is available. In Word 2003 and older, open the
two documents you want to compare, click the 'Window' menu and select
'Compare Side by Side'. Now click the 'Window' menu again and select the
'Arrange All' option.<br />
In Word 2007 and 2010, open the documents
that you want to compare and move to the View tab of the ribbon. Click
the 'View Side by Side' button, and then click 'Arrange All'. Press
'Synchronous Scrolling' and you can scroll then through both of your
documents at the same time. <br />
<strong>10. Paste text with the Spike </strong><br />
While
the clipboard provides a useful way to copy and move text around a Word
document, there's a little-known feature called the Spike that provides
an alternative. Text that's added to the Spike is cut from the document
and there's no limit to the number of entries that can be added. <br />
<figure><img alt="the spike" src="http://cdn3.mos.techradar.futurecdn.net//Review%20images/PC%20Plus/PCP%20300/PCP300.helpdesk.the_spike-580-90.jpg" width="580" /></figure>When
the content of the Spike is pasted into a document, it's done so in the
order that it was spiked. This provides a very handy way of
reorganising paragraphs or lists, without the need for endless cutting
and pasting. <br />
To add text to the Spike, select it and press
[Ctrl]+[F3] simultaneously – this can be repeated as many times as
required. To paste the contents of the Spike back into a document, you
just need to press [Ctrl]+[Shift]+[F3]. <br />
This will clear the
Spike, ready to start collecting more data, but it's also possible to
paste the Spike while retaining its contents for future use. Position
the cursor where the pasted text should appear, type the word spike and
then press [F3].</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-30384587358329856662013-01-31T12:21:00.001-08:002013-01-31T12:21:30.486-08:00Mot de passe oublié <div dir="ltr" style="text-align: left;" trbidi="on">
Vous pouvez créer sous Windows XP une disquette de réinitialisation de mot
de passe. Cette disquette a pour but de vous empêcher d'oublier votre mot de
passe. Pour créer cette disquette, rendez-vous dans le panneau de configuration
et cliquez sur <strong>Comptes utilisateurs</strong>. Cliquez sur le compte pour lequel vous souhaitez créer une disquette et cliquez à gauche sur <strong>Empêcher un mot de passe oublié</strong>. L'assistant s'affiche :<br />
<div class="c">
<img alt="Récupération de mot de passe oublié" src="http://www.vulgarisation-informatique.com/images/articles/passe_oublie/etape_1.gif" /></div>
Cliquez sur <strong>suivant</strong> et insérez une disquette vierge et
formatée dans le lecteur A.<br />
<div class="c">
<img alt="Préparation de la disquette" src="http://www.vulgarisation-informatique.com/images/articles/passe_oublie/etape_2.gif" /></div>
Cliquez ensuite sur <strong>suivant</strong>. Indiquez ensuite votre mot de
passe actuel, et cliquez sur <strong>suivant</strong><br />
<div class="c">
<img alt="Demande du mot de passe actuel" src="http://www.vulgarisation-informatique.com/images/articles/passe_oublie/etape_3.gif" /></div>
L'assistant réalise la disquette. Cliquez sur <strong>suivant</strong> une fois la réalisation terminée..<br />
<div class="c">
<img alt="Fin de la réalisation de la disquette" src="http://www.vulgarisation-informatique.com/images/articles/passe_oublie/etape_4.gif" /></div>
Cliquez ensuite sur <strong>suivant</strong> pour terminer la réalisation de la disquette.<br />
<div class="c">
<img alt="Le mot de passe oublié ne sera plus qu'un mauvais souvenir" src="http://www.vulgarisation-informatique.com/images/articles/passe_oublie/etape_5.gif" /></div>
Ensuite si vous oubliez votre mot de passe, voici la méthode pour accéder
à votre ordinateur :<br />
<ul>
<li>Si votre ordinateur ne fait pas partie d'un domaine ou d'un environnement de domaine (c'est généralement le cas) :</li>
</ul>
<blockquote>
Lorsque l'écran d'ouverture de session s'affiche, sélectionnez votre nom
d'utilisateur puis tapez votre mot de passe. Une petite boîte
intitulée <strong>Avez-vous oublié votre mot de passe</strong> ? s'affiche.<br />
Cliquez sur <strong>utiliser votre disque de réinitialisation de mot de passe</strong> pour
lancer l'Assistant. Suivez les instructions de l'Assistant qui créera un
nouveau mot de passe. Vous pourrez ensuite ouvrir une session en utilisant le nouveau mot de
passe. Gardez votre disquette de récupération de mot de passe pour en
recréer autant que vous souhaitez, il n'est pas nécessaire de recréer la
disquette.<br />
</blockquote>
<ul>
<li>Les instructions suivantes s'appliquent uniquement dans le cas d'un
environnement de domaine
ou d'un ordinateur qui a fait partie d'un domaine.</li>
</ul>
<blockquote>
Lorsque l'écran d'ouverture de session s'affiche, appuyez sur <strong>CTRL+ALT+SUPPR</strong> et tapez votre mot de passe dans la zone <strong>Mot de passe</strong>. Une boîte de dialogue <strong>Échec de l'ouverture de session</strong> s'affiche.
Cliquez sur <strong>Réinitialiser</strong> et insérez la disquette de
réinitialisation de mot de passe. Suivez les instructions de
l'Assistant qui créera un nouveau mot de passe. Ouvrez une session en
utilisant le nouveau mot de passe, puis rangez la disquette de
réinitialisation des mots de passe dans un endroit sûr en vue d'une
utilisation ultérieure. Il n'est pas nécessaire de créer une nouvelle
disquette.
<br />
Pour obtenir des informations générales sur l'Assistant Mot de
passe oublié et sur l'Assistant Réinitialisation du mot de passe, et
pour prendre connaissance des instructions permettant de créer une
disquette de réinitialisation des mots de passe, cliquez sur <b>Rubriques
connexes</b>.<br />
</blockquote>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-87955798417777020552013-01-31T12:09:00.003-08:002013-01-31T12:09:41.875-08:00Créer une disquette de démarrage [Windows XP]<div dir="ltr" style="text-align: left;" trbidi="on">
<img alt="" src="http://www.vulgarisation-informatique.com/images/disquette_rotation.jpg" /><br />
Voici l'étape à suivre pour créer une disquette de démarrage qui vous servira à démarrer la console en cas de problème.
<br />
Insérez une disquette (qui sera la future disquette de démarrage)
dans le lecteur. Allez dans le poste de travail et faites une clic droit
sur le lecteur de disquettes. Choisissez "formater". <br />
Vous avez un écran ressemblant à ceci normalement :<br />
<div class="c">
<img alt="" src="http://www.vulgarisation-informatique.com/images/disquette_demarrage_xp.gif" /></div>
Cochez la case "créer une disquette de démarrage MS-DOS" et cliquez sur Ok.<br />
Voilà, votre disquette de démarrage est terminée.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-33657706728273534052013-01-31T12:08:00.003-08:002013-01-31T12:08:30.653-08:00Nettoyer Windows : supprimez tous les programmes et fichiers inutiles<div dir="ltr" style="text-align: left;" trbidi="on">
Windows est très gourmand en espace disque et provoque un désordre dans
tout le PC. Pour bénéficier du maximum d'espace sur votre disque dur et
accélérer votre PC, il n'est pas inutile de le nettoyer en profondeur. <br />
Voici comment procéder :<br />
<div class="rouge">
<b>(le texte noté en gras et en rouge est à répéter
pour tous les lecteurs du poste de travail).</b></div>
Tout d'abord, rendez vous dans le poste de travail. Sélectionnez le lecteur
C: et faites un clic avec le bouton droit de la souris. Cliquez ensuite sur
"propriétés". Vous vous retrouvez face à cet écran :<br />
<div class="c">
<img alt="propriétés du disque" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_2.gif" /></div>
Cliquez sur "nettoyage de disque". Une nouvelle
fenêtre apparaît : vous êtes dans l'utilitaire qui permet de nettoyer le
disque dur. <span class="rouge"><b>Cochez toutes les cases qui se trouvent
dans le cadre "Fichier à supprimer :" puis cliquez sur ok. Répondez
"oui" à la boîte de dialogue qui s'affiche.</b></span><br />
<div class="c">
<img alt="nettoyage de disque" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_3.gif" /></div>
Revenez à la fenêtre du nettoyage de disque et cliquez ensuite
sur l'onglet "autres options". Ces options sont les plus importantes
et permettent de gagner énormément d'espace disque : <br />
<div class="c">
<img alt="Nettoyage de disque - options avancées" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_4.gif" /></div>
Certains composants de Windows sont cachés et ne peuvent être
supprimés sans la modification d'un fichier. Cliquez sur "démarrer",
puis sur "rechercher" et indiquez dans la zone de recherche le fichier
"sysoc.inf". Le fichier se trouve dans le répertoire
"C:\windows\inf". Cochez dans les préférences les cases qui
permettent de rechercher dans les fichiers cachés et les fichiers système. Une
fois ce fichier ouvert (dans le bloc notes), cliquez sur "édition",
puis "remplacer". Une nouvelle fenêtre apparaît. Dans la case
"Rechercher :", indiquez "hide" et dans la case
"Remplacer par :", mettez "*". Cliquez sur remplacer. Les
modifications sont apportées au fichier. Cliquez sur "fichier", puis
sur "enregistrer". Vous pouvez fermer le bloc notes. Revenez à la
fenêtre du nettoyage de disque. Dans la case "Composants Windows",
cliquez sur "Nettoyer". Vous vous retrouvez face à cette fenêtre :<br />
<div class="c">
<img alt="Composants de Windows" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_5.gif" /></div>
Sélectionnez "Accessoires et utilitaires" et cliquez
sur "détails". Décochez les composants dont vous n'avez pas besoin.
Décochez ensuite les autres accessoires tels que : "MSN explorer",
"Service d'indexation", "Windows Messenger".<br />
Cliquez ensuite sur suivant et revenez à la fenêtre du
nettoyage de disque. Dans la case "Programmes installés", cliquez sur
"nettoyer". L'écran que vous voyez devrait être similaire à
celui-ci :<br />
<div class="c">
<img alt="Ajout/suppression de programmes" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_6.gif" /></div>
Pour chaque programme que vous n'avez pas besoin, sélectionnez
le et cliquez sur "supprimer". Répétez l'opération autant de fois
que nécessaire. <b><span class="rouge">Revenez à la fenêtre du nettoyage de
disque et dans la case "Restauration du système", cliquez sur
"Nettoyer". Répondez "oui" à la boîte de dialogue qui
s'affiche. </span></b>Faites ensuite un clic droit sur le bouton démarrer, et
cliquez sur "explorer". Rendez vous tout d'abord dans le dossier
<strong>C:\WINDOWS\Help\Tours</strong>. Supprimez tous les fichiers et dossiers
résiduels. Un seul dossier restera : <strong>mmTour</strong>, qui refuse de se
supprimer. Rendez vous ensuite au dossier parent, celui nommé <strong>Help</strong>.
Ici se trouvent les fichiers d'aide de Windows, au format .hlp et .chm. Vous
pouvez supprimer les fichiers portant cette extension si vous ne vous servez pas
de l'aide de vos logiciels, ni de celle de Windows.<br />
<div class="c">
<img alt="" src="http://www.vulgarisation-informatique.com/images/nettoyage_etape_7.gif" /></div>
Rendez vous ensuite dans le répertoire temporaire en tapant
dans la barre d'adresses <b>%temp%</b>. Appuyez sur la touche
"Entrée". Ce dossier contient les fichiers normalement utilisés par
les applications et supprimés dès qu'il n'y en a plus besoin. En réalité il
reste toujours des fichiers dans ce dossier si l'application a planté ou si
elle est mal conçue. Cliquez ensuite sur entrée et supprimez tous les dossiers
et fichiers. Voilà ! vous devriez avoir normalement gagné plusieurs dizaines
de méga octets sur votre disque.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-53991948909873368002013-01-31T12:07:00.002-08:002013-01-31T12:07:27.572-08:00Créer un point de restauration système<div dir="ltr" style="text-align: left;" trbidi="on">
Créer un point de restauration système permet, le cas échéant, de
revenir à une configuration telle qu'elle se trouve au jour où le point à
été créé. <br />
Nous aurons besoin de l'outil de Windows disponible ici :<br />
<div class="rouge">
<b>Menu démarrer/programmes/accessoires/outils système/restauration système</b></div>
Voici l'écran d'accueil du programme :<br />
<div class="c">
<img alt="Restauration système" src="http://www.vulgarisation-informatique.com/images/restauration_1.JPG" /></div>
Trois
options sont disponibles. Celle qui nous intéresse est 'Créer un point
de restauration'. Sélectionnez cette option et cliquez sur suivant.<br />
Une
autre page apparaît. Vous devez entrer une description de la
restauration. Entrez une description et cliquez sur créer. Un descriptif
s'affiche. Cliquez ensuite sur démarrage, puis annuler. Votre point de
restauration à été créé. Il vous servira par la suite à restaurer
votre système tel qu'il est maintenant.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-42575244777044128232013-01-31T12:03:00.001-08:002013-01-31T12:03:17.891-08:00La mise en forme conditionnelle [Excel]<div dir="ltr" style="text-align: left;" trbidi="on">
La mise en forme conditionnelle va vous permettre de mettre en forme
(couleur de fond, changement de police, etc) une ou plusieurs cellules
en fonction de conditions que vous définirez. Vous pourrez par exemple
colorier en vert toutes les cellules ayant leur valeur supérieure à 10
et en rouge celles ayant une valeur inférieure à 0. Les possibilités
sont infinies.<br />
Pour ce tutorial, nous allons reprendre l'exemple du fichier excel que nous avons pris pour le premier tutorial : <a class="lb" href="http://www.vulgarisation-informatique.com/tutoriel-macro-excel.php">Créer une macro - Excel</a>.<br />
<div class="c">
<img alt="exemple type" src="http://www.vulgarisation-informatique.com/images/articles/excel_premiere_macro/etape_1.png" /></div>
Notre objectif sera de faire une mise en forme selon la valeur des
chiffres de la colonne C. Spécifions des règles (une seule règle peut
suffir, mais ici nous allons en spécifier plusieurs de manière à montrer
un exemple) :<br />
<ul>
<li>Si la valeur de la cellule se trouve comprise entre 1 et 45, la cellule deviendra rouge avec une police d'écriture jaune.</li>
<li>Si la valeur de la cellule se trouve comprise entre 46 et 70, la cellule deviendra bleue avec une police d'écriture jaune.</li>
<li>Si la valeur de la cellule se trouve comprise entre 71 et 100, la cellule deviendra verte avec une police d'écriture noire.</li>
</ul>
Maintenant que les règles sont définies, nous allons les mettre en pratique. Sélectionnez entièrement la colonne <strong>C</strong> en cliquant dans la liste des colonnes sur la lettre <strong>C</strong>. Vous vous retrouvez avec un écran de ce style :<br />
<div class="c">
<img alt="Sélection de toute une colonne" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_1.png" /></div>
Cliquez ensuite sur le menu <strong>Format</strong> => <strong>Mise en forme conditionnelle</strong>. Une nouvelle fenêtre apparaît :<br />
<div class="c">
<img alt="choix des règles de mise en forme" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_2.png" /></div>
Dans le cadre <strong>Condition1</strong>, prenez l'option <strong>La valeur de la cellule est</strong> et à droit de cette option choisissez l'option <strong>comprise entre</strong>.
Ensuite dans l’autre case à droite, vous marquez la valeur 1 et dans la
dernière case, la valeur 45, ce qui aura pour but d'activer une règle
conditionnelle pour les valeurs comprises entre 1 et 45.<br />
Nous allons maintenant spécifier la mise en forme de la cellule. Pour ce faire, cliquez sur le bouton <strong>Format</strong> :<br />
<div class="c">
<img alt="Choix de la mise en forme de la cellule" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_3.png" /></div>
Dans l'onglet police, vous pouvez choisir la couleur du texte (prenez
pour cette règle un jaune assez voyant) ainsi que sa mise en forme
générale. Dans l'onglet motifs, vous allez pouvoir modifier
l'arrière-plan de la cellule :<br />
<div class="c">
<img alt="Arrière plan" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_4.png" /></div>
Choisissez ici le rouge. Cliquez sur <strong>Ok</strong>. Cliquez ensuite sur <strong>Ajouter</strong> pour ajouter une seconde règle conditionnelle :<br />
<div class="c">
<img alt="Ajouter une mise en forme" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_5.png" /></div>
Vous allez pouvoir maintenant rajouter les deux règles
conditionnelles que nous avons établies plus haut (à savoir une cellule
bleue avec du texte jaune pour les valeurs comprises entre 46 et 70,
ainsi que la dernière règle voulant qu'une cellule ayant sa valeur
comprise entre 71 et 100 soit sur fond vert avec du texte noir). Cliquez
sur <strong>Ajouter</strong> une fois que vous aurez complété la deuxième règle, pour pouvoir ajouter la dernière.<br />
Si tout s'est bien passé, vous devriez avoir ce résultat :<br />
<div class="c">
<img alt="Rendu final" src="http://www.vulgarisation-informatique.com/images/articles/mise_en_forme_conditionnelle/etape_6.png" /></div>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-59624671252760371692013-01-31T11:54:00.000-08:002013-01-31T11:54:20.181-08:00Installer apache sous Windows<div dir="ltr" style="text-align: left;" trbidi="on">
Apache est le serveur le plus utilisé au monde. Conçu à l'origine pour les
systèmes UNIX, il existe aussi pour windows. Voyons comment l'installer :<br />
Commencez par télécharger Apache <a href="http://apache.crihan.fr/dist/httpd/binaries/win32/apache_2.0.50-win32-x86-no_ssl.msi"><b>ici</b></a>.
Ouvrez ensuite le fichier. Un écran d'accueil s'ouvre :<br />
<div class="c">
<img alt="Installation d'apache" src="http://www.vulgarisation-informatique.com/images/articles/apache/etape_1.gif" /></div>
Cliquez trois fois sur le bouton <b>Next </b>(pour accepter la license et
passer la lecture du lisez-moi).<br />
Vous arrivez devant cet écran :<br />
<div class="c">
<img alt="Configuration d'apache" src="http://www.vulgarisation-informatique.com/images/articles/apache/etape_4.gif" /></div>
Dans la zone <b>Network Domain</b> indiquez l'adresse IP de votre serveur (en
général la machine locale, donc 127.0.0.1). Dans la zone <b>Server Name</b>,
indiquez "localhost". Ceci vous permettra d'accéder à votre serveur
en tapant ce nom dans votre barre d'adresses d'internet Explorer. Indiquez
ensuite un email de contact (vous pouvez mettre n'importe quoi dans cette case).<br />
Sélectionnez ensuite <b>For All Users, on Port 80, as a service --
Recommended</b>, puis cliquez sur le bouton <b>Next.</b><br />
<div class="c">
<img alt="Configuration d'apache" src="http://www.vulgarisation-informatique.com/images/articles/apache/etape_5.gif" /></div>
Sélectionnez l'option <b>Custom</b>, et cliquez sur le bouton <b>Next.</b> <br />
<div class="c">
<img alt="Configuration d'apache" src="http://www.vulgarisation-informatique.com/images/articles/apache/etape_6.gif" /></div>
Cliquez sur <b>Apache Documentation</b> de manière à ne pas l'installer.
Vous économiserez plus de 30 Mo d'espace disque. Cliquez ensuite sur <b>Apache
HTTP Server 2.0.50 </b>puis sur le bouton <b>Change</b> si vous souhaitez
changer le répertoire d'installation. Cliquez ensuite sur le bouton <b>Next. </b>Cliquez
ensuite sur le bouton <b>Install</b>, puis sur le bouton <b>Finish.</b><br />
L'installation est terminée !<br />
Rendez-vous dans Internet Explorer, et tapez "http://localhost".
Si une page décrivant apache s'affiche, c'est bon ! (vous pouvez alors
placer vos fichiers html, zip, etc... dans le dossier htdocs (du
répertoire apache2, lui-même situé dans le répertoire d'installation
d'apache), sinon recommencez
l'installation.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-43006410579085249412013-01-31T11:51:00.000-08:002013-01-31T11:51:00.708-08:00Partager des fichiers sous Windows<div dir="ltr" style="text-align: left;" trbidi="on">
Partager des fichiers sous Windows XP (avec des PC clients sous
Windows 98/Me/2000 ou XP) peut vite devenir l'enfer et il arrive souvent
de voir des messages "Accès refusé" ou encore "l'utilisateur ne
bénéficie pas du type de session demandé sur cet ordinateur" quand ce
n'est tout simplement pas une fenêtre qui apparaît avec un mot de passe
alors que vous n'en avez jamais défini !<br />
Nous allons donc apprendre ici à paramétrer correctement Windows XP
pour qu'il permette un partage de fichiers dans les meilleures
conditions, sans messages d'erreurs. La première chose à faire lorsque
l'on veut partager des fichiers, est paradoxalement de désactiver le
partage de fichiers simple ! Je sais, ce n'est normalement pas logique,
mais vous verrez au fur et à mesure de l'utilité d'une telle mesure.
Pour désactiver le partage de fichiers simple, allez dans le poste de
travail, puis cliquez sur le menu <strong>outils => options des dossiers</strong>. Cliquez ensuite sur l'onglet <strong>Affichage</strong>, puis décochez <strong>Utiliser le partage de fichiers simple (recommandé)</strong>. Cliquez ensuite sur Ok. <br />
<div class="c">
<img alt="Désactiver le partage de fichiers simple" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape1.gif" /></div>
Une fois ceci fait, il va falloir partager proprement dit les
dossiers ou fichiers de votre choix. Nous allons utiliser par défaut le
répertoire <strong>documents partagés</strong> de Windows qui se situe ici : <strong>C:\Documents and Settings\All Users\Documents</strong>.
Il s'agit d'un choix arbitraire, vous pouvez tout à fait utiliser un
autre dossier de partage situé n'importe où sur votre disque dur, la
procédure sera la même.<br />
<div class="c">
<img alt="Poste de travail" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape2.gif" /></div>
Pour que les autres utilisateurs du réseau voient votre dossier
partagé, il va falloir lui attribuer des autorisations spéciales. Faites
un clic droit sur ce dossier, puis cliquez sur <strong>Propriétés</strong>, puis sur l'onglet <strong>Partage</strong>. Vous arrivez devant une fenêtre de ce style :<br />
<div class="c">
<img alt="Options de partage" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape3.gif" /></div>
Sélectionnez la case Partager ce dossier, et attribuez un nom (de
préférence faisant moins de 12 caractères, mais bon ce n'est pas une
obligation si tous vos postes sont sous XP ou 2000). Il va maintenant
falloir attribuer des autorisations d'accès. Cliquez sur le bouton <strong>Autorisations</strong>. Une fenêtre comme celle-ci s'ouvre alors :<br />
<div class="c">
<img alt="Autorisations" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape4.gif" /></div>
Par défaut les utilisateurs qui accèdent à vos dossiers de partage seront notés comme étant <strong>Invité</strong>.
Il va donc falloir leur permettre d'accéder aux ressources mises à leur
disposition. Pour ce faire, cliquez sur Ajouter, puis dans la zone de
texte, tapez <strong>Invité</strong>. Cliquez ensuite sur Ok.<br />
<div class="c">
<img alt="Ajout des invités dans la liste des autorisations" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape5.gif" />
</div>
Si tout va bien, vous avez maintenant une fenêtre devant vous qui ressemble à ça :<br />
<div class="c">
<img alt="Autorisations" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape6.gif" /></div>
Sélectionnez le compte "Invité" puis dans la liste des autorisations,
vous pouvez maintenant cocher "Lecture" pour que les utilisateurs
distants puissent voir vos fichiers, ainsi que "Modification" si vous
souhaitez qu'ils puissent supprimer ou écraser vos fichiers. Une fois
ceci fait, cliquez sur Ok, puis sur l'onglet "Sécurité". Il va
maintenant falloir réitérer les mêmes opérations (cliquer sur Ajouter,
taper "Invité", cliquer sur ok puis attribuer des droits).<br />
<div class="c">
<img alt="Autorisations NTFS" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape7.gif" /></div>
Une fois tout ceci fait, cliquez sur Ok. Le dossier apparaît
désormais avec une main en dessous, signifiant qu'il est partagé. Dans
le meilleur des mondes, il nous aurait fallu nous arrêter maintenant
pour que tout fonctionne. Oui, mais malheureusement, les messages
d'erreurs d'impossibilité d'accès seront présents si on s'arrête là. Il
va donc falloir aller dans les méandres de Windows pour aller rajouter
des autorisations d'accès via le réseau pour les utilisateurs identifiés
comme "Invité". Pour ce faire, il va falloir aller dans la stratégie de
groupe de Windows. Cliquez sur <strong>démarrer => panneau de configuration => outils d'administration => stratégie de sécurité locale</strong>. Déroulez à gauche <strong>Stratégies locales</strong>, puis cliquez sur <strong>Attribution des droits utilisateur</strong>. Vous arrivez devant une fenêtre de ce style :<br />
<div class="c">
<img alt="Stratégie de sécurité locale" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape8.gif" /></div>
L'option qui nous intéresse est la première, intitulée <strong>Accéder à cet ordinateur depuis le réseau</strong>. Double-cliquez dessus. Vous arrivez devant une fenêtre de ce style :<br />
<div class="c">
<img alt="Autorisations d'accès au réseau" src="http://www.vulgarisation-informatique.com/images/articles/partage_fichiers/etape9.gif" /></div>
Si la mention "Invité" n'apparaît pas, cliquez sur Ajouter un utilisateur ou un groupe. Cliquez sur <strong>Avancé</strong> puis sur <strong>Rechercher</strong>. Sélectionnez ensuite <strong>Invité</strong>
puis cliquez deux fois sur Ok. Vérifiez que l'option "Refuser l'accès à
cet ordinateur depuis le réseau" ne comporte pas la mention "Invité"
puis fermez la fenêtre. Maintenant, vos documents sont visibles des
autres ordinateurs du réseau et la procédure est terminée.</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com0tag:blogger.com,1999:blog-9020370651846000084.post-23130549883175598282013-01-31T11:49:00.002-08:002013-01-31T11:49:12.430-08:00Partager sa connexion internet<div dir="ltr" style="text-align: left;" trbidi="on">
Le partage d'une connexion internet sous Windows XP est très simple.
Nous supposerons que votre réseau local est déjà créé. Si votre réseau
n'est pas encore créé, vous pouvez regarder cet article : <a class="lb" href="http://www.vulgarisation-informatique.com/creer-reseau-local.php">Tutorial de création d'un réseau local</a>.<br />
Une fois votre réseau créé, il nous reste à partager la connexion internet proprement dite. Si vous avez appliqué quelques <a class="lb" href="http://www.vulgarisation-informatique.com/astuces.php">astuces</a>
disponibles sur le site pour rendre votre ordinateur plus rapide, le
partage de connexion pourra se faire avec quelques difficultés
supplémentaires. Nous irons donc voir que tout va bien au niveau des
paramètres du système d'exploitation.<br />
<div class="s">
Vérification des paramètres du système d'exploitation :</div>
<div style="margin-left: 30px;">
Il s'agit surtout de vérifier que les <a class="lb" href="http://www.vulgarisation-informatique.com/services.php">services</a>
dont a besoin le partage de connexion peuvent être lancés à tout moment
par le système d'exploitation. Pour ce faire, cliquez sur <strong>démarrer</strong>, <strong>exécuter</strong> puis tapez <strong>services.msc</strong>. Cliquez sur <strong>Ok</strong>, une fenêtre ressemblant à celle-ci devrait apparaître :</div>
<div class="c">
<img alt="services" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_1.gif" /></div>
<div style="margin-left: 30px;">
Cherchez le service nommé <strong>Client DHCP</strong> et double-cliquez dessus. Dans la zone intitulée <strong>Type de démarrage</strong> sélectionnez la valeur <strong>Automatique</strong>. </div>
<div class="c">
<img alt="services - activation d'un service" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_2.gif" /></div>
<div style="margin-left: 30px;">
Si le service n'est pas lancé, cliquez ensuite sur le bouton <strong>Démarrer</strong>. Cliquez sur <strong>Ok</strong> puis procédez de la même façon pour le service intitulé <strong>Pare feu Windows / Partage de connexion internet</strong>.</div>
<div style="margin-left: 30px;">
Les services sont maintenant configurés
correctement pour accepter le partage de connexion internet. Nous allons
maintenant paramétrer votre connexion internet pour la partager.</div>
<div class="s">
Partage de la connexion proprement dit - PC hôte :</div>
<div style="margin-left: 30px;">
Cliquez sur le menu démarrer, puis sur <strong>Connexions réseau</strong>. Vous arrivez devant une fenêtre ressemblant à celle-ci : </div>
<div class="c">
<img alt="Connexions réseau" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_3.gif" /></div>
<div style="margin-left: 30px;">
Faites un clic droit sur votre connexion internet qui sera utilisée pour le partage, cliquez sur <strong>Propriétés</strong>. Dans la fenêtre qui s'ouvre, cliquez sur l'onglet <strong>Avancé</strong>. Vous arrivez devant une fenêtre ressemblant à celle-ci :</div>
<div class="c">
<img alt="Partage de connexion internet" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_4.gif" /></div>
<div style="margin-left: 30px;">
Cochez les deux cases intitulées respectivement <strong>Autoriser d'autres ordinateurs du réseau à se connecter via la connexion internet de cet ordinateur</strong>, et <strong>Etablir une connexion d'accès à distance chaque fois qu'un ordinateur de mon réseau tente de se connecter à internet</strong>.</div>
<div class="s">
Partage de la connexion proprement dit - PC clients :</div>
<div style="margin-left: 30px;">
Une fois le PC qui partagera sa connexion
internet configuré, il faut maintenant paramétrer les PC clients, ceux
qui bénéficieront du partage.</div>
<div class="s" style="margin-left: 30px;">
Pour Windows XP :</div>
<div style="margin-left: 60px;">
Retournez dans la fenêtre des connexions
réseau puis faites un clic droit sur votre connexion au réseau local.
Cliquez ensuite sur propriétés. Vous arrivez devant un écran ressemblant
à celui-ci :</div>
<div class="c">
<img alt="Propriétés d'une connexion réseau" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_5.gif" /></div>
<div style="margin-left: 60px;">
Sélectionnez ensuite <strong>Protocole TCP / IP</strong> puis cliquez sur <strong>Propriétés</strong>. Dans la zone intitulée <strong>Passerelle par défaut</strong>, indiquez l'adresse IP du PC hôte. Sélectionnez ensuite <strong>Utiliser l'adresse de serveur DNS suivante</strong> et indiquez les <a class="lb" href="http://www.vulgarisation-informatique.com/dns-fai.php">DNS de votre fournisseur d'accès</a> (si vous ne les connaissez pas mettez l'adresse IP du PC hôte). La configuration du PC client est terminée.</div>
<div class="c">
<img alt="Paramètre TCP / IP" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_6.gif" /></div>
<div class="s" style="margin-left: 30px;">
Pour Windows 98 / Me :</div>
<div style="margin-left: 60px;">
Rendez-vous dans le panneau de configuration et double-cliquez sur l'icône <strong>Réseau</strong>. Vous arrivez devant une fenêtre ressemblant à celle-ci :</div>
<div class="c">
<img alt="Propriétés du réseau - Windows 98 / Me" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_7.gif" /></div>
<div style="margin-left: 60px;">
Cliquez sur l'onglet <strong>Identification</strong> et notez le nom de votre ordinateur.</div>
<div class="c">
<img alt="Nom de l'ordinateur" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_8.gif" /></div>
<div style="margin-left: 60px;">
Retournez ensuite sur l'onglet Configuration
puis sélectionnez "TCP / IP" et cliquez sur Paramètres. Cliquez ensuite
sur l'onglet passerelle. Vous arrivez devant un écran comme celui-ci :</div>
<div class="c">
<img alt="Paramétrage de la passerelle internet" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_9.gif" /></div>
<div style="margin-left: 60px;">
Indiquez dans la zone intitulée <strong>nouvelle passerelle</strong> l'adresse IP du PC hôte, puis cliquez sur <strong>Ajouter</strong>. Cliquez ensuite sur l'onglet <strong>Configuration DNS</strong>. Un écran de ce style apparaît :</div>
<div class="c">
<img alt="Configuration DNS" src="http://www.vulgarisation-informatique.com/images/articles/partage_connexion_xp/etape_10.gif" /></div>
<div style="margin-left: 60px;">
Sélectionnez Activer DNS. Dans la zone Hôte,
indiquez le nom que vous avez noté tout à l'heure. Dans la zone Ordre
de recherche DNS, indiquez un <a class="lb" href="http://www.vulgarisation-informatique.com/dns-fai.php">DNS de votre fournisseur d'accès</a>
puis cliquez sur Ajouter. Faites de même avec le second DNS fourni par
votre fournisseur d'accès. Cliquez ensuite sur Ok, fermez tout et
redémarrez votre PC.</div>
</div>
abdessamadhttp://www.blogger.com/profile/05406414270854404188noreply@blogger.com1