9/08/2015

Prevent form submit from submiting multiple times by jQuery

If you need to assign a click function dynamically, there is a way to ensure the click function is only assigned once and not duplicated.


Now I show one way based on jquery




       
                        # test
            if ($_POST) {
                print_r($_POST);
                $loop = 100000000;
                for ($i = 0; $i < $loop; $i++) {
                    $b+=1;
                }
                echo 'Completed';
            }
            ?>
        


       

           

           
       



   

       

8/27/2015

How to avoid your div blocked by ad blocker in browser

Please do not use the following names as the class name or id name of css
in your website.

Now ad blocker plugin of many browser will block the following name in your contents, such as
  • AdBlock
  • Adblock Plus
  • AdBlock extension
  • Adblock Plus extension
  • Ad Blockers for Chrome, Firefox, and Safari
The list of rules for ad blocker

#boxes-box-zergnet_module,
 #zergnet,
 #zergnet-widget,
 #zergnet-wrapper,
 .component-zergnet,
 .content-zergnet,
 .module-zerg,
 .widget-ami-zergnet,
 .widget_ok_zergnet_widget,
 .zergnet,
 .zergnet-row,
 .zergnet-widget,
 .zergnet-widget-container,
 .zergnetBLock,
 .zergnetpower,
 div[id^="zergnet-widget-"],
 #AD_banner,
 #AdColumn,
 #AdContainer,
 #AdHeader,
 #AdImage,
 #Adcode,
 #AdvertiseFrame,
 #Advertisements,
 #BottomAdContainer,
 #BottomAds,
 #ContentAd,
 #PreRollAd,
 #RightAdBlock,
 #TopAd,
 #WNAd41,
 #ad-area,
 #ad-background,
 #ad-bg,
 #ad-bottom,
 #ad-container,
 #ad-header,
 #ad-header-728x90,
 #ad-leaderboard,
 #ad-main,
 #ad-right,
 #ad-text,
 #ad-top,
 #ad-top-banner-placeholder,
 #ad-top-wrapper,
 #ad-unit,
 #ad-wrapper,
 #ad468,
 #ad728,
 #ad728x90,
 #adBanner,
 #adBelt,
 #adComponentWrapper,
 #adDiv,
 #adFrame,
 #adGallery,
 #adHeader,
 #adHolder,
 #adLayer,
 #adLeader,
 #adPosition0,
 #adText,
 #ad_1,
 #ad_2,
 #ad_3,
 #ad_4,
 #ad_5,
 #ad_728_90,
 #ad_area,
 #ad_banner,
 #ad_center,
 #ad_content,
 #ad_header,
 #ad_leaderboard,
 #ad_overlay,
 #ad_space,
 #ad_square,
 #ad_table,
 #ad_unit,
 #ad_wrap,
 #ad_wrapper,
 #adaptv_ad_player_div,
 #adbackground,
 #adbanner,
 #adbar,
 #adblock,
 #adboard,
 #adbody,
 #adbox,
 #adcode,
 #adcontainer,
 #adcontainer1,
 #adcontent,
 #adhead,
 #adheader,
 #adimg1,
 #adlayer,
 #adnews,
 #adposition3,
 #adright,
 #ads-col,
 #adsHeader,
 #ads_bottom,
 #ads_right,
 #ads_top,
 #ads_wrapper,
 #adsdiv,
 #adsense,
 #adsense_block,
 #adsense_inline,
 #adsensewide,
 #adspace,
 #adspace_top,
 #adspot-300x250-pos-1,
 #adspot-300x250-pos-2,
 #adtext,
 #adtop,
 #adv-masthead,
 #adv-top,
 #advert1,
 #advert2,
 #advert_box,
 #advertise,
 #advertisement1,
 #advertisetop,
 #advertising_wrapper,
 #adverts,
 #advtop,
 #adwrapper,
 #banner-ad,
 #bannerAd,
 #bannerAdWrapper,
 #banner_topad,
 #bannerad,
 #bigAd,
 #bigad,
 #body_ad,
 #bottomAd,
 #bottomAds,
 #bottom_ad,
 #centerads,
 #cmn_ad_tag_head,
 #companionAd,
 #content-header-ad,
 #contentAd,
 #content_ads,
 #content_adv,
 #contentad,
 #dart-container-728x90,
 #dfp_ad_Entry_728x90,
 #dfp_ad_Home_728x90,
 #divAd,
 #div_prerollAd_1,
 #download_ad,
 #featuread,
 #featured-ads,
 #featuredAds,
 #footer_ad,
 #footer_ads,
 #game-ad,
 #googlead,
 #gridAdSidebar,
 #head-ad,
 #header-ads,
 #headerAd,
 #headerAdContainer,
 #header_ad,
 #homead,
 #ka_adRightSkyscraperWide,
 #leaderAd,
 #leaderBoardAd,
 #leaderboard-ad,
 #leaderboard-advertisement,
 #leaderboardad,
 #left-ad,
 #left_ads,
 #leftad,
 #leftads,
 #logoAd,
 #logo_ad,
 #mainAd,
 #main_ad,
 #mpu2,
 #mpu2_container,
 #mpu_container,
 #msad,
 #myAd,
 #player_ads,
 #pre_advertising_wrapper,
 #prerollAd,
 #promo-ad,
 #publicidad,
 #reklama,
 #rh-ad,
 #right_ads,
 #right_adsense,
 #search-sponsor,
 #searchAd,
 #search_ads,
 #sideAd,
 #side_ads,
 #sidebar-ads,
 #sidebar_ad,
 #sidebar_ads,
 #skybox-ad,
 #sponsorAdDiv,
 #sponsorText,
 #sponsoredlinks,
 #sponsors-home,
 #takeover_ad,
 #top-ad,
 #topAd,
 #topAdSpace,
 #topAdSpace_div,
 #topAdvert,
 #topBannerAd,
 #top_ad,
 #top_ads,
 #topad,
 #topadvert,
 #topbannerad,
 #under_story_ad,
 #videoAd,
 .ADBAR,
 .AdBody:not(body),
 .AdBox,
 .AdInfo,
 .AdTitle,
 .AdvertContainer,
 .HomeAds,
 .IM_ad_unit,
 .RelatedAds,
 .SponsoredContent,
 .ad-300x250,
 .ad-banner,
 .ad-block,
 .ad-body,
 .ad-border,
 .ad-btn,
 .ad-button,
 .ad-cat,
 .ad-cell,
 .ad-display,
 .ad-enabled,
 .ad-header,
 .ad-holder,
 .ad-img,
 .ad-inner,
 .ad-item,
 .ad-leader-top,
 .ad-leaderboard,
 .ad-left,
 .ad-link,
 .ad-links,
 .ad-panel,
 .ad-placement,
 .ad-right,
 .ad-section,
 .ad-served,
 .ad-sidebar,
 .ad-square,
 .ad-stack,
 .ad-text,
 .ad-top,
 .ad-unit,
 .ad-unit-300-wrapper,
 .ad-vertical-container,
 .ad-wide,
 .ad-wrap,
 .ad-wrapper,
 .ad300,
 .ad468,
 .ad728,
 .ad90,
 .adBlock,
 .adBottomBoard,
 .adBox,
 .adContent,
 .adDiv,
 .adElement,
 .adFrame,
 .adFrameCnt,
 .adHead,
 .adHeader,
 .adHeaderblack,
 .adHeadline,
 .adHolder,
 .adHoldert,
 .adImg,
 .adItem,
 .adLink,
 .adMessage,
 .adMiddle,
 .adMod,
 .adModule,
 .adOverlay,
 .adPanel,
 .adPod,
 .adResult,
 .adRight,
 .adRotator,
 .adSpace,
 .adSpot,
 .adText,
 .adTitle,
 .adTopHome,
 .adWidget,
 .adWrap,
 .ad_1,
 .ad_160,
 .ad_160x600,
 .ad_2,
 .ad_3,
 .ad_728x90,
 .ad_960,
 .ad_Right,
 .ad_block,
 .ad_body,
 .ad_container,
 .ad_description,
 .ad_global_header,
 .ad_head_rectangle,
 .ad_header,
 .ad_img,
 .ad_item,
 .ad_leaderboard,
 .ad_line,
 .ad_middle,
 .ad_outer,
 .ad_promo,
 .ad_slug_table,
 .ad_space,
 .ad_spot,
 .ad_text,
 .ad_title,
 .ad_trick_header,
 .ad_trick_left,
 .ad_wrap,
 .ad_wrapper,
 .adarea,
 .adbanner,
 .adbar,
 .adbottom,
 .adbutton,
 .adcolumn,
 .adcont,
 .addiv,
 .adframe,
 .adfree,
 .adheader,
 .adholder,
 .adinfo,
 .adkit,
 .adlink,
 .adlist,
 .admain,
 .admiddle,
 .adright,
 .adrow1,
 .adrow2,
 .ads-1,
 .ads-2,
 .ads-3,
 .ads-area,
 .ads-col,
 .ads-header,
 .ads-holder,
 .ads-inline,
 .ads-item,
 .ads-right,
 .ads-section,
 .ads-title,
 .ads-top,
 .ads1,
 .adsBlock,
 .adsWidget,
 .ads_catDiv,
 .ads_div,
 .ads_top,
 .ads_wrapper,
 .adsbottombox,
 .adsbox,
 .adsbygoogle,
 .adscontainer,
 .adshome,
 .adside,
 .adslot,
 .adslot_blurred,
 .adspace,
 .adtable,
 .adtile,
 .adtop,
 .adv300,
 .adv_300,
 .advert-block,
 .advert-box,
 .advert-container,
 .advert-content,
 .advert-horizontal,
 .advert-wrapper,
 .advert2,
 .advertColumn,
 .advertContainer,
 .advertLink,
 .advertText,
 .advert_area,
 .advert_container,
 .advert_list,
 .advertbox,
 .advertisement-1,
 .advertisement-block,
 .advertisement-swimlane,
 .advertiser,
 .advertising_banner,
 .advertising_block,
 .advertisment,
 .advertorial,
 .adverts,
 .adverttext,
 .adwords,
 .afs_ads,
 .after-post-ad,
 .article_ad,
 .b-advert,
 .banner-ads,
 .banner160x600,
 .banner300,
 .bannerAd,
 .banner_728x90,
 .banner_ad,
 .bannerad,
 .bigads,
 .block-ad,
 .block-simpleads,
 .blog-ads,
 .bottom-ad,
 .bottom-ads,
 .bottom-left-ad,
 .bottomAds,
 .bottom_ad_block,
 .box-ads,
 .box-radvert,
 .boxad,
 .can_ad_slug,
 .category-ad,
 .change_AdContainer,
 .chitikaAdBlock,
 .container_ad,
 .container_row_ad,
 .contentAd,
 .contentAds,
 .content_ads,
 .content_tagsAdTech,
 .cp-adsInited,
 .custom-ad,
 .desktop-ad,
 .displayAd,
 .download_ad,
 .featured-ad,
 .featuredAdBox,
 .flash-advertisement,
 .footer-ad,
 .footer-ads,
 .footerad,
 .forumAd,
 .gallery-ad,
 .google-sponsored,
 .googleAdSense,
 .googleAds,
 .has-ad,
 .header-ad,
 .headerAd,
 .header_ad,
 .header_ad_center,
 .header_advert,
 .headerad,
 .headerads,
 .home-ad,
 .home-ads,
 .homeAd,
 .homead,
 .homepage-ad,
 .homepage_ads,
 .horizontal_ad,
 .img_ad,
 .imgad,
 .inner_ad,
 .innerad,
 .interstitial_ad_wrapper,
 .ipsAd,
 .item-ads,
 .item-container-ad,
 .leaderboard-ad,
 .leaderboard-ads,
 .leftAd,
 .leftad,
 .list-ad,
 .list-ads,
 .listad,
 .logo-ad,
 .marketing-ad,
 .mid_ad,
 .middle_AD,
 .mod-adopenx,
 .module-ad,
 .newsAd,
 .oasad,
 .openx,
 .page-ad,
 .page_ad,
 .pfAd,
 .player_ad,
 .player_hover_ad,
 .pm-ad,
 .post-ad,
 .post-sponsored,
 .post_ad,
 .post_ads,
 .postad,
 .premiumAdOverlay,
 .premiumAdOverlayClose,
 .promoAd,
 .pub_300x250,
 .pub_300x250m,
 .pub_728x90,
 .pushdown-ad,
 .rail-ad,
 .rbRectAd,
 .rectangle_ad,
 .refreshAds,
 .region-top-ad-position,
 .reklam,
 .reklama,
 .reportAdLink,
 .resultad,
 .right-ad,
 .rightAd,
 .right_ad,
 .right_ads_column,
 .rightad,
 .rightadv,
 .searchAds,
 .searchad,
 .searchads,
 .showAd,
 .side-ad,
 .side-bar-ad-position1,
 .single-ad,
 .singleAd,
 .skinAd,
 .sky_ad,
 .skyscraperAd,
 .slide-ad,
 .smallAd,
 .small_ad,
 .smallads,
 .sponsor-box,
 .sponsorBlock,
 .sponsorBottom,
 .sponsoredLinks,
 .sponsorlink,
 .sticky-ad,
 .story-ad,
 .text-ad,
 .text-ad-links,
 .text-ads,
 .textAd,
 .text_ad,
 .text_ads,
 .textad,
 .textads,
 .top-ad,
 .top-ad-wrapper,
 .topAds,
 .top_ad,
 .top_ad_div,
 .top_ad_wrap,
 .top_ads,
 .topads,
 .tower-ad,
 .type_ads_default,
 .view_ad,
 .wideAd,
 .withAds,
 .wnad,
 .wpInsertInPostAd,
 .yom-ad,
 div[id^="MarketGid"],
 div[id^="div-gpt-ad-"],

7/02/2015

Auto start the network for Centos 7 after rebooting

Open /etc/sysconfig/network-scripts/ifcfg-xxxx file and replace line

ONBOOT=no

with

ONBOOT=yes

save and exit the file, and restart the Centos 7.

Configure PHP-5.5+MySQL-5.6+apache-2.4+CentOS-7 on VirtualBox-4.3

0. Download and install VirtualBox 4.3
   https://www.virtualbox.org/wiki/Downloads

1. Download CentOS 7
   http://www.centos.org/download/

2. Install + configure Network

3.  Update yum
  $sudo yum update
  $sudo yum install gcc kernel-devel kernel-headers
  $sudo reboot

4. Install Virtual LinuxAddtions
    If you meet error with[Building the OpenGL support module  [FAILED]] ,      please use the following command

$sudo export MAKE='/usr/bin/gmake -i'
$sudo ./VBoxLinuxAdditions.run

if you still have errors, please try
$sudo /etc/init.d/vboxadd setup

5. Install apache 2.4
$sudo yum install httpd
$sudo systemctl start  httpd.service
$sudo systemctl enable httpd
$sudo  systemctl list-unit-files|grep httpd
         httpd.service                               enabled

6. Install Remi Repo
$sudo yum install http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
$sudo yum install http://rpms.famillecollet.com/enterprise/7/remi/x86_64/php55-2.0-2.el7.remi.x86_64.rpm

7. Open 80 port
$sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$sudo firewall-cmd --reload


8.  Confirm the httpd from browser
  http://127.0.0.1


9. Install PHP5.5

$sudo yum install --enablerepo=remi-php55 php php-common php-mbstring php-xml php-mysqlnd php-pdo php-devel php-mcrypt




10. Restart the apache
$sudo systemctl restart  httpd.service


11. Install MySQL 5.6
$sudo yum install http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
$sudo yum install mysql mysql-server
$sudo chkconfig mysqld on
$sudo chkconfig --list mysqld 
    mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off



12.  Restart Apache

$sudo systemctl restart  httpd.service

5/22/2015

Configuring Apache to run Python Scripts and MySQL on Centos

    In order to setup a website based on python, you should install python, apache, and mysql. You may use msyql or mysql-connector to connect mysql.

1. Install Python
     $ yum install python

2. Install Apache
    $ yum install httpd

3. Configure Apache for Python
    $ vi /etc/httpd/conf/httpd.conf

     DirectoryIndex index.py

    
    <Directory /var/www/web/app>
        Options +ExecCGI
        AddHandler cgi-script .py
    </Directory>
   


4. Confirmation

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"


5. Install MYSQL
    $ yum install MySQL-python

6. Test Example

# import mysql
import MySQLdb

db = MySQLdb.connect("localhost","user","password","test" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()

print "Database version : %s " % data

# disconnect from server
db.close()


7. Install MYSQL Connector
    $ yum install mysql-connector-python

8. Test Example

# import mysql connector
from mysql.connector import (connection)

cnx = connection.MySQLConnection(user='user', password='password',
                                 host='localhost',
                                 database='test')
cursor = cnx.cursor()

cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()

print "Database version : %s " % data

cnx.close()

2/18/2015

Download PDF file or View PDF file on browser by PHP

View pdf file on browser by PHP


 $file = '63f78a20ccab015aaa7a76f8161e665d.pdf';
  $filename = 'filename.pdf';
  header('Content-type: application/pdf');
  header('Content-Disposition: inline; filename="' . $filename . '"');
  header('Content-Transfer-Encoding: binary');
  header('Accept-Ranges: bytes');
  @readfile($file);



Download pdf file by PHP


$file = '63f78a20ccab015aaa7a76f8161e665d.pdf';
$filename = 'filename.pdf';
header("Content-Disposition: attachment; filename=" .  $filename);  
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
@readfile($file); 

2/02/2015

update mysql 5.5 to 5.6 by yum on Centos

Now MySQL provides the repos for mysql-server (http://dev.mysql.com/downloads/repo/). So we may use it and install or update mysql.

1. Add repo for msyql
   # rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

2. View Repo of mysql
   #  less  /etc/yum.repos.d/mysql-community.repo


# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0

3. Back your database
  # msyqldump -uroot -p --databases database-name1 database-name2 > /tmp/backup.sql

4. Update your msyql
     # yum [install | update] mysql-server

5. Check the version of your mysql
    # mysql --version