Zen Cart V1.5.5 Add Extra Text at Category Footer

  1. Modify mysql database, add a field called ‘categories_footer’ at the table of ‘categories_description’, same field names and description of the field called ‘categories_description’.
  2. Add the function at admin panel, to create or modify a category, we need to modify categories.php which is under the admin fold. Within this file we need to add an extra field so that we can fill in the extra text of footer. Take care there are several places need to modify or add.
  3. We need to create a function called “zen_get_category_footer()”, same as  the function of “zen_get_category_description()”, add it within the file called general.php, which is under “admin/includes/functions/”.
  4. We also need to add the new extra block name with categories.php, say “define(‘TEXT_CATEGORIES_FOOTER’, ‘Categories Footer Description:’);”, just let this line under “define(‘TEXT_CATEGORIES_DESCRIPTION’, ‘Categories Description:’);”, which will be added within the file called  categories.php which is under “admin/includes/languages/english/”.
  5.  Now let’s share how to let the  extra text at footer display at front page of a category. We need to modify 2 files. Let modify the first file which is called “tpl_index_product_list.php”, just under “includes/templates/responsive_classic/templates/”. Add the following code just above the last </div> at the end of the file:
    <?php
    // categories_description
    if ($current_categories_footer != ”) {
    ?>
    <div id=”indexProductListCatDescription” class=”content”><?php echo $current_categories_footer;  ?></div>
    <?php } // categories_description ?>
    </div>
  6. Modify the last file called “main_template_vars.php”, which is under “includes/modules/pages/index/”. Modify $sql, and add the new field, so that we can  use “$current_categories_footer” at “tpl_index_product_list.php”.
Posted in MySQL, Php Study, Zen Cart. Comments Off on Zen Cart V1.5.5 Add Extra Text at Category Footer »

Skills on How to Show different Adsense Ads at WordPress

More and more people love to use wordpress to setup blogs and place adsense ads, and many people still love the use the theme of Classic, by Dave Shea. Can we show different adsense code at the same place, but different pages then? For example, we want to show 2 adsense block at the main body of detailed pages, but only show 1 adsense block at other page’s main body.
(more…)

Posted in Php Code, Php Skills, Php Study, WordPress. Comments Off on Skills on How to Show different Adsense Ads at WordPress »

Vbulletin Version 4.1.2 Installation Errors

When I install Version 4.1.2, the following errors come out:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/cpgtxos/public_html/forums.glassesadvisor.com/includes/class_core.php on line 414

Warning: Cannot modify header information – headers already sent by (output started at /home/cpgtxos/public_html/forums.glassesadvisor.com/includes/class_core.php:414) in /home/cpgtxos/public_html/forums.glassesadvisor.com/install/includes/class_upgrade_ajax.php on line 731 (more…)

Posted in Php Study, Vbulletin. Comments Off on Vbulletin Version 4.1.2 Installation Errors »

How to Access MySQL Command Line in XAMPP?

MySQL binaries should be under your XAMPP folder. Look for a /bin folder, and you’ll find the mysql.exe client around. Let’s assume it is in e:\xampp\mysql\bin, then you should fireup a command prompt in this folder.

First, go to e:\xampp, and run xampp_start. If you do not run xampp_start first, the error message “Can’t connect to Mysql server on ‘localhost'” will occur when you go to step 2.

Afer you run the commend prompt of DOS, then enter:

cd d:\xampp\mysql\bin
mysql.exe -u root –password

Enter password:
and enter root password

mysql>

After log into your mysql server, and start typing your commands.
Type “quit”  or “exit” to exit mysql
(more…)

Posted in Php Study. Comments Off on How to Access MySQL Command Line in XAMPP? »

Using PHP to Generate Strong Password

If you want to have very strong password to protect your account, here is the code for :

<code>
<?php
 
function generatePassword($length=9, $strength=0) {
    $vowels = ‘aeuy’;
    $consonants = ‘bdghjmnpqrstvz’;
    if ($strength & 1) {
        $consonants .= ‘BDGHJLMNPQRSTVWXZ’;
    }
    if ($strength & 2) {
        $vowels .= “AEUY”;
    }
    if ($strength & 4) {
        $consonants .= ‘23456789’;
    }
    if ($strength & 8) {
        $consonants .= ‘@#$%’;
    }
 
    $password = ”;
    $alt = time() % 2;
    for ($i = 0; $i < $length; $i++) {
        if ($alt == 1) {
            $password .= $consonants[(rand() % strlen($consonants))];
            $alt = 0;
        } else {
            $password .= $vowels[(rand() % strlen($vowels))];
            $alt = 1;
        }
    }
    return $password;
}
 
?>
</code>

Posted in Php Code, Php Study. Comments Off on Using PHP to Generate Strong Password »

How to chang Vbulleting Domain Name?

Sometimes we want to change vbulleting forum domain name, here are some tips on how to do:

1. Before you change your old domain name to your new domain name, login into you cpanel, go to vBulletin Options, Choose Site Name / URL / Contact Details, and change your Forum URL to your new forum url, that is to say, your new domains.

2. Copy all file under your old web host to your new web host.

 3. Back up your old database and import to your new forum database. (more…)

Posted in Php Study, Vbulletin. Comments Off on How to chang Vbulleting Domain Name? »

How to Get the Current Page URL

Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. Here is how you can do that. (more…)

Posted in Php Code, Php Skills, Php Study. Comments Off on How to Get the Current Page URL »

How to usp php to ban ip

First build a database table:

CREATE TABLE `su_lockip` (
  `id` int(4) NOT NULL auto_increment,
  `lockip` varchar(1024) default NULL,
  PRIMARY KEY  (`id`)
) 

Second, design a page so that you can add the ip you want to ban, every ip is devided by |,  I only write the mail part:
 

$UlockIp=$_POST[‘z’]?$_POST[‘z’]:”;
 if(empty($UlockIp)){
  exit(“<script>alert(‘Sorry, the message your input is wrong!’);history.back();</script>”);
 }
 $sql=”update su_lockip set lockip=’$UlockIp'”;
 if(mysql_query($sql)){
  exit(“<script>alert(‘Locked succesfully!’);history.back();</script>”);
 }else{
  exit(“<script>alert(‘Sorry, the message your input is wrong!’);history.back();</script>”);
 } 

Last, check the ip is in the database or not, if in the database, then show killed.

function lock_user_ip(){
 $Usql =mysql_query(“select * from su_lockip”);
 $Urs =mysql_fetch_array($Usql);
 $UlockIp=$Urs[‘lockip’];
 $ClockIp=$this->get_real_ip();
 $Iplist =explode(‘|’,$UlockIp);
 if(in_array($ClockIp,$Iplist)){
  exit(‘sorry system lock your IP’);
 }
 }
 
 function get_real_ip(){
   $ip=false;
   if(!empty($_SERVER[“HTTP_CLIENT_IP”])){
    $ip = $_SERVER[“HTTP_CLIENT_IP”];
   }
   if (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
    $ips = explode (“, “, $_SERVER[‘HTTP_X_FORWARDED_FOR’]);
    if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
    for ($i = 0; $i < count($ips); $i++) {
     if (!eregi (“^(10|172\.16|192\.168)\.”, $ips[$i])) {
      $ip = $ips[$i];
      break;
     }
    }
   }
   return ($ip ? $ip : $_SERVER[‘REMOTE_ADDR’]);
 } 

Posted in Php Code, Php Study. Comments Off on How to usp php to ban ip »

Finding Items in an Array or not with PHP

The problem: we have an array of items in PHP and we want to find out if a specific item is in the array. In code we can define the array as:
(more…)

Posted in Php Functions, Php Study. Comments Off on Finding Items in an Array or not with PHP »

How to show all files in a document?

$dirname=”E:/zhanzhongjie/chengbiao-com/chengbiao-com”;
$dir_handle=opendir($dirname);
while($file=readdir($dir_handle)) (more…)

Posted in Php Functions, Php Study. Comments Off on How to show all files in a document? »
12
King Php Science Welcome, you are from: 157.55.39.44