Think Your Mind

Linux

Best Encode for PHP5 and support symfony

by kary on May.23, 2010, under Linux, Symfony

In symfony, encoded classes excluded from config_autoload_yml.php. Because when symfony found the classes and read the contents, symfony can not find the words that contain abstract class|interface, final class|interface, class.

Following is the solution to make it work.

1. create config_handlers.yml in sf_root_dir/config folder and add

config/autoload.yml:
  class:    myAutoloadConfigHandler

2. add myAutoloadConfigHandler.class.php to sf_root_dir/config

class myAutoloadConfigHandler extends sfAutoloadConfigHandler
{
static public function parseFile($path, $file, $prefix)
{
$mapping = array();
$content = file_get_contents($file);
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface)\s+(\w+)~mi', $content, $classes);

if (count($classes[1]) == 0)
{
if (stristr($content, 'ioncube_loader') !== FALSE)
{
preg_match_all('~^//\s*(?:abstract\s+|final\s+)?(?:class|interface)\s+(\w+)~mi',
$content, $classes);
}
}

foreach ($classes[1] as $class)
{
$localPrefix = '';
if ($prefix)
{
// FIXME: does not work for plugins installed with a symlink
preg_match('~^'.str_replace('\*', '(.+?)', preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $path), '~')).'~', str_replace('/', DIRECTORY_SEPARATOR, $file), $match);
if (isset($match[$prefix]))
{
$localPrefix = $match[$prefix].'/';
}
}

$mapping[$localPrefix.strtolower($class)] = $file;
}
return $mapping;
}
}

3. change ProjectConfiguration.class.php and add myAutoloadConfigHandler.class.php

public function setup()
{
require_once(sfConfig::get('sf_root_dir').'/config/myAutoloadConfigHandler.class.php');

4. using ionCude Encoder to encode the files and add comment “class sfClassName” to the encode file.
Example: myTools.class.php

// IONCUBE ENCODER 6.5 EVALUATION
// THIS LICENSE MESSAGE IS ONLY ADDED BY THE EVALUATION ENCODER AND
// IS NOT PRESENT IN PRODUCTION ENCODED FILES

// class myTools
if(!extension_loaded(’ionCube Loader’)){$__oc=strtolower(substr(php_uname(),0,3));$__ln=’ioncube_loader_’.$__oc.’_’.substr(phpversion(),0,3).(($__oc==’win’)?’.dll’:’.so’);@dl($__ln);if(function_exists(’_il_exec’)){return _il_exec();}$__ln=’/ioncube/’.$__ln;$__oid=$__id=realpath(ini_get(’extension_dir’));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==’:'){$__id=str_replace(’\\’,'/’,substr($__id,2));$__here=str_replace(’\\’,'/’,substr($__here,2));}$__rd=str_repeat(’/..’,substr_count($__id,’/')).$__here.’/';$__i=strlen($__rd);while($__i–){if($__rd[$__i]==’/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die(’The file ‘.__FILE__.” is corrupted.\n”);}if(function_exists(’_il_exec’)){return _il_exec();}echo(’Site error: the file ‘.__FILE__.’ requires the ionCube PHP Loader ‘.basename($__ln).’ to be installed by the site administrator.’);exit(199);
?>
4+oV5Djj/RjxxiMy5hHec2J9iSWGrP53JymQThUitFyI+rDD9TZc2z8BXRg+rQoi2zlgyd1jv271
LGLiuMCfZM9Wyo97ZTp208rr6ekINq15uTrYKONgK8dPivUR3GzHKXjbKRNv+toLg2bgkSIlKTzC
3KaXVdeReVGarLrmVxaC7L3pJ4Lt1Nex/HVwg3foRqvLGrv0vowUiL1k4uv87wuEJhST20s/KQ6M
8JwWXKksGBPbJ3cDMQuODDnHqNo//6G0VT4kAb4NP/LU9ejObXbOZx25YnWCgS1kyeeANpe++7Tv
rGwE4smPZpXuQawA5zZR2esxUiftfJXP4Pc0QmUUJRwcQhf2brOmWtb9JchulRNIRLgUxzmcYXk3
2z4KuvH3XkH/r2MnNXwiL1T172aBUF65ScDqVF3gZqJX1sOqvDwfqcVOPTA7PV1WUcGFbM58y0Cs

5. Now your files will be able auto load by the symfony.

6. Some link for ionCube
* The ionCube Home page
ioncube.com
* The Standalone Encoder

ionCube Standalone PHP Encoder

* The online Encoder

ionCube Online PHP Encoder

7. Finally, I have write a task to encode the files, if you need the task file, please send a email to me. I will send the file to you.

Share/Save/Bookmark

Leave a Comment :, , more...

Compile apc and ssh2 for PHP 5.2.xx in Linux (ssh2, apc)

by kary on May.14, 2010, under Linux

APC for Php 5.2.xx:

  1. wget http://pecl.php.net/package/apc
  2. unzip the download file
  3. run phpize in the unzip folder
  4. ./configure –enable-apc –with-php-config=/usr/local/bin/php-config
  5. make && make install
  6. enable the apc.so in php.ini

SSH2 for Php 5.2.xx

  1. wget http://www.libssh2.org/download/libssh2-1.2.5.tar.gz
  2. wget http://pecl.php.net/get/ssh2
  3. unzip all downloaded files
  4. in libssh2 folder
  5. ./configure && make && make install
  6. in SSH2 folder
  7. phpize
  8. ./configure && make && make install
  9. enable the ssh2.so in php.ini

Share/Save/Bookmark

Leave a Comment :, , , , more...

Update Boost in CentOS 5 x86_64

by kary on May.10, 2010, under Linux

yum install libicu-devel
yum install libicu
yum install icu

export ICU_PATH=/usr
export ICU_LINK=-L/usr/lib64
export EXPAT_INCLUDE=/usr/include
export EXPAT_LIBPATH=/usr/lib64

yum install openmpi-devel

yum install expat-devel

./bootstrap.sh --prefix=/usr

Edit project-config.jam
add
using mpi;

./bjam install

Share/Save/Bookmark

Leave a Comment :, more...

Load balance in CentOS

by kary on Sep.02, 2009, under Linux

1. Testing your system if the bonding driver is available

modprobe bonding miimon=100
ifconfig bond0 192.168.1.1 netmask 255.255.255.0
ifconfig eth0 down
ifconfig eth1 down
ifenslave bond0 eth0 eth1

2. Create the network configration file for next reboot

create /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
NETWORK=192.168.1.0
NETMASk=255.255.255.0
IPADDR=192.168.1.13
GATEWAY=192.168.1.1
USERCTL=no

edit /etc/sysconfig/network-scripts/ifcfg-eth0 and eth1

**** original config *****
MASTER=bond0
SLAVE=yes

load bonding driver to modprode

edit /etc/modprobe.conf add

****** original config ********
alias bond0 bonding
options bond0 miimon=100 mode=1

reboot system

Share/Save/Bookmark

Leave a Comment :, , , more...

Format USB for Linux (Ext3)

by kary on Sep.02, 2009, under Linux

mkfs.ext3 -v -L usbdisk /dev/sdb1

Share/Save/Bookmark

Leave a Comment :, , , more...

Reverse Proxy Configuration

by kary on May.23, 2009, under Linux

Squid + CentOS 5

Below config will make the proxy server point to one local web server.

#on 80 port load default site content
http_port 80 vhost defaultsite=192.168.10.23

#on 443 SSL port load default site content and using the given cert and key
https_port 443 defaultsite=192.168.10.23 cert=/etc/squid/server.crt key=/etc/squid/server.key

#cache the given IP content on port 80 and pass the HTTP auth info
cache_peer 192.168.10.23 parent 80 0 no-query originserver login=PASS

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
refresh_pattern ^ftp:        1440    20%    10080
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern .        0    20%    4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255

#create the local LAN address for allow access
acl locallan src 192.168.10.0/255.255.255.0

acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70        # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost

#apply local LAN to allow access list
http_access allow locallan

http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all
coredump_dir /var/spool/squid

Share/Save/Bookmark

Leave a Comment more...

Change MySQL default charset

by kary on Apr.24, 2009, under Linux, MySQL

When runing MySQL in Linux, the latin_1 charset will be the default when you create new database. But we always need UTF-8 as the default charset in our database, so that the below configration will help you made the process smooth.

character-set-server=utf8
default-collation=utf8_unicode_ci

Share/Save/Bookmark

Leave a Comment more...

Can’t edit a file in Linux even the root

by kary on Mar.23, 2009, under Linux

In some case, the Linux have some files will not allow user edit directly. It will append immutable permission to the file. The file will not allow every one to edit or delete, unless the attribute has been removed.

lsattr path_to_file

Will show the addition attribute for the file or folder.

chattr -i path_to_file

Will change the file to immutable permission.

Share/Save/Bookmark

Leave a Comment :, more...

Cent OS 5 PPTPD Setup VPN + NAT

by admin on Nov.27, 2008, under Linux

PPTP Server Installation in CentOS 5

This document is shown how to build a Linux Point to Point Tunneling Protocol (PPTP) server using Poptop. This allows roaming users to connect to their corporate network from anywhere on the Internet securely and inexpensively. It supports Windows 95/98/Me/NT/2000/XP PPTP clients and Linux PPTP clients. The requirements are:
  • CentOS 5
  • kernel-2.6.18-8.el5
  • ppp-2.4.4-1.el5

Kernel version 2.6.15 or above has MPPE built-in which is required for MSCHAPv2. CentOS 5 kernel version is 2.6.18 that means you do not need to install the MPPE module. CentOS 5 comes with ppp-2.4.4-1.el5 and it is MPPE support enabled.

1. Run the command below to test if your kernel supports MPPE and you should get a return an “ok”:

modprobe ppp-compress-18 && echo ok

2. Download the RPM file pptpd-1.3.4-1.rhel5.1.i386.rpm from:

http://poptop.sourceforge.net/yum/stable/packages/

3. Install the RPM by running this command:

rpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm

4. Change the following file /etc/ppp/options.pptpd as below:

name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd

5. Change the following file /etc/pptpd.conf as below:

option /etc/ppp/options.pptpd
logwtmp
localip 192.168.2.2
remoteip 192.168.99.11-15

6. Add the following username (johndie) and password (passwrd) in /etc/ppp/chap-secrets as below:

# Secrets for authentication using CHAP
# client server secret IP addresses
johndoe pptpd passwrd *

7. Run the following command to enable the pptpd to start automatically in runlevel 3 and 5 as below:

chkconfig –level 35 pptpd on

8. Now, you can start the pptpd service as below:

service pptpd start

9. For pptpd to work, the packet forwarding must be enabled. Edit /etc/sysctl.conf and change the line to below:

net.ipv4.ip_forward = 1

10. To enable it immediately, run the following command below:

sysctl -p

11. To enable NAT routing, run the following command below:

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

Share/Save/Bookmark

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Recent Comments