zlb@ubuntu:~/php-5.2.6/ext$ sudo vim crypt.def
1.crypt.def
string encrypt(string str)
string decrypt(string str)
zlb@ubuntu:~/php-5.2.6/ext$ sudo ./ext_skel --extname=crypt --proto=crypt.def
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo vim config.m4
//打开16,18行对于.configure --enalbe的支持
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo vim crypt.c
PHP_FUNCTION(encrypt)
{
char *str = NULL;
int argc = ZEND_NUM_ARGS();
int str_len;
int i=0;
char ch;
if (zend_parse_parameters(argc TSRMLS_CC, "s", &str, &str_len) == FAILURE)
{return;}
while(ch=str[i])
{
str[i] +=3;
ch = str[++i];
}
RETURN_STRINGL(str,i,1);
//php_error(E_WARNING, "encrypt: not yet implemented");
}
PHP_FUNCTION(decrypt)
{
char *str = NULL;
int argc = ZEND_NUM_ARGS();
int str_len;
int i=0;
char ch;
if (zend_parse_parameters(argc TSRMLS_CC, "s", &str, &str_len) == FAILURE)
{return;}
while(ch=str[i])
{
str[i]-=3;
ch=str[++i];
}
RETURN_STRINGL(str,i,1);
php_error(E_WARNING, "decrypt: not yet implemented");
}
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
zlb@ubuntu:~/php-5.2.6/ext/crypt$
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo ./configure --help|grep cry
--enable-crypt Enable crypt support
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo ./configure ...
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo make ...
zlb@ubuntu:~/php-5.2.6/ext/crypt$ sudo make install ...
zlb@ubuntu:~/php-5.2.6/ext/crypt$ php crypt.php
Functions available in the test extension:
confirm_crypt_compiled
encrypt
decrypt
Congratulations! You have successfully modified ext/crypt/config.m4. Module crypt is now compiled into PHP.