WordPress

全新的正體中文 WordPress 網誌!

suPHP vs mod_php

Posted on | 十一月 4, 2010 | No Comments

suPHP vs. mod_php. When is suPHP superior.
Wednesday, June 18th, 2008 11:31AM UTC

A long time customer of ours asked about another shared hosting provider’s PHP setup. They need to write files to the

file system using PHP. He was having issues with creating files and folders through PHP. This provider uses mod_php,

instead of our setup on HostASite.com that is suPHP based. To get around the issue their tech support recommend

setting the folder to use permission 777 (writeable by ANYONE).

Using 777 permissions on a folder means ANYONE on that server can write to it. Hackers LOVE this type of setup. In

addition, with mod_php you must have at least 644 perms on PHP files, which ALSO means your files can be read by

anyone. This means your MySQL password, key to your merchant account, etc., can be read by any customer on that shared

server! If you ask me, not a secure solution.

We use suPHP instead of the default apache/mod_php for shared hosting.

SuPHP
Pros:

* PHP runs as your user/group
* PHP files can have perms of 640 (hiding things like passwords from other accounts)
* Files/folders written by PHP are written as user/group (no apache or other global user)
* Custom php.ini file per site (can add/remove security options)
* Can run php4 and php5 at the same time (on even the same site!)

Cons:

* Slower
* many PHP .htaccess options do not work (since you can have your own php.ini file this make this point moot)

apache/mod_php
Pros:

* Faster (about 25-30%)

Cons

* PHP safe mode isn’t safe
* files written by PHP are saved as the apache process (usually apache/apache user/group)

For our Shared hosting servers it’s a no brainer to use suPHP instead of mod_php, even if we take a performance hit.

PHP is the #1 method hackers gain access to customer accounts. So once an account is hacked on a shared server, they

can do much more damage with a mod_php setup. SuPHP accounts are much more sandboxed. We’ve had many hacked accounts

via suPHP, and none of them have affected our other customers. In the future are going to replace suPHP and use

LiteSpeed’s web server instead. It offers the same performance as mod_php and yet the same security as suPHP.

Our VPSes and dedicated servers we give the customer the option to select which PHP setup they want.

Author: Larry
Category: Hosting, Security
RSS 2.0 comment feed
Both comments and pings are currently closed.
Comments

1. On June 18th, 2008 2:52+00:00 UTC Rob M says:

I use suPHP in my dev environment with both php4 and php5 just so I can imitate what is used by

hostasite/10for10. Having a custom php.ini is actually a really nice feature since you can do some things that you can

’t do in .htaccess. But LiteSpeed seems like the best of both worlds.

Under suPHP:

* Any scripts that require 777 should use 755 instead.
* Generally, set folders to 755.
* Generally, set files to 644.

What should my .htaccess file look like if my account is on a suPHP server?
You should remove the lines that begin with "php_value" and "php_flag". You will need to move these files to a file

named php.ini and upload php.ini into your public_html directory. Then, add the following line into the .htaccess file

in your public_html:

suPHP_ConfigPath /home/username/public_html

where "username" is your cPanel username. You will need to remove php_value and php_flag from ALL .htaccess files you

may have. However, you only need to add the suPHP_ConfigPath line in the .htaccess file in your public_html directory

only.

Please note that you will need to change the format of your php_value and php_flag lines into the php.ini format.

(Refer to the FAQ entry on how your php.ini file should be formatted).
Another consideration while everyone is "banging on" about you MUST use suPHP. ( taken from a post by Doug Robbins ).

Without suPHP

Without suPHP, intruders might gain write-access to all files and directories that are owned by "nobody" or are world

-writable — e.g. chmod xx6 for files or xx7 for directories.

With suPHP

Intruders might gain write-access to all files owned by the user.

If an exploit runs with permissions of the account owner, all files in the account are susceptible to being

overwritten.

You might want to consider installing suhosin for added security.

php_flag engine off
<Files ~ "\.(php*|s?p?html|cgi|pl)$">
deny from all
</Files>

.htaccess & php.ini in suPHP

Posted on | 十一月 4, 2010 | No Comments

php.ini EZConfig is a proprietary cPanel feature not found in all cPanels.

It makes life easier for Joomla users as it provides a GUI for editing a global php.ini file.

The global php.ini file is stored in the home directory.

The global php.ini file has a recursive affect meaning that the settings in the file will affect all directories on

the account.

This is an improvement over the traditional method of manually editing php.ini files and placing them in every

directory to be affected.
Overriding php.ini EzConfig:

Create a custom php.ini and add the following to a .htaccess file in the same directory:
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/USERNAME/public_html/PATH/TO/DIRECTORY/php.ini
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

You will have to edit the "suPHP_ConfigPath" line to point to the proper php.ini file.

(Technically it doesn’t need to be in the same directory, but putting it there may be best for the sake of

organization.)

apt-get yum port

Posted on | 十月 26, 2010 | No Comments

APT 常用指令如下:

apt-get update
更新套件列表

apt-get dist-upgrade
升級 rpm

apt-cache search
搜尋套件,ex: apt-cache search httpd

apt-get install
安裝套件,這裡的套件安裝,會考慮到相依性的問題。 ex: apt-get install httpd

apt-get remove
移除套件,這裡的套件移除,也會考慮到相依性的問題。 ex: apt-get remove httpd

apt-get clean
清除安裝時下載的暫存套件原始檔案,位於 /var/cache/apt/archives

YUM 常用指令如下:

yum update
更新套件, ex: yum update httpd,如果只有 yum update ,會更新所有已經安裝的套件。

yum search
搜尋套件,ex: yum search httpd*,會搜尋所有跟 httpd 有關的套件。

yum install
安裝套件,這裡的套件安裝,會考慮到相依性的問題。 ex: yum install httpd

yum remove
移除套件,這裡的套件移除,也會考慮到相依性的問題。 ex: yum remove httpd

yum clean
清除安裝時下載的暫存套件原始檔案,位於 /var/cache/yum,因為這裡可以清除的項目很多,我最常用的是 yum clean all ,一

次給他清掉 :p

yum list
列出套件名稱,用法常用有分以下幾種:

yum list updates
列出所有可以更新的套件

yum list installed
列出所有已安裝的套件

20.1. 如何只抓取 tarball?

如果只希望抓取 tarball 下來的話,僅需打下面指令即可:

# make fetch

如果是要抓取單一的 port,以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make fetch

那麼,預設會將 editors/joe 的 tarball 下載至 /usr/ports/distfiles 目錄下。

如果是希望抓取安裝此 ports 所有相關相依 ports 的 tarball,以 systuils/portupgrade 為例的話,則:

# cd /usr/ports/systuils/portupgrade
# make fetch-recursive

預設會將此 port 與所有需要的其他 port 的 tarball,都下載至 /usr/ports/distfiles 目錄下。

如果是希望抓取 ftp 分類下所有 ports 的 tarball ,則:

# cd /usr/ports/ftp
# make fetch-recursive

則會所將 ftp 分類下所有 ports 的 tarball 都下載至 /usr/ports/distfiles 目錄下。

20.2. 如何僅做到解開 tarball的步驟?

有時候習慣自己 patch 原始碼的時候,會很常用到這個功能。以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make extract

那麼就會將 tarball解開至 /usr/ports/editors/joe/work 目錄下。

20.3. 如何僅做到解開 tarball 並補上官方提供的 patch ?

此法與上面方式有一些類似,不同於是先補上官方提供的 patch ,再行 patch 自己的修正。有時候習慣自己 patch 原始碼的時候,會很常用到這個功能。 以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make patch

那麼就會將 tarball解開至 /usr/ports/editors/joe/work 目錄下 ,並補上官方提供的 patch。

20.4. 如何安裝一個新的 port?

如果系統上未安裝此軟體,則可以選擇安裝一個新的 port。 以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make install

如此會在系統上安裝一個新的 joe 軟體。 如果需要在安裝完成後,也一併清除編輯時期所留下來的暫存目錄,則可配合 make clean 方法一起使用,如:

# cd /usr/ports/editors/joe
# make clean

20.5. 如何安裝一個新的 port,並打包(package)起來?

將安裝完成的軟體打包起來,有許多便利性:包括在叢集系統中,可供其它機器使用, 或將未來此軟體出問題可重新利用此 package 重新快速安裝。 以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make package

如此會在系統上安裝一個新的 joe 軟體,並將此軟體打包(package)起來。 package 預設會在 /usr/ports/editors/joe 目錄下,如果希望集中管理的話,建議做如下的步驟:

# mkdir -p /usr/ports/packages/All

以後打包的 packages 都會存放在此目錄下,並且系統會自動做分類,以方便管理。 如果需要在安裝完成後,一併清除編輯時期所留下來的暫存目錄,則可加上 make clean 一起使用,比如:

# cd /usr/ports/editors/joe
# make package clean

20.6. 如何打包一個 port,並將其所有相依的 ports 也打包起來?

因為上面剛說的 make package 方式只有打包單一套件, 中間依賴的 ports 並沒有一起打包,這會出現一個常遇到的問題: 就是如果一個 port 需要依賴其它的 ports,那麼必須將其它 ports 也一起打包,否則安裝 packages 會有相依的問題。 以 sysutils/portupgrade 為例:

# cd /usr/ports/sysutils/portupgrade
# make DEPENDS_TARGET=package package

如此一來,就會對所有 portupgrade 所相依賴的 ports 都一併打包,也包括自己本身。

20.7. 如何對一個已經安裝的 port 打包?

如果安裝好一個套軟,事前並未打包,事後想打包的話, 以 editors/joe 為例:

# cd /var/db/pkg
# pkg_create -b joe-{版本號}

如此一來,就會將已安裝的 port 打包起來,放在 /var/db/pkg 目錄下。

20.8. 如何清理 ports 編輯期間所產生的暫存資料?

在安裝 port 的時候,通常會有編譯期間所需要的工作目錄(work),因此通常安裝好一個套件後,會清除此暫存目錄,以節省硬碟空間。 以 editors/joe 為例:

# cd /usr/ports/editors/joe
# make clean

而如果是希望清除所有 ports 的暫存目錄,則:

# cd /usr/ports
# make clean

而如果是希望清除所有 ftp 分類的暫存目錄,則:

# cd /usr/ports/ftp
# make clean

20.9. 如何清理 ports 編輯期間所產生的暫存資料,以及 tarball 檔?

上面所講的 make clean 僅只是清除編輯期間所需要的工作目錄(work),並沒有將編譯 ports 時一併下載的 tarball 刪除(相對應之 tarball 預設會存放在 /usr/ports/distfiles) 如果打算把 tarball 也一併清除的話,以 editors/joe 為例:

# cd /usr/ports/editors/joe
# make distclean

make distclean 的步驟包含了 make clean 的功能,也就是說除了會刪除 tarball 外,還會一併清除編譯時的暫存 work 目錄。

如果是希望清除所有 ports 的暫存 work 目錄及 tarball,則:

# cd /usr/ports
# make distclean

而如果是希望清除所有 ftp 分類的暫存目錄以及 tarball,則:

# cd /usr/ports/ftp
# make distclean

20.10. 如何在安裝 ports 前查詢所依賴的相關套件?

在安裝 ports 前,可以查詢所需依賴/相關的套件。 以 mail/p5-Mail-SpamAssassin 為例:

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make all-depends-list

make all-depends-list 顯示此套件所有相依的套件。

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make pretty-print-build-depends-list

make all-depends-list 顯示此套件在編譯期間所需要的套件。

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make pretty-print-run-depends-list

make all-depends-list 顯示此套件要執行時所需要的套件。

20.11. 如何移除已安裝的 ports?

editors/joe 為例:

# cd /usr/ports/editors/joe
# make deinstall

或是使用 pkg_delete

# pkg_delete joe-{version}

有時候套件之間的相依性會導致無法直接移除,如果要強制移除的話,則:

# pkg_delete -f joe-{version}

但請注意:很有可能會導致其它相依到這軟體的套件執行起來出現問題。

20.12. 如何一併移除所相依的 ports?

sysutils/portupgrade 為例:

# cd /usr/ports/sysutils/portupgrade
# make deinstall-depends

執行此步驟前,請注意是否會移除其他套件也有共同相依的部分。建議先參考 上面所講的 make-depends-list 的方法來檢查。

# pkg_delete joe-{version}

或者建議用:pkg_delete,這樣若仍有相依該套件的話,會先警告而不會移除。 除非有另外加了 -f 參數來強制移除…。

# pkg_delete -r joe-{version}

20.13. 如何重新安裝已安裝過的 ports?

重新安裝的前提是:之前有安裝過或目前已安裝。以 editors/joe 為例:

# cd /usr/ports/editors/joe
# make deinstall clean install

或是

# cd /usr/ports/editors/joe
# make reinstall

或是

# portupgrade -f joe

20.14. 如何以關鍵字搜尋所要找的 ports?

如果要從全部的 ports collection 中找尋與關鍵字 "ldap" 有關的 ports,則:

# cd /usr/ports
# make search key=ldap

如果只要從與 ftp 相關的 ports 下找尋與關鍵字 "ldap" 有關的 ports,則:

# cd /usr/ports/ftp
# make search key=ldap

另外,還有另一個用法,方法只是將 key 換成 name。如果已經知道要搜尋 ports 的名稱,或只想找名稱相關的關鍵字 "ldap", 則:

# cd /usr/ports
# make search name=ldap

20.15. 如何升級已安裝的 ports?

如果已經安裝套件,事後欲升級的話,必須先移除舊版的 port。以 editors/joe 為例:

# portupgrade joe

或是

# cd /usr/ports/editors/joe
# make clean reinstall

或是

# portupgrade -f joe

20.16. 如何查詢目前系統安裝了哪些套件?

查詢目前系統已安裝的全部套件:

# pkg_info

20.17. 如何查詢目前系統有沒有安裝這個關鍵字的套件?

假設要找的關鍵字是 joe 的話:

# pkg_info | grep joe

20.18. 如何查詢某個檔案是屬於哪些套件?

如果想查詢 /usr/local/bin/joe 是屬於哪個套件的話,則:

# pkg_info -W /usr/local/bin/joe

如果沒有回傳任何資訊的話,代表著這個檔案是由 FreeBSD 內建的。

20.19. 如何查詢某個套件安裝了哪些檔案?

如果想查詢目前系統所安裝的 joe 包含了哪些檔案,則:

# pkg_info -L /var/db/pkg/joe-{version}

20.20. 如何安裝舊版的 ports?

有時候會因為相依性,或是新版有問題,而會想裝舊版本的套件。 這裡介紹的方法是利用 CVS 的好處,回歸到以前舊版本存在的日子,以安裝舊版本的套件。

首先,若我們要回復到某一個套件的版本時,需要去查詢 FreeBSD ports CVS repository。 最常見的就是 Freshports 網站、 FreeBSD 的 Mailing FreeBSD cvs 或是 FreeBSD ports cvsweb

查到該套件版本所依存的日子後,就修改 CVS tag。一般預設 ports 的 CVS tag 會寫在 /usr/share/examples/cvsup/ports-supfile ,如要回溯到 2002/10/05 號的話,則:

# vi /usr/share/examples/cvsup/ports-supfile
default date=2002.10.05.00.00.00  #將 date 改成當日

然後按照一般 CVSup 或 csup 的時候一樣,執行 CVSup 或 csup (make update),此時的 ports collections 就會回到當時的情形,那麼該套件的舊版也會出現在 ports collections 中,只要安裝即可。

如果僅是想回溯某部份的 ports,則必須加上額外的資訊,如僅希望把 lang/perl5.8 回溯, 而我們得知此屬於 lang 中的一支,則:

# vi /usr/share/examples/cvsup/ports-supfile
#ports-all #將 ports-all 標示起來
ports-lang #加入這行

最後,執行 CVSup 或 csup ,並安裝即可。目前若希望單獨回溯單一的 port,則比較麻煩。

php zip and unzip

Posted on | 十月 8, 2010 | No Comments

source code:

zip

<?php
include ("Archive_Zip-0.1.1/Archive/Zip.php");
$zipfile = New Archive_Zip("tempzip/zipfile.zip");
$file_list = array("test.php");
$zipfile->create($file_list);
?>

unzip

<?php
include ("Archive_Zip-0.1.1/Archive/Zip.php");

if (file_exists(‘tempzip/zipfile.zip’))
{
$obj = new Archive_zip(‘tempzip/zipfile.zip’); // name of zip file
}
else
{
die(‘File does not exist’);
}

if ($obj->extract(array(‘by_preg’ => ‘/.*/’, ‘add_path’ => ‘tempzip/’)))
{
echo ‘Extracted successfully!’;
}
else
{
echo ‘Error in file extraction’;
}
?>

php validation form

Posted on | 十月 4, 2010 | No Comments

<?
session_start();
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(44,18);
$back = ImageColorAllocate($im, 245,245,245);
imagefill($im,0,0,$back); //背景srand((double)microtime()*1000000);
//生成4位数字
for($i=0;$i<4;$i++){
$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));
$authnum=rand(1,9);
$vcodes.=$authnum;
imagestring($im, 5, 2+$i*10, 1, $authnum, $font);
}for($i=0;$i<100;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);$_SESSION['VCODE'] = $vcodes;
?>

eshop problem

Posted on | 九月 15, 2010 | No Comments

1054 – Unknown column ‘p.products_id’ in ‘on clause’

select count(p.products_id) as total from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = ’1′ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ’1′ and p2c.categories_id = ’528′

In Catalog/index.php file..

Find this…

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['manufacturers_id'] . "‘ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$HTTP_GET_VARS['filter_id'] . "‘";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and pd.products_id = p.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['manufacturers_id'] . "‘";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['filter_id'] . "‘ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$current_category_id . "‘";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$current_category_id . "‘";
}
}
————————————-

and replace with this

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['manufacturers_id'] . "‘ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$HTTP_GET_VARS['filter_id'] . "‘";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and pd.products_id = p.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['manufacturers_id'] . "‘";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = ‘" . (int)$HTTP_GET_VARS['filter_id'] . "‘ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$current_category_id . "‘";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = ’1′ and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = ‘" . (int)$languages_id . "‘ and p2c.categories_id = ‘" . (int)$current_category_id . "‘";
}
}

554 Message not allowed – [320]

Posted on | 九月 15, 2010 | No Comments

Within a few minutes he had solved the problem and it was so simple. The date on my computer had been changed at some point and was showing a month ahead. This would have meant that any emails that I sent out would have been date stamped a month in the future. Obviously the Yahoo mail system doesn’t like this and so it bounced back my emails.

客戶端電腦時間問題.

install PDO for cPanel

Posted on | 九月 14, 2010 | No Comments

Log in to WHM, go to "Software >> EasyApache". Select PHP 5 and go to exhaustive options list and there you will find PDO. Select and follow the options. This will recompile php/apache with PDO.

Java tutorial

Posted on | 九月 13, 2010 | No Comments

http://caterpillar.onlyfun.net/Gossip/JavaGossip-V2/ConnectDB.htm

How to check if an email address exists without sending an email?

Posted on | 九月 13, 2010 | No Comments

We have all been doing email address validation for a very long time to make sure that the email is correctly formatted. This is to avoid users entering wrongly formatted email address but still they can accidentally give us a wrong email address.

Example of a correctly formatted email address but still wrong:

mailbox.does.not.exist@reddit.com [VALID email fromat but still not correct]

Above case specifically happens when you take important customer email on phone and you type in the wrong email. So is there a QUICK solution to really check the email without sending a test message to the user? Yes.

The solution

A quick & simple check below can be implemented in most programming language including PHP, Python etc. It relies on using the same SMTP which is used to send emails.

To check if user entered email mailbox.does.not.exist@reddit.com really exists go through the following in command prompt.

First - Find mail exchanger of reddit.com

COMMAND:
nslookup – q=mx reddit.com
RESPONSE:
reddit.com      MX preference = 10, mail exchanger = mail.reddit.com
mail.reddit.com internet address = 208.96.53.70

Second - Connect to mail server mail.reddit.com

COMMAND:
telnet mail.reddit.com 25
RESPONSE:
220 mail.reddit.com ESMTP Postfix NO UCE NO UEMA  C=US L=CA Unsolicated electronic mail advertisements strictly prohibited, subject to fine under CA law CBPC 17538.45.  This electronic mail service provider’s equipment is located in the State of California.  See http://www.reddit.com/static/inbound-email-policy.html for more information.

COMMAND:
helo hi
RESPONSE:
250 mail.reddit.com

COMMAND:
mail from: <youremail@gmail.com>
RESPONSE:
250 2.1.0 Ok

COMMAND:
rcpt to: <mailbox.does.not.exist@reddit.com>
RESPONSE:
550 5.1.1 <mailbox.does.not.exist@reddit.com>: Recipient address rejected: User unknown in local recipient table

COMMAND:
quit
RESPONSE:
221 2.0.0 Bye

NOTES:

1) the 550 response indicates that the email address is not valid and you have caught a valid but wrong email address. This code can be on the server and called on AJAX when user tabs out of the email field.  The entire check will take less than 2 seconds to run and you can make sure that the email is correct.
2) If email was present the server will respond with a 250 instead of 550
3) There are certain servers with a CATCH ALL email and this means all email address are accepted as valid on their servers (RARE but some servers do have this setting).
4) Please do not use this method to continuously to check for availability of gmail / yahoo / msn accounts etc as this may cause your IP to be added to a blacklist.
5) This is to supplement the standard email address javascript validation.

« go backkeep looking »

About

This is an area on your website where you can add text. This will serve as an informative location on your website, where you can talk about your site.

Subscribe to our feed

Search

Admin