Tuesday, July 31, 2012

Using Google Drive for online file storage




 You can use Google Drive (https://drive.google.com/) for online file storage.  The first 5GB is free.
You can share files with your friends, or share files between different computers.

Video: Go Google: Google Drive 
Introducing the all-new Google Drive. Now access your files, even the big ones, from wherever you are. Share them with whomever you want, and edit them together in real time. Learn more at http://drive.google.com/star

Thursday, July 26, 2012

Prevent your wireless network from being hacked



If you set your wireless in WEP network, your wireless network is very easily hacked by Ubuntu.
Below is the video:
Hacking Wireless with Ubuntu

Using openDNS for your network security



You may want your Internet safe and secure. You may not want your kids playing online game all the time. You can use openDNS for network security.
http://www.opendns.com/
OpenDNS is a free Filtering system on the Internet. It allows you to reroute your Internet content through Open DNS servers. It is ultra-reliable, globally distributed cloud network. It is simple, smart, easy.

You just need to change your DNS setting
from
Obtain DNS server address automatically
to
Use the following DNS server address:
208.67.222.222
208.67.220.220

The detail can be found in this video: 
Setting up your computer with Open DNS

Monday, July 23, 2012

SEO optimization for blogs



Blogs are like magazines. You need to update it often to to help SEO or your effort will be in vain.

 Search engines keep track the content in change. It is better to post every week. Make each post shorter and more frequent. I will post more tips later.

Friday, July 20, 2012

Full screen demo HTML5



fish

Click image or here to see FULL screen;

HTML 5 Full screen API example



Now in HTML5, there is new "Full Screen API".
 Example: http://jiansenlu.blogspot.ca/2012/07/full-screen-demo-html5.html
click the image to see full image mode. Press Esc key to return to normal mode.
Source code:
 <style>
section
{
    display: block;
    float: right;
    width: 40%;
    padding: 10px;
    margin: 0;
    border: 2px solid #ddd;
    cursor: pointer;
}

section img
{
    width: 100%;
}

section p
{
    font-weight: bold;
    text-align: center;
    margin: 0;
}

section:-webkit-full-screen
{
    float: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0 none;
    background-color: #f00;
}

section:-moz-full-screen
{
    float: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0 none;
}

section:-ms-full-screen
{
    float: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0 none;
}

section:-o-full-screen
{
    float: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0 none;
}

section:full-screen
{
    float: none;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0 none;
}
</style>
<section id="fullscreen">
<img src="http://www.orble.com/images/my-fish.jpg" alt="fish" />
<p>Click image or here to see FULL screen;</p>
</section>


<script>
var e = document.getElementById("fullscreen");

e.onclick = function() {

    if (RunPrefixMethod(document, "FullScreen") || RunPrefixMethod(document, "IsFullScreen")) {
        RunPrefixMethod(document, "CancelFullScreen");
    }
    else {
        RunPrefixMethod(e, "RequestFullScreen");
    }

}
var pfx = ["webkit", "moz", "ms", "o", ""];
function RunPrefixMethod(obj, method) {
  
    var p = 0, m, t;
    while (p < pfx.length && !obj[m]) {
        m = method;
        if (pfx[p] == "") {
            m = m.substr(0,1).toLowerCase() + m.substr(1);
        }
        m = pfx[p] + m;
        t = typeof obj[m];
        if (t != "undefined") {
            pfx = [pfx[p]];
            return (t == "function" ? obj[m]() : obj[m]);
        }
        p++;
    }

}

</script>

Reference:
 http://blogs.sitepointstatic.com/examples/tech/full-screen/index.html

Special character display and language encoding in MYSQL



To force display HTML page in utf-8, we can use
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


To set the MySQL encoding default to UTF-8, we need to add the following to my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

[mysqld]
default-character-set = utf8    
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
 
Sometimes we still find that  non-English characters 
are output as question marks... Try to useysql_query("SET NAMES 'utf8'");
Example

<?php

$db = mysql_connect('DB_ADDRESS','DB_USER','DB_PASS') or die("Database error");

mysql_select_db('My_DB', $db);

//SOLUTION::  add this comment before your 1st query -- force multiLanuage support
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");


$query = "select * from DB_TABLE";

$result = mysql_query($query);


?>

Thursday, July 19, 2012

html code in SEO optimization



There are a few tips for HTML code in the Search Engine Optimization (SEO).

1. <h1> </ h1> has a higher weight  in search engines.

2. <a href="" target="_blank" title=""> </ a>The title part of the hyperlink can be a lot of accumulation Keyword ~ ​​~ This place is easy to search crawler to find ~ ~~This accumulation of keywords, link to this


3, <img src="" title=""> title attribute in this tag can also be the accumulation of a large number of keyword search engine can also be found, the search engine can only recognize words


4. Title tag of <caption> this table </ caption> permissions on the search engine is relatively high


5, <iframe> </ iframe> is not very friendly to search engines.
Do not use this label.
 
6 <title> </ title> html document title part of the large accumulation of additional information in the document keywords to search engine optimization, search engine will crawl and careful use


7 <meta> tag<meta name="keywords" content=" a lot of key words here"> absolutely important.The <meta name="Description" cotent=""> description can be the accumulation of 80 charactersGoogle is the accumulation of 79 characters


<meta name="robots" content=>|Here are six options:index can be indexed by search enginesthe noindex may not be indexed by search enginesfollow search engine links on the page to find other pagesnofllow not allowed to search engines can find under the link on the page Other pagesall both can be included and you can find other pagesnone do not can be
About robots.txtThis file must be placed in the root of the site! ! The file name must be all lowercase. \Format: the User-Agent: the robot the following rules applyDisallow: pages blocked/ / This is the robots.txt of Taobao[Pre] such as: User-agent: Baiduspider
                    
Disallow: /
                    
User-agent: baiduspider
                    
Disallow: /
Also: map tag <map> </ map> is not conducive to SEO optimization

The concept and important of HTTP 404 error page








1. What is the  HTTP 4404?

    You may come across  HTTP 404 when you open a page that does not exist or wrongThe HTTP status code 404 means that the server can not find the specified resource, the requested page does not exist, a lot of open source systems provide a 404 page    


2. Why 404 pages?

    When a link fails, it will close the window, if no HTTP 404 page. It will be bad for SEO and  the user experience. It will reduce the search engines to trust this site.

3.    How to add HTTP 404 page in Apache server:

    Add the code in the. htaccess file: ErrorDocument 404 / Error.html
    Create a simple html404 page named Error.html to
    The Error.html placed in the web root

Wednesday, July 18, 2012

Google keyword tool



There are 30 millions of websites. How to let Google search engine go through your website and attract more visitors? One of method is to use google keywords tool. you can be a synonym for the keyword and you can also provide your website URL to generate your keyword list. This will help you better choose keywords and site optimization to provide you with information.

 The Google keyword tool is extremely powerful, and completely free to use the address is: https://adwords.google.com/select/KeywordToolExternal

For example, I input my url  jiansenlu.blogspot.com in website and type  php in Word or phrase, I found low competitive words:
PHP and,
PHP com,
PHP or,
PHP this,
in PHP,
PHP forums,
about PHP,
PHP die,
free PHP scripts,
PHP books

I also found "PHP online training" , "PHP programmer", learn PHP programming" are high competitive words.


 This will give me the key word analysis to bring a lot of useful information, and the actual Google search queries based on specific pages on my site match, but also to my ad share and search share.


error_reporting() function in PHP



The default error report in PHP is off, You can turn on error reporting in php.ini,via chnaging:
display_errors = Off
to
display_errors = On

There are 14 levels of PHP errors, to include all levels of error messages except notice, change
error_reporting = E_ALL 
to
error_reporting = E_ALL & ~E_NOTICE

If we set error reporting off in php.ini, we still can turn it on in PHP code via:
adding the following code at the beginning of your PHP script

ini_set('display_errors', 1);
error_reporting(E_ALL);


The 14 evels of PHP errors are as follows:

1        E_ERROR          fatal, script stop
2        E_WARNING       not fatal. script continues  to be executed
4        E_PARSE         
8        E_NOTICE        
16       E_CORE_ERROR    
32       E_CORE_WARNING  
64       E_COMPILE_ERROR 
128      E_COMPILE_WARNING
256      E_USER_ERROR    
512      E_USER_WARNING 
1024     E_USER_NOTICE   
2048     E_STRICT     
4096     E_RECOVERABLE_ERROR
8191     E_ALL:     all erros and warnings。

Thursday, July 12, 2012

Renew my startssl certificate in 2012



1) I used ssl certificate for  my https web server, I used  free class 1 certificate from startssl  (http://www.startssl.com/). Each year I have to renew my ssl certificate. i.e I nned to replace my old
ssl.key, ssl.crt, ca.pem and sub.class1.server.ca.pem files under my ssl directory to a new one. Click the link in email body and lead ot to express renew lane.  The notice of expiration in two weeks was received  by webmaster. You can not renew before the two weeks expiration.
During renew, you should be able to access your webmaster account in your web server or similar account defined in Startssl, as Startssl will send an email to this account to verify that you are the Web master.
 
This year I have a new computer, when I use authentic in startssl, the webpage redirect to an error page, and I register a new user and the massage said my email address existed.
I have to migrate my certificate from my previous XP computer to new Windows 7. In Firefox:
Select "Tools"->"Options" , then select "Advanced" -> "Encryption" -> "View Certificates", choose the "Your Certificates" tab and locate your client certificate from the list. The certificate will be listed under StartCom. Select the certificate and click on "Backup", choose a name for this backup file, provide a password (68) and save it at a known location. I save the file name as startssl.p12


To restore the certificate in another computer, in FireFox:
Select "Tools"->"Options" , then select "Advanced" -> "Encryption" -> "View Certificates", choose the "Your Certificates" tab and click import with your p12 certificate file location.

Now I start to renew my Startssl:
2) Startssl auto provides express lane

Under message
  • If you created your own private key and certificate request (CSR), please skip this step.
  • Provide a password for your private key. (At least 10 characters, max. 32)
  • Allowed are only letters and numbers, without spaces!
  • Write your password down somewhere securely.
  • Note that SHA2 hash algorithm may be not supported on older systems (Windows XP, Windows 2003).
create your own password.
Save Private Key
  • Copy and paste the content from the textbox below into a file and save it as ssl.key.
  • Make sure, that you do not alter the content and you did not add any spaces! Save it in ASCII format (plain text).
  • Allowed are only letters and numbers, without spaces!
  • Decrypt the private key with the OpenSSL utility: openssl rsa -in ssl.key -out ssl.key or use the utility from the Tool Box.
Ready Processing Certificate
  • We have gathered enough information in order to sign your certificate now.
  • The common name of this certificate will be set to www.cesei.org.
  • The certificate will have the following host names supported:
    1. cesei.org
    2. www.cesei.org
    3. www.cesei.org
  • Please click on Continue in order to process the certificate.
Save Certificate
  • In the textbox below is your PEM encoded certificate.
  • Copy and paste the content into a file and save it as ssl.crt.
  • Make sure, that you do not alter the content and you did not add any spaces! Save it in ASCII format (plain text).
3)run the following command
openssl rsa -in ssl.key -out ssl.key
OR click Decrypt Private Key in Toolbox, which is identical to the above command
copy the ssl.key above and the password in step 2.
generate  RSA private key and copy to a file ssl.key (rename old ssl.key first)

4) Click StartCom Root CA (PEM encoded) in StartCom CA Certificates (left menu) to save as ca.pem;
Click Class 1 Intermediate Server CA in StartCom CA Certificates (left menu) to save as  sub.class1.server.ca.pem.

5) Install your  ssl.key, ssl.crt, ca.pem and sub.class1.server.ca.pem in your web server ssl directory and restart your web server.

6) To check your ssl in your web server, go to SSL checker and input your https website or left click your mouse in your browser with your https website, click more information and view certificate.

Wednesday, July 11, 2012

Free enscript file program: enscript files



In a worst case, someone stole your computer or break in your computer account, how can you protect your your important files, such as files containing your Credit card and password information? You can use Encrypt Files program to encrypt and decrypt your files.

 Encrypt Files program can be downloaded from:
 http://www.encryptfiles.net/ 
 
Encrypt Files is FREE program. With Encrypt Files you can protect your files and folders from unauthorized viewing. Encrypt Files supports 13 encryptions methods.  It is

  • Fast and lightweight
  • 13 advanced encryption algorithms
  • It can encrypt entire folders
  • Shreds original files after encryption
  • Make files hidden after encryption
  • It is free

Monday, July 9, 2012

PHP, validate an email address



To validate the email address in an input form in PHP,  the following regular    expression can be used:
  "/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i"

Example:
<?php
 if(isset($_POST['submit'])){
   /* email check */
   $email = $_POST['email'];
    if ($email == '') {
        $msg->addError('You must enter an email address.');
    } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $email)) {
        $msg->addError('The entered email address was invalid.');
    } 
}
?>

Friday, July 6, 2012

More free recycled electronics in BC, Canada after July 1



I remember I need to pay the electronics shop to recycle my old fashion TV two years ago. Now the Electronics Product Recycling Association's (EPRA) electronic stewardship program includes more electronic items, such as desktop computers, printers and fax machines etc. For a full list acceptable products:
 http://www.return-it.ca/electronics/products/
location
http://www.return-it.ca/electronics/locations/

And more:
 http://www.electrorecycle.ca/

zen-cart, an open source eCommerce software



Zen Cart® truly is the art of e-commerce; free, user-friendly, open source shopping cart software. It is PHP-based, using a MySQL database and HTML components. Support is provided for numerous languages and currencies. Zen-cart can be downloaded from:
http://www.zen-cart.com/

List of free and open source eCommerce software, from http://en.wikipedia.org

This is a list of notable eCommerce software which is free and open source software.
Software Name Written in Database License Current stable version First release date Latest release date
Arcavias PHP serveral, primarily MySQL LGPL 2012-05 2012-04-27 2012-02-29[1]
Batavi PHP MySQL GNU General Public License 1.2.1
2012-01-18[2]
Bigfish Java several Open Software License
2011-08-31 2012-05-07[3]
Broadleaf Commerce Java several Apache License 2.0 1.5.4
2012-02-21
Bots (edi) Python N/A GNU General Public License 2.1.0
2012-01-02
Interchange Perl several GNU General Public License 5.6.3
2010-03-24[4]
Magento PHP MySQL Open Software License 1.7.0.0 2007-08-31 2012-04-24[5]
nopCommerce ASP.NET MVC MS SQL Mozilla Public License 2.30
2011-11-19
OFBiz Java several Apache License 2.0 10.04
2011-01-19
osCommerce PHP MySQL GNU General Public License 3.0.2 2000 2011-08-06[6]
osCMax PHP MySQL GNU General Public License 2.5.0[7]
2012-02-20
PrestaShop PHP MySQL OSL Ver. 3 / AFL Ver. 3 1.4.8.2 2007 2012-05-14[8]
Ubercart PHP MySQL GNU General Public License 3.0
2012-02-01[9]
Zen Cart PHP MySQL GNU General Public License 1.5.0 2003, osCommerce fork 2011-12-31[10

 

Thursday, July 5, 2012

Install Drupal 7.14



Drupal is an open source software package written in PHP,  which allows you to easily organize, manage and publish your content, with an endless variety of customization.
You can download Drupal  from 
http://drupal.org/project/drupal
Setup your webs erver, MySQL database and PHP and run install.php, and follow the instruction step by step.   I successfully set up my drupal 7.14 on:
http://swf.site40.net/

Although the setup is very simple, I do have some struggle in setup. Fireftp did not copy all my files
to the remote server,  and some files were missing. Several errors were produced as below:
1.drupal Fatal error: Call to undefined function cache_get() ,module.inc 
2.  Notice: Undefined property: stdClass::$owner in _drupal_theme_initialize() (line 208 of /home/a7240086/public_html/drupal/includes/theme.inc).
    Warning: include_once(/home/a7240086/public_html/drupal/) [function.include-once]: failed to open stream: No such file or directory in _drupal_theme_initialize() (line 208 of /home/a7240086/public_html/drupal/includes/theme.inc).
    Warning: include_once() [function.include]: Failed opening '/home/a7240086/public_html/drupal/' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in _drupal_theme_initialize() (line 208 of /home/a7240086/public_html/drupal/includes/theme.inc).
3. Access denied
You are not authorized to access this page. 
After I created a new remote  directory  and synchronized all files in  Fireftp and create a new database All these errors disappeared and the installation was done in a few minutes.

Tuesday, July 3, 2012

PHP addslashes to prevent MySQL injection



To prevent MySQL injection, we can use PHP function addslashes.
to add backslashes before characters single quote ('), double quote ("), backslash (\) and NULL
in MySQL database queries. Example:
$_POST['password'] = trim($_POST['password']); 
$_POST['password'] = addslashes($_POST['password']); 
Here we first use  PHP trim function  to strip whitespace from the beginning and end of a string by default. It can also strip other characters by specification at the second variable.

A better function is mysqli_real_escape_string in PHP 5.  In the older version of PHP, mysql_real_escape_string is used.

PHP validiate HTML form



We can use PHP or JavaScript to validate the HTML form.
In PHP, when a form is submitted,   we can check if the $_POST value is empty. If not, the MySQL database will be upadated.
PHP Example to validate HTML form:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="course_form">
<div class="row required">
<label for="uri">Credit card processing location URL </label><br/>
<input type="text" name="uri" value="<?php echo $row['uri'] ?>" id="uri" size="80" />
</div>
<div class="row required">
<label for="vendor_id">Vendor ID assigned by credit card payment service </label><br/>
<input type="text" name="vendor_id" value="<?php echo $row['vendor_id'] ?>" id="vendor_id" size="40"/>
</div>
<input type="hidden" name="course" value="mycouse" />
<input type="submit" class="input-button" name="submit" value="Save" />
</form>
<?php 
//Note here I used hidden variable to check if the form is submitted, the same as 
// if(isset($_POST['submit']))

if (isset($_POST['course'])) {

if((!$_POST['uri'])&&(!$_POST['vendor_id'])){

//update database hereh

}else{
echo "You need to fill all the required field";
}
?>


JavaScript Example to validate HTML form:
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return validateForm()"   name="course_form">

<div class="row required">
<label for="uri">Credit card processing location URL </label><br/>
<input type="text" name="uri" value="<?php echo $row['uri'] ?>" id="uri" size="80" />
</div>
<div class="row required">
<label for="vendor_id">Vendor ID assigned by credit card payment service </label><br/>
<input type="text" name="vendor_id" value="<?php echo $row['vendor_id'] ?>" id="vendor_id" size="40"/>
</div>
<input type="hidden" name="course" value="mycouse" />
<input type="submit" class="input-button" name="submit" value="Save" />
</form>
 <script type="text/javascript">
 function validateForm()
{
var x=document.forms["course_form"]["uri"].value;
var x=document.forms["course_form"]["vendor_id"].value;
if (x==null || x==""||y==null || y=="")
  {
  alert("You need to fill all the required field");
  return false;
  }
}
</script>

HTML checked="checked" and selected="selected"



We use checked="checked" in radio button (circle) or checkbox (square) to indicate an item is checked.
We use selected="selected" in a drop-down menu to indicate an item is selected.
Combination with PHP, we can edit  user file etc using MySQL database:
Example:
<input type="radio" name="email_admin" value="1"  <?php if($row['email_admin'] == 1){ echo('selected="selected"'); } ?>/>Enable

Example of   checked="checked" in radio button:
<form>
<input type="radio" name="car" value="Nissan" checked="checked" /> Nissan<br />
<input type="radio" name="car" value="Toyota" /> Toyota
</form>

 Example of   checked="checked" in checkbox:
<form>
<input type="checkbox" name="car" value="Nissan" checked="checked" /> Nissan<br />
<input type="checkbox" name="car" value="Toyota" /> Toyota
</form>

Example of  selected="selected" in a drop-down list:
<select name="currency">
<option value="CAD" >CAD - Canadian Dollars</option>
<option value="AUD" selected="selected">AUD - Australian Dollars</option>
<option value="BRL">BRL - Brazilian Reais</option>
<option value="GBP">GBP - British Pounds</option>
<option value="CZK">CZK - Czech Koruny</option>
<option value="DKK">DKK - Danish Kroner</option>
</select>

Sunday, July 1, 2012

Design CSS Menu online



You make not want to design CSS menu from scratch. Even experience web designers still take times to write CSS scripts for complicated drop-down menus. You can design your CSS menus online by a few clicks. The web link is:
http://cssmenumaker.com/
1)FIND
Explore the gallery of professionally designed CSS Menus.
2)CUSTOMIZE
Personalize your menu with  easy to use online Menu Maker.
3)DOWNLOAD
Download the HTML, CSS, and Images for your custom menu in a nice neat package.