Pengen Punya WebSite instan kualitas intan ?

Friday, April 30, 2010

install ectoken or tokenizer into PHP(ECToken PHP extension)

The ECToken PHP extension allows you to generate your EdgeCast Token Authentication from a PHP script. When passed a key and a string, the function ectoken_generate will return an encrypted string for a token authentication URL. [you can read more]

login to server as root

create directory ectoken and download php-ectoken.tar.gz & ecencrypt_visualcpp_source.zip
cd /root

mkdir ectoken

cd ectoken

wget http://commands.org.uk/files/ecencrypt_visualcpp_source.zip

wget http://commands.org.uk/files/php-ectoken.tar.gz

extract php-ectoken, move to /usr/local/ then compile it
 tar -zxf  php-ectoken.tar.gz

mv php-ectoken /usr/local

cd  /usr/local/php-ectoken/

run this command :
phpize

./configure  --enable-ectoken

make

copy module ectoken.so to /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
cp  modules/ectoken.so /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

edit php.ini and add this on the last line ( above Zend line ) :
extension=ectoken.so

next step, unzip ecencrypt_visualcpp_source.zip
cd /root/ectoken

unzip  ecencrypt_visualcpp_source.zip

cd ecencrypt

run this command :
g++  ec_encrypt.cpp -o ec_encrypt -lssl

this is will compile and added new file called "ec_encrypt"

move ec_encrypt to home directory on this server and change owner to domains user
cp ec_encrypt  /home/domains/

chown  domains.users ec_encrypt

now, go to /home/domains/yourdomain.com/htdocs and create 2 new file ( ec_token.inc.php & testing.php )

put this line on ec_token.inc.php :
<?php

// Put the path to [ec_encrypt] here.
define(EC_TOKEN_PATH, '/home/domains/ec_encrypt');
function get_ip_token($key, $ip) {
return exec(EC_TOKEN_PATH." $key ec_clientip=$ip");
}
function get_country_allow_token($key, $countries) {
return exec(EC_TOKEN_PATH." $key ec_country_allow=$countries");
}
function get_country_deny_token($key, $ip) {
return exec(EC_TOKEN_PATH." $key ec_country_deny=$countries");
}

?>

put this line on testing.php :
<?php

$key = "12345678";

$params =
"ec_secure=1&ec_expire=1185943200&ec_ip=111.11.111.11&ec_country_allow=US&ec_ref_allow=ec1.com";

$token = ectoken_generate($key, $params);

echo $token;

?>

restart apache and test it. if installed and work properly, you'll
see the result through this URL :
http://216.**.***.***/testing.php


Thanks for sidiq :)

3 comments:

Sander Pick said...

Oh no! Where did the source files go? Was super excited when I saw this. Are you still offering the extensions?

Prayoga said...

oh, sorry Sander, the file accidentally erased

Unknown said...

after make command i got following error.
/bin/sh /usr/local/php-ectoken/libtool --mode=compile cc -I. -I/usr/local/php-ectoken -DPHP_ATOM_INC -I/usr/local/php-ectoken/include -I/usr/local/php-ectoken/main -I/usr/local/php-ectoken -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/php-ectoken/ectoken.c -o ectoken.lo
mkdir .libs
cc -I. -I/usr/local/php-ectoken -DPHP_ATOM_INC -I/usr/local/php-ectoken/include -I/usr/local/php-ectoken/main -I/usr/local/php-ectoken -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/php-ectoken/ectoken.c -fPIC -DPIC -o .libs/ectoken.o
/usr/local/php-ectoken/ectoken.c:5:30: error: openssl/blowfish.h: No such file or directory
/usr/local/php-ectoken/ectoken.c:26: error: expected declaration specifiers or '...' before 'BF_KEY'
/usr/local/php-ectoken/ectoken.c:159: error: expected declaration specifiers or '...' before 'BF_KEY'
/usr/local/php-ectoken/ectoken.c: In function 'cfb64_encrypt':
/usr/local/php-ectoken/ectoken.c:164: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'v0'
/usr/local/php-ectoken/ectoken.c:164: error: 'v0' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:164: error: (Each undeclared identifier is reported only once
/usr/local/php-ectoken/ectoken.c:164: error: for each function it appears in.)
/usr/local/php-ectoken/ectoken.c:164: error: 'v1' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:164: error: 't' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:167: error: 'BF_LONG' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:167: error: expected ';' before 'ti'
/usr/local/php-ectoken/ectoken.c:175: error: 'ti' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:177: error: expected expression before ')' token
/usr/local/php-ectoken/ectoken.c: In function 'bfencrypt':
/usr/local/php-ectoken/ectoken.c:202: error: 'BF_KEY' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:202: error: expected ';' before 'key'
/usr/local/php-ectoken/ectoken.c:206: error: 'key' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:208: error: 'BF_ENCRYPT' undeclared (first use in this function)
/usr/local/php-ectoken/ectoken.c:208: warning: passing argument 5 of 'cfb64_encrypt' from incompatible pointer type
/usr/local/php-ectoken/ectoken.c:208: warning: passing argument 6 of 'cfb64_encrypt' makes integer from pointer without a cast
/usr/local/php-ectoken/ectoken.c:208: error: too many arguments to function 'cfb64_encrypt'
make: *** [ectoken.lo] Error 1

Post a Comment