cvs: pear /PECL/spplus CREDITS config.m4 php_spplus.c php_spplus.h spplus.php /PECL/spplus/tests 001.phpt

From: Date: Thu, 07 Nov 2002 23:33:52 +0000
Subject: cvs: pear /PECL/spplus CREDITS config.m4 php_spplus.c php_spplus.h spplus.php /PECL/spplus/tests 001.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7308@lists.php.net to get a copy of this message
nicos Thu Nov 7 18:33:52 2002 EDT Added files: /pear/PECL/spplus CREDITS config.m4 php_spplus.c php_spplus.h spplus.php /pear/PECL/spplus/tests 001.phpt Log: Adding spplus

Index: pear/PECL/spplus/config.m4 +++ pear/PECL/spplus/config.m4 dnl dnl $Id: config.m4 dnl PHP_ARG_WITH(spplus, for spplus support, [ --with-spplus[=DIR] Include SPPLUS (French Caisse d'Epargne Telepaiement)]) if test "$PHP_SPPLUS" != "no"; then for i in /usr/local /usr $PHP_SPPLUS; do if test -r $i/spp_signe.h; then SPPLUS_INC_DIR=$i elif test -r $i/include/spp_signe.h; then SPPLUS_INC_DIR=$i/include fi if test -r $i/php_spplus.a; then SPPLUS_LIB_DIR=$i elif test -r $i/lib/php_spplus.a; then SPPLUS_LIB_DIR=$i/lib fi done if test -z "$SPPLUS_INC_DIR"; then AC_MSG_ERROR(Could not find spp_signe.h Please make sure you have the SPPLUS installed. Use ./configure --with-spplus=<spplus-dir> if necessary) fi if test -z "$SPPLUS_LIB_DIR"; then AC_MSG_ERROR(Could not find php_spplus.a Please make sure you have the SPPLUS installed. Use ./configure --with-spplus=<spplus-dir> if necessary) fi AC_MSG_RESULT(found in $SPPLUS_LIB_DIR) AC_MSG_RESULT(linking php_spplus.a with libspplus.a) ln -sf $SPPLUS_LIB_DIR/php_spplus.a $SPPLUS_LIB_DIR/libspplus.a PHP_ADD_INCLUDE($SPPLUS_INC_DIR) PHP_SUBST(SPPLUS_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH(spplus, $SPPLUS_LIB_DIR, SPPLUS_SHARED_LIBADD) AC_DEFINE(HAVE_SPPLUS, 1, [ ]) PHP_NEW_EXTENSION(spplus, php_spplus.c, $ext_shared) fi Index: pear/PECL/spplus/php_spplus.c +++ pear/PECL/spplus/php_spplus.c #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "php_spplus.h" #include "spp_signe.h" /* ZEND_DECLARE_MODULE_GLOBALS(spplus); */ ZEND_MINFO_FUNCTION(spplus); ZEND_MINIT_FUNCTION(spplus); ZEND_MSHUTDOWN_FUNCTION(spplus); ZEND_FUNCTION(calcul_hmac); ZEND_FUNCTION(nthmac); ZEND_FUNCTION(signeurlpaiement); ZEND_FUNCTION(calculhmac); /* {{{ mysql_functions[] */ zend_function_entry spplus_functions[] = { ZEND_FE(calcul_hmac, NULL) ZEND_FE(nthmac, NULL) ZEND_FE(signeurlpaiement, NULL) ZEND_FE(calculhmac, NULL) {NULL, NULL, NULL} }; /* }}} */ /* {{{ mysql_module_entry */ zend_module_entry spplus_module_entry={ STANDARD_MODULE_HEADER, "spplus", spplus_functions, ZEND_MINIT(spplus), ZEND_MSHUTDOWN(spplus), NULL, NULL, ZEND_MINFO(spplus), "3.0", STANDARD_MODULE_PROPERTIES }; /* }}} */ #if COMPILE_DL_SPPLUS ZEND_GET_MODULE(spplus) #endif /* {{{ ZEND_MINFO_FUNCTION */ ZEND_MINFO_FUNCTION(spplus) { php_info_print_table_start(); php_info_print_table_row(2, "SPPLUS functions", "enabled "); php_info_print_table_end(); } /* }}} */ /* {{{ ZEND_MINIT_FUNCTION */ ZEND_MINIT_FUNCTION(spplus) { return SUCCESS; } /* }}} */ /* {{{ ZEND_MSHUTDOWN_FUNCTION */ ZEND_MSHUTDOWN_FUNCTION(spplus) { return SUCCESS; } /* }}} */ /* {{{ proto char *calcul_hmac(string clent , string codesiret , string montant , string reference , string validite , string taxe , string devise , string langue) Getting a calcul_hmac key. */ ZEND_FUNCTION(calcul_hmac) { char *iclent, *icodesiret, *imontant, *ireference, *ivalidite, *itaxe, *idevise, *ilangue; int iclent_len, icodesiret_len, imontant_len, ireference_len, ivalidite_len, itaxe_len, idevise_len, ilangue_len; char *result; if (zend_parse_parameters(8, "ssssssss", &iclent, &iclent_len, &icodesiret, &icodesiret_len, &imontant, &imontant_len, &ireference, &ireference_len, &ivalidite, &ivalidite_len, &itaxe, &itaxe_len, &idevise, &idevise_len, &ilangue, &ilangue_len) == FAILURE) { WRONG_PARAM_COUNT; } result = sp_calcul_hmac(iclent, icodesiret, ireference, ilangue, idevise, imontant, itaxe, ivalidite); RETURN_STRING(result, 1); } /* }}} */ /* {{{ proto char *nthmac(string clent , string data) Getting a nthmac key. Note that data is: $data = "$codesiret$reference$langue$devise$montant$taxe$validite"; */ ZEND_FUNCTION(nthmac) { char *iclent, *idata; int iclent_len, idata_len; char *result; if (zend_parse_parameters(2, "ss", &iclent, &iclent_len, &idata, &idata_len) == FAILURE) { WRONG_PARAM_COUNT; } result = sp_NTHMAC(iclent, idata); RETURN_STRING(result, 1); } /* }}} */ /* {{{ proto char *signerurlpaiement(string clent , string data) Getting a url for the paiement redirection. Note that data is: $data = "$codesiret$reference$langue$devise$montant$taxe$validite"; */ ZEND_FUNCTION(signeurlpaiement) { char *iclent, *idata; int iclent_len, idata_len; char *result; if (zend_parse_parameters(2, "ss", &iclent, &iclent_len, &idata, &idata_len) == FAILURE) { WRONG_PARAM_COUNT; } result = sp_signeURLPaiement(iclent, idata); RETURN_STRING(result, 1); } /* }}} */ /* {{{ proto char *calculhmac(string clent , string data) Getting a calculhmac key. Note that data is: $data = "$codesiret$reference$langue$devise$montant$taxe$validite"; */ ZEND_FUNCTION(calculhmac) { char *iclent, *idata; int iclent_len, idata_len; char *result; if (zend_parse_parameters(2, "ss", &iclent, &iclent_len, &idata, &idata_len) == FAILURE) { WRONG_PARAM_COUNT; } result = sp_CalculHmac(iclent, idata); RETURN_STRING(result, 1); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ Index: pear/PECL/spplus/php_spplus.h +++ pear/PECL/spplus/php_spplus.h /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | +----------------------------------------------------------------------+ $Id: php_spplus.h,v 1.1 2002/11/07 23:33:52 nicos Exp $ */ #ifndef PHP_SPPLUS_H #define PHP_SPPLUS_H extern zend_module_entry spplus_module_entry; #define phpext_spplus_ptr &spplus_module_entry #ifdef PHP_WIN32 #define PHP_SPPLUS_API __declspec(dllexport) #else #define PHP_SPPLUS_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(spplus); PHP_MSHUTDOWN_FUNCTION(spplus); PHP_RINIT_FUNCTION(spplus); PHP_RSHUTDOWN_FUNCTION(spplus); PHP_MINFO_FUNCTION(spplus); PHP_FUNCTION(confirm_spplus_compiled); /* For testing, remove later. */ /* Declare any global variables you may need between the BEGIN and END macros here: ZEND_BEGIN_MODULE_GLOBALS(spplus) int global_value; char *global_string; ZEND_END_MODULE_GLOBALS(spplus) */ /* In every utility function you add that needs to use variables in php_spplus_globals, call TSRM_FETCH(); after declaring other variables used by that function, or better yet, pass in TSRMLS_CC after the last function argument and declare your utility function with TSRMLS_DC after the last declared argument. Always refer to the globals in your function as SPPLUS_G(variable). You are encouraged to rename these macros something shorter, see examples in any other php module directory. */ #ifdef ZTS #define SPPLUS_G(v) TSRMG(spplus_globals_id, zend_spplus_globals *, v) #else #define SPPLUS_G(v) (spplus_globals.v) #endif #endif /* PHP_SPPLUS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: */ Index: pear/PECL/spplus/spplus.php +++ pear/PECL/spplus/spplus.php <? if(!extension_loaded('spplus')) { die('Error'); } else { echo "spplus loaded"; } $clent = '58 6d fc 9c 34 91 9b 86 3f fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'; $codesiret = '00000000000001-01'; $montant = '10.00'; $reference = 'ref123456'; $validite = '31/12/2099'; $taxe = '0.0'; $devise = '978'; $langue = 'FR'; $hmac = calcul_hmac($clent,$codesiret,$montant,$reference,$validite,$taxe,$devise,$langue); echo "Calcul_hmac: ".$hmac."\n"; $data = "siret=$codesiret&reference=$reference&langue=$langue&devise=$devise&montant=$montant&taxe=$taxe&validite=$validite"; $hmac = calculhmac($clent,$data); echo "Calculhmac: ".$hmac."\n"; $data = "$codesiret$reference$langue$devise$montant$taxe$validite"; $hmac = nthmac($clent,$data); echo "nthmac: ".$hmac."\n"; $data = "https://www.spplus.net/cgis-bin/spdecrypt.exe?siret=$codesiret&reference=$reference&langue=$langue&devise=$devise&montant=$montant&taxe=$taxe&validite=$validite"; $url = signeurlpaiement($clent,$data); echo "signeurlpaiement: ".$url."\n"; ?> Index: pear/PECL/spplus/tests/001.phpt +++ pear/PECL/spplus/tests/001.phpt --TEST-- Check for spplus presence --SKIPIF-- <?php if (!extension_loaded("spplus")) print "skip"; ?> --POST-- --GET-- --INI-- --FILE-- <?php echo "spplus extension is available\n"; $clent = '58 6d fc 9c 34 91 9b 86 3f fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'; $codesiret = '00000000000001-01'; $montant = '10.00'; $reference = 'ref123456'; $validite = '31/12/2099'; $taxe = '0.0'; $devise = '978'; $langue = 'FR'; $hmac = calcul_hmac($clent,$codesiret,$montant,$reference,$validite,$taxe,$devise,$langue); echo $hmac."\n"; $data = "siret=$codesiret&reference=$reference&langue=$langue&devise=$devise&montant=$montant&taxe=$taxe&validite=$validite"; $hmac = calculhmac($clent,$data); echo $hmac."\n"; $data = "$codesiret$reference$langue$devise$montant$taxe$validite"; $hmac = nthmac($clent,$data); echo $hmac."\n"; $data = "https://www.spplus.net/cgis-bin/spdecrypt.exe?siret=$codesiret&reference=$reference&langue=$langue&devise=$devise&montant=$montant&taxe=$taxe&validite=$validite"; $url = signeurlpaiement($clent,$data); echo $url."\n"; ?> --EXPECT-- spplus extension is available 32A946AD9589521CAFA70AAD63DEB7AC20CAE858 32A946AD9589521CAFA70AAD63DEB7AC20CAE858 32A946AD9589521CAFA70AAD63DEB7AC20CAE858 https://www.spplus.net/cgis-bin/spdecrypt.exe?siret=00000000000001%2D01&reference=ref123456&langue=FR&devise=978&montant=10%2E00&taxe=0%2E0&validite=31%2F12%2F2099&hmac=32A946AD9589521CAFA70AAD63DEB7AC20CAE858
« previous php.pear.cvs (#7308) next »