Thursday, July 25, 2013

google chrome desktop notification

ref: http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example

 <script>  
 function notify() {  
  var havePermission = window.webkitNotifications.checkPermission();  
  if (havePermission == 0) {  
   // 0 is PERMISSION_ALLOWED  
   var notification = window.webkitNotifications.createNotification(  
    'http://i.stack.imgur.com/dmHl0.png',  
    'Chrome notification!',  
   'Here is the notification text'  
   );  
   notification.onclick = function () {  
    window.open("http://blog.apis17.info");  
    notification.close();  
   }  
   notification.show();  
  } else {  
    window.webkitNotifications.requestPermission();  
  }  
 }   
 </script>  
 <div style="width: 300px; height: 300px; background: yellow" onclick="notify()">  
 Cick here to notify  
 </div>  

view on jsfiddle

slow website respond xampp windows 8 [solved]

http://www.apachefriends.org/f/viewtopic.php?f=16&t=51152

when user click php links that not require database it respond faster. localhost web respond with delay about 300ms if i have database query page. it occur even with simple mysql query. after searching around i found that windows 8 not able to locate localhost correctly (127.0.0.1 or ::0). this is my solution:

1. edit my.cnf located in C:\xampp\mysql\bin directory
2. find bind-address and uncomment 127.0.0.1 or ::1 which your pc use to connect localhost

 # Change here for bind listening  
 # bind-address="127.0.0.1"   
  bind-address = ::1     # for ipv6  

mine using ::1 and i uncomment that line.
3. restart mysql service. use xampp control panel (xampp-control) located at C:\xampp

you will see improvement after restart mysql service.
cheers.

Tuesday, July 23, 2013

homeloader.so problem (cpanel) [solved]

ref: http://stackoverflow.com/questions/9688452/php-module-does-not-compile-does-not-recognize-static-function-entry

i have a problem with homeloader.so after upgrading to php 5.4 using easyapache.

 [23-Jul-2013 12:17:55 Asia/Kuala_Lumpur] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/homeloader.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/homeloader.so: cannot open shared object file: No such file or directory in Unknown on line 0  

 root@cp [~]# locate homeloader  
 /usr/local/cpanel/src/userphp/homeloader.c  
 /usr/local/cpanel/src/userphp/homeloader.loT  
 /usr/local/cpanel/src/userphp/php_homeloader.h  
 /usr/local/lib/php/extensions/no-debug-non-zts-20090626/homeloader.so <-- 20100525="" code="" nbsp="" no="">
current working directory is  
 /usr/local/lib/php/extensions/no-debug-non-zts-20100525/  

 trying to compile homeloader.c manually but have error. 
 
 root@cp [/usr/local/cpanel/src/userphp]# ./install  
 Configuring for:  
 PHP Api Version: 20100412  
 Zend Module Api No: 20100525  
 Zend Extension Api No: 220100525  
 checking for egrep... grep -E  
 checking for a sed that does not truncate output... /bin/sed  
 .....................blablabla  
 and finally  
 cc -I. -I/usr/local/cpanel/src/userphp -DPHP_ATOM_INC -I/usr/local/cpanel/src/userphp/include -I/usr/local/cpanel/src/userphp/main -I/usr/local/cpanel/src/userphp -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/cpanel/src/userphp/homeloader.c -fPIC -DPIC -o .libs/homeloader.o  
 /usr/local/cpanel/src/userphp/homeloader.c:46: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âhomeloader_functionsâ  
 /usr/local/cpanel/src/userphp/homeloader.c:149: error: âhomeloader_functionsâ undeclared here (not in a function)  
 gmake: *** [homeloader.lo] Error 1  

the solution:

 vi /usr/local/cpanel/src/userphp/homeloader.c  

go to line 46
type :46 on vi
replace function_entry with static zend_function_entry

exit vi. type :wq


./install

and success: :)
 Build complete.  
 Don't forget to run 'make test'.  
 Installing shared extensions:   /usr/local/lib/php/extensions/no-debug-non-zts-20100525/  


 root@cp [/usr/local/cpanel/src/userphp]# updatedb  
 root@cp [/usr/local/cpanel/src/userphp]# locate homeloader.so  
 /usr/local/lib/php/extensions/no-debug-non-zts-20090626/homeloader.so  
 /usr/local/lib/php/extensions/no-debug-non-zts-20100525/homeloader.so  <-- code="" success="">

Monday, July 22, 2013

suhosin (cpanel) on PHP5.4

after upgrading to latest php using easyapache, no suhosin.so created.
i'm compile myself and its work:
reference:https://github.com/stefanesser/suhosin/issues/17

cd ~
mkdir suhosin
cd suhosin
wget https://github.com/stefanesser/suhosin/archive/master.zip
unzip master.zip
Start Compiling
phpize
./configure
make
make install

updatedb
locate memcache.so

/usr/local/lib/php/extensions/no-debug-non-zts-20090626/suhosin.so
/usr/local/lib/php/extensions/no-debug-non-zts-20100525/suhosin.so

Done!

Friday, July 12, 2013

unify, vlan tagging, ipv6 connection

store for future reading
http://blog.namran.net/2011/01/30/setting-up-ipv6-network-via-tm-unifi-on-centos-5/

currently not able to connect to vlan pppoe using centos.

i have this but not sure how to use:
http://home.abubakar.net/gitpub/?p=unifi_pppoe;a=commitdiff_plain

this article about creating vlan interface:
http://www.cyberciti.biz/tips/howto-configure-linux-virtual-local-area-network-vlan.html

exploring. pls wait for successfull stories :p

UPDATES (2):
i have a problem with PADO (no receive response from server)
http://wiki.mikrotik.com/wiki/Manual:Interface/PPPoE

further search i think there maybe bugs with my pppd
http://thomashw.github.io/blog/2012/09/06/rp-pppoe-and-pppd-lcp-timeout-sending-config-requests/

UPDATES (1):
http://www.tunnelbroker.net/forums/index.php?topic=951.0;wap2
found unifi dialer:
http://home.abubakar.net/gitpub/?p=unifi_pppoe;a=summary


 #! /bin/sh   
 #  
 # unifi-pppoe          Script to run PPPOE/VLAN for Telekom Malaysia  
 #        UniFi Broadband Internet Service.  
 # chkconfig: 345 10 90  
 # description: UniFi service provides Internet and IPTV service  
 #       over VLANs. This script sets your system to   
 #       connect to the IP Network. It also sets up a   
 #       bridged device to connection to the set top box  
 #       via another NIC.   
 ### BEGIN INIT INFO  
 # Provides:  unifi-pppoe  
 # Required-Start: $local_fs   
 # Required-Stop: $local_fs  
 # Default-Start:  3 4 5  
 # Default-Stop:  0 1 2 6  
 # Short-Description: PPPoE/VLAN for UniFi  
 ### END INIT INFO  
 # Settings:  
 USER=user@unifi  
 PASS=unifipassword  
 WANIFACE=eth1  
 INETVLAN=500  
 IPTVIFACE=eth2  
 IPTVVLAN=600  
 # INSTRUCTIONS:  
 #  
 # (1) Install this script   
 #  
 # Copy it to /etc/init.d/unifi-pppoe. Make sure it is owned by  
 # root and set the permission for it to 700.  
 #  
 # don't forget to install the following packages:  
 #      yum install vconfig rp-pppoe ppp bridge-utils  [CentOS]  
 #      sudo apt-get install vlan pppoe ppp bridge-utils [Ubuntu]  
 #  
 # Set it to run on startup automatically using:  
 #  chkconfig unifi-pppoe on        [CentOS]  
 #  update-rc.d unifi-pppoe defaults    [Ubuntu]  
 #  
 # (2) Edit the settings above  
 # Set USER to your UniFi user-id, PASS to your internet password.  
 # WANIFACE is the interface from which you connect your PC to the  
 # BTU.   
 # If you are using a vlan-tagging switch (e.g. mikrotik RB250GS or  
 # equivalent), set INETVLAN to blank. If your PC is connected   
 # directly to the BTU, set it to 500.  
 # Added a patch from Stanley Seow/rizvanrp for IPTV Vlan. You would   
 # need to set IPTVIFACE to the ethernet that your set top box is   
 # connected to, and IPTVVLAN to 600. If you don't have IPTV (e.g.  
 # UniFi BIZ), leave both settings blank.  
 # Example connection:  
 #  
 # +---------+     +-------------------+  
 # |Fiber BTU|---------|eth0  Linux PC  |  
 # +---------+     |          |  
 #           |  eth1   eth2  |  
 #           +-------------------+  
 #  +------+        |    |  
 #  | IPTV |----------------+    +--------- (LAN PCs)  
 #  +------+  
 #  
 # (3) Test it using:  
 #  /etc/init.d/unifi-pppoe start  [to start]  
 #  /etc/init.d/unifi-pppoe stop   [to stop]  
 # Note: If you're planning to run this for more than a few minutes,   
 #    make sure you setup a firewall on your system. Also, you  
 #    may share the internet connection with other PCs via   
 #    another interface. You can accomplish both of these using  
 #    the excellent arno-iptables-firewall script. Install this  
 #    from the website (for CentOS) or "sudo apt-get install  
 #    arno-uptables-firewall" on ubuntu and follow the instructions.  
 # Written by shahada abubakar <shahada AT abubakar.net>  
 #  
 # Copyright (c) 2011, Shahada Abubakar.  
 #  
 # This program is free software: you can redistribute it and/or modify  
 # it under the terms of the GNU General Public License as published by  
 # the Free Software Foundation, either version 3 of the License, or  
 # (at your option) any later version.  
 #  
 # This program is distributed in the hope that it will be useful,  
 # but WITHOUT ANY WARRANTY; without even the implied warranty of  
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
 # GNU General Public License for more details.  
 #  
 # You should have received a copy of the GNU General Public License  
 # along with this program. If not, see <http://www.gnu.org/licenses/>  
 start_vpn() {  
      if [ -e /var/run/ppp-unifi.pid ]; then  
           PID=`head -1 /var/run/ppp-unifi.pid`  
           GOT=`ps xa | grep "$PID" | grep -v grep | wc -l`  
           if [ "$GOT" -ne 0 ] ; then  
                echo "unifi-pppoe is already running..."  
                return 1  
           fi  
      fi  
      if [ "$INETVLAN" != "" ] ; then  
           ifconfig $WANIFACE up 0.0.0.0  
           modprobe 8021q  
           vconfig set_name_type DEV_PLUS_VID_NO_PAD 2>&1 > /dev/null  
           vconfig add $WANIFACE $INETVLAN 2>&1 > /dev/null  
           # see contents of /proc/net/vlan/config for current status  
           PPPOEDEV=$WANIFACE.$INETVLAN  
      else  
           PPPOEDEV=$WANIFACE  
      fi  
      ifconfig $PPPOEDEV up 0.0.0.0  
      if [ "$INETVLAN" != "" -a "$IPTVVLAN" != "" -a "$IPTVIFACE" != "" ] ; then  
           vconfig add $WANIFACE $IPTVVLAN  
           ifconfig $WANIFACE.$IPTVVLAN up 0.0.0.0  
           ifconfig $IPTVIFACE up 0.0.0.0  
           brctl addbr iptv-bridge  
           brctl addif iptv-bridge $WANIFACE.$IPTVVLAN  
           brctl addif iptv-bridge $IPTVIFACE  
           # from stanleyseow AT gmail.com  
           # Up the bridge interface named iptv-bridge  
           ifconfig iptv-bridge up 0.0.0.0  
      fi  
      logger "Starting UniFi PPPoE session"  
      # note: add UniFi specific routes and post-up commands to   
      #    /etc/ppp/ip-up.local  
      /usr/sbin/pppd pty \  
           "/usr/sbin/pppoe -p /var/run/pppoe-unifi.pid -I $PPPOEDEV -T 80 -U -m 1412" \  
           noipdefault noccp noauth hide-password usepeerdns mtu 1492 \  
           defaultroute mru 1492 noaccomp nodeflate nopcomp novj novjccomp \  
           user $USER lcp-echo-interval 20 lcp-echo-failure 3 \  
           password $PASS debug maxfail 0 persist \  
           linkname unifi ipparam unifi   
 }  
 status_vpn () {  
      if [ -e /var/run/ppp-unifi.pid ]; then  
           PID=`head -1 /var/run/ppp-unifi.pid`  
           GOT=`ps xa | grep "$PID" | grep -v grep | wc -l`  
           if [ "$GOT" -ne 0 ] ; then  
                echo "unifi-pppoe is running..."  
                return 1  
           else  
                echo "unifi-pppoe is dead but pid file exists"  
                return 0  
           fi  
      else  
           echo "unifi-pppoe is not running..."  
           return 0  
      fi  
 }  
 stop_vpn () {  
      if [ -e /var/run/ppp-unifi.pid ] ; then  
           PID=`head -1 /var/run/ppp-unifi.pid`  
           kill $PID  
           ifconfig $WANIFACE up 0.0.0.0  
           if [ "$INETVLAN" != "" ] ; then  
                if [ "$IPTVVLAN" != "" ] ; then  
                     ifconfig iptv-bridge down  
                     brctl delif iptv-bridge eth2   
                     brctl delif iptv-bridge $WANIFACE.$IPTVVLAN  
                     brctl delbr iptv-bridge  
                     vconfig rem $WANIFACE.$IPTVVLAN  
                fi  
                vconfig rem $WANIFACE.$INETVLAN  
           fi  
      else  
           echo "unifi-pppoe is not running..."  
           return 0  
      fi  
 }  
 case "$1" in  
      start)  
           start_vpn;  
           RETVAL=$?  
           ;;  
      stop)  
           stop_vpn;  
           RETVAL=$?  
           ;;  
      restart)  
           stop_vpn;  
           sleep 1;  
           start_vpn  
           RETVAL=$?  
           ;;  
      status)  
           status_vpn;  
           RETVAL=$?  
           ;;  
      *)  
           echo "Usage: unifi-pppoe start|stop|restart|status"  
           exit 1  
 esac  
 exit $RETVAL  
Related Posts Plugin for WordPress, Blogger...