Apr 29

linux — install cent os via url mirros in china

Below list some available mirrors url that can be used to do a network installation of cent os:








Apr 27

linux — CentOS change the name of the network interface

The network didn’t work in my new minimal CentOS install. After some try on changing both “adapter type” and mac addr,i found that with ifconfig command

> ifconfig -a

First,you need to edit the file below,find the line with your mac(the one generated by Virtulbox),change ethx to ech0,remove all other lines.
> vim /etc/udev/rules.d/70-persistent-net.rules

the name of the network become eth3.not eth0 by default.but there is only ifcfg-eth0 in /etc/sysconfig/network-scirpts/. so is it possible for me to revert the name back to eth0?yes!

SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”08:00:27:07:aa:e6″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”03:00:23:24:45:e2″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth1″
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”03:00:37:27:ba:a3″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth2″
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”05:00:37:07:ab:c6″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth3″

Now, reload the udev configuration.
>  start_udev

Third,restart network service
> service network restart



Apr 25

Linux — how to know if php run as cgi or module

For some reason you want to know how is php working with web server like apache. if you are the people who config the server,you got the answer in your head. what if you are not? well,php have a function for this:


Per php manual,call this function will returns the type of interface between web server and PHP

Source code    

The section below is take from the php manual:
Although not exhaustive, the possible return values include aolserver, apache, apache2filter, apache2handler, caudium, cgi (until PHP 5.3), cgi-fcgi, cli, continuity, embed, isapi, litespeed, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, and webjames.

When php run in CGI mode( or any other mode other that module mode), you can not set php config via php_value directive in the .htaccess file.

you can also take a look at the phpinfo page to decide how php is working with your webserver.

Apr 23

zen cart — adapt zen cart to switch template based upon parameter

well,as a zen cart developer,you may have lots of zen cart template. Don’t you bother with  zen cart installation. Though you can make a batch script to generate mass zen cart websites, it will take you a lot of disk space and make you headache while searching for a special zen cart template.

so why not keep all the zen cart template in a single zen cart website.when you need to test some special zen cart template,specify a parameter with the value of template name and zen cart will take the parameter as the current template,no bother to do zen cart admin setting once and once again.

so how? the adoption of the zen cart core code is simple,as below:

Copy includes/init_includes/init_templates.php to includes/init_includes/overrides/init_templates.php,change the code like below:

$sql = “select template_dir
where template_language = ‘” . $_SESSION['languages_id'] . “‘”;
$template_query = $db->Execute($sql);
if ($template_query->RecordCount() > 0) {
$template_dir = $template_query->fields['template_dir'];

// customized by georgezheng
if (isset($_GET['t'])  && $_GET['t'] != ” ) {
$temp = trim($_GET['t']);
$_SESSION['t'] = $temp;
} elseif ( isset($_SESSION['t']) &&  $_SESSION['t'] != ” ) {
$temp = $_SESSION['t'];
} else {
$temp = ”;

if ( $temp != ” && is_dir(DIR_WS_TEMPLATES . $temp) ) {
$template_dir = $temp;

save,then browse your zen cart website with url like this http://www.abcdomain.com/?t=temp1.zen cart will looking for the template temp1,if exists temp1 will be set as current template for this session.

Apr 19

linux — rsync backup withou rsync daemon

i run rsync over ssh to do daily backup with the following command,

rsync -avze ‘ssh -p5000′ [USER@]HOST:SRC… [DEST]

it works ok except that when you remove file/dir from src,it can not be mapped to DESC. To make the deletion affect to the DEST backup,you need to add the –delete option.

rsync -ave ‘ssh -p5000′ –delete user@host:src  desc


Apr 17

Linux – Centos 6 Obtain DHCP IP Address using console

I just install a minimal CentOS 6 in my virtualbox. then i found yum did not work due to the network setting.After google,i got this –

When doing a minimal install on Centos 6, the server is not set to use DHCP by default. Most servers use static IP addresses,

First,  edit /etc/sysconfig/network-script/ifcfg-eth0 and change ONBOOT variable to yes. Then just restart the nework service.

> vi /etc/sysconfig/network-script/ifcfg-eth0

> service network restart  OR
>/etc/init.d/network restart

you can also try to run

> dhcpclient

Mar 27

zen cart — How to determine if current page is HomePage?

sometims,you need to know if the current page is homepage. for example,you don’t want to show some special content in the homepage,then you need to know whether the current page is homepage.

From zen cart source code,i got some idea,see it below


Source code    
$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );

so we can get the result from $this_is_home_page.  this is a global varaible,so you can access it if it’s initiated.


Mar 25

zen cart — How to Add a Sidebox to Zen Cart

One of the best way to customize Zen Cart is to create a new Sidebox.A Zen Cart sidebox is what displays various contents in the left or right columns of your Zen Cart store. By default numerous sideboxes will show in either the left or right column of a Zen Cart online store. The followings are some of the most popular zen cart sidebox — The categories sidebox, the search sidebox, and the information sidebox. Zen cart comes with some builtin sidebox which could be a good tutor to start to learn how to add a new sidebox to Zen Cart.

A sidebox consists of three files which are located in the includes directory:

  1. modules/sideboxes/YOUR_TEMPLATE/new_sidebox.php
  2. languages/english/extra_definitions/YOUR_TEMPLATE/new_sidebox_defines.php
  3. templates/YOUR_TEMPLATE/sideboxes/tpl_new_sidebox.php

The ‘new’ up there should be replaced with your own sidebox name.


Source code    
 $show_new_sidebox = true;
 if ($show_new_sidebox == true){
   $current_page_base,'sideboxes'). '/tpl_new_sidebox.php');
   //do some db query and other processing here
   $left_corner = false;
   $right_corner = false;
   $right_arrow = false;
   require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE,
   $current_page_base,'common') . '/' . $column_box_default);


Source code    
  define('BOX_HEADING_NEW_SIDEBOX', 'Gallery');


Source code    
 $content = <<< End_Of_Quote
  Enter your sidebox content here
Mar 23

zen cart — how to get the url of the current page

i want to set a anchor in all page.so when the user click on the anchor,it will bring user back to the head of the current page.i just don’t want to call too much javascript code.

Source code    
<a href="#backhome">Back to top</a>

The code up there not work.As the browser will fix the anchor url  which cut the current url from last slash.for example

http://www.abcdomain.com/product-one_p_29.html   => http://www.abcdomain.com/#backhome

http://www.abcdomain.com/category1/product-one_p_29.html => http://www.abcdomain.com/category1/#backhome

$_SERVER['REQUEST_URI'] stores the url from the root, see example below

http://www.abcdomain.com/product-one_p_29.html => product-one_p_29.html
http://www.abcdomain.com/category1/product-one_p_29.html  =>

so the anchor snippet code can be adapter to the following code

Source code    
<a href="<?php echo $_SERVER['REQUEST_URI']?>#backhome">Back to top</a>