summaryrefslogtreecommitdiff
path: root/ext/cybercash
diff options
context:
space:
mode:
Diffstat (limited to 'ext/cybercash')
-rw-r--r--ext/cybercash/Makefile.am2
-rw-r--r--ext/cybercash/config.h.stub1
-rw-r--r--ext/cybercash/config.m426
-rw-r--r--ext/cybercash/cybercash.c198
-rw-r--r--ext/cybercash/cybercash.h56
-rw-r--r--ext/cybercash/cyberlib.php214
-rw-r--r--ext/cybercash/test.php26
7 files changed, 0 insertions, 523 deletions
diff --git a/ext/cybercash/Makefile.am b/ext/cybercash/Makefile.am
deleted file mode 100644
index 486524e47c..0000000000
--- a/ext/cybercash/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-noinst_LTLIBRARIES=libphpext_cybercash.la
-libphpext_cybercash_la_SOURCES=cybercash.c
diff --git a/ext/cybercash/config.h.stub b/ext/cybercash/config.h.stub
deleted file mode 100644
index fb5502d911..0000000000
--- a/ext/cybercash/config.h.stub
+++ /dev/null
@@ -1 +0,0 @@
-#define HAVE_MCK 0
diff --git a/ext/cybercash/config.m4 b/ext/cybercash/config.m4
deleted file mode 100644
index 648968b9e3..0000000000
--- a/ext/cybercash/config.m4
+++ /dev/null
@@ -1,26 +0,0 @@
-dnl config.m4 for extension CyberCash
-dnl don't forget to call PHP_EXTENSION(cybercash)
-
-AC_MSG_CHECKING(for CyberCash support)
-AC_ARG_WITH(cybercash,
-[ --with-cybercash[=DIR] Include CyberCash support. DIR is the CyberCash MCK
- install directory.],
-[
- if test "$withval" != "no"; then
- test -f $withval/mckcrypt.h && MCK_DIR="$withval"
- test -f $withval/c-api/mckcrypt.h && MCK_DIR="$withval/c-api"
- if test -n "$MCK_DIR"; then
- AC_MSG_RESULT(yes)
- PHP_EXTENSION(cybercash)
- LIBS="$LIBS -L$MCK_DIR/lib"
- AC_ADD_LIBRARY_WITH_PATH(mckcrypto, $MCK_DIR/lib)
- AC_ADD_INCLUDE($MCK_DIR)
- AC_DEFINE(HAVE_MCK)
- else
- AC_MSG_ERROR(Please reinstall the CyberCash MCK - I cannot find mckcrypt.h)
- AC_MSG_RESULT(no)
- fi
-fi
-],[
- AC_MSG_RESULT(no)
-])
diff --git a/ext/cybercash/cybercash.c b/ext/cybercash/cybercash.c
deleted file mode 100644
index 9c5784886a..0000000000
--- a/ext/cybercash/cybercash.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Evan Klinger <evan715@sirius.com> |
- | Timothy Whitfield <timothy@ametro.net> |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-
-#if HAVE_MCK
-#include "cybercash.h"
-#include "mckcrypt.h"
-#include "base64.h"
-
-function_entry cybercash_functions[] = {
- PHP_FE(cybercash_encr, NULL)
- PHP_FE(cybercash_decr, NULL)
- PHP_FE(cybercash_base64_encode, NULL)
- PHP_FE(cybercash_base64_decode, NULL)
- {0}
- };
-
-zend_module_entry cybercash_module_entry = {
- "CyberCash",
- cybercash_functions,
- NULL,NULL,
- NULL,NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES,
-};
-
-PHP_FUNCTION(cybercash_encr)
-{
- pval **wmk, **sk, **inbuff;
- unsigned char *outbuff, *macbuff;
- unsigned int outAlloc, outLth;
- long errcode;
-
- if(ARG_COUNT(ht) != 3 || getParametersEx(3,&wmk,&sk,&inbuff) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(wmk);
- convert_to_string_ex(sk);
- convert_to_string_ex(inbuff);
-
- outAlloc = (*inbuff)->value.str.len + 10;
-
- outbuff = (unsigned char *)emalloc(outAlloc);
- macbuff = (unsigned char *)emalloc(20);
-
- errcode = mck_encr((*wmk)->value.str.val,(*sk)->value.str.val,
- (*inbuff)->value.str.len+1,
- (*inbuff)->value.str.val,
- outAlloc,
- outbuff,
- &outLth,
- macbuff);
-
- array_init(return_value);
-
- add_assoc_long(return_value,"errcode",errcode);
-
- if(!errcode)
- {
- add_assoc_stringl(return_value,"outbuff",outbuff,outLth,0);
- add_assoc_long(return_value,"outLth",outLth);
- add_assoc_stringl(return_value,"macbuff",macbuff,20,0);
- }
- else
- {
- efree(outbuff);
- efree(macbuff);
- }
-}
-
-PHP_FUNCTION(cybercash_decr)
-{
- pval **wmk,**sk,**inbuff;
- unsigned char *outbuff, *macbuff;
- unsigned int outAlloc, outLth;
- long errcode;
-
-
- if(ARG_COUNT(ht) != 3 || getParametersEx(3,&wmk,&sk,&inbuff) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(wmk);
- convert_to_string_ex(sk);
- convert_to_string_ex(inbuff);
-
- outAlloc=(*inbuff)->value.str.len;
-
- outbuff=(unsigned char *)emalloc(outAlloc);
- macbuff=(unsigned char *)emalloc(20);
-
- errcode=mck_decr((*wmk)->value.str.val,
- (*sk)->value.str.val,
- (*inbuff)->value.str.len,
- (*inbuff)->value.str.val,
- outAlloc,
- outbuff,
- &outLth,
- macbuff);
-
- array_init(return_value);
-
- add_assoc_long(return_value,"errcode",errcode);
-
- if(!errcode) {
- add_assoc_stringl(return_value,"outbuff",outbuff,outLth,0);
- add_assoc_long(return_value,"outLth",outLth);
- add_assoc_stringl(return_value,"macbuff",macbuff,20,0);
- }
- else
- {
- efree(outbuff);
- efree(macbuff);
- }
-}
-
-PHP_FUNCTION(cybercash_base64_encode)
-{
- pval **inbuff;
- char *outbuff;
- long ret_length;
-
- if(ARG_COUNT(ht) != 1 ||
- getParametersEx(1,&inbuff) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(inbuff);
-
- outbuff=(char *)emalloc(
- base64_enc_size((unsigned int)(*inbuff)->value.str.len));
-
- ret_length=base64_encode(outbuff,
- (*inbuff)->value.str.val,(*inbuff)->value.str.len);
-
- return_value->value.str.val=outbuff;
- return_value->value.str.len=ret_length;
- return_value->type=IS_STRING;
-
-}
-
-PHP_FUNCTION(cybercash_base64_decode)
-{
- pval **inbuff;
- char *outbuff;
- long ret_length;
-
- if(ARG_COUNT(ht) != 1 ||
- getParametersEx(1,&inbuff) == FAILURE)
- {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_string_ex(inbuff);
-
- outbuff=(char *)emalloc(
- base64_dec_size((unsigned int)(*inbuff)->value.str.len));
-
- ret_length=base64_decode(outbuff,
- (*inbuff)->value.str.val,(*inbuff)->value.str.len);
-
- return_value->value.str.val=outbuff;
- return_value->value.str.len=ret_length;
- return_value->type=IS_STRING;
-
-}
-#endif
diff --git a/ext/cybercash/cybercash.h b/ext/cybercash/cybercash.h
deleted file mode 100644
index 27bba3edd1..0000000000
--- a/ext/cybercash/cybercash.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Evan Klinger <evan715@sirius.com> |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _CYBERCASH_H
-#define _CYBERCASH_H
-
-
-#if HAVE_MCK
-
-#if PHP_API_VERSION < 19990421
-#define zend_module_entry cybercash_module_entry
-#include "modules.h"
-#include "internal_functions.h"
-#endif
-
-extern zend_module_entry cybercash_module_entry;
-#define cybercash_module_ptr &cybercash_module_entry
-
-PHP_FUNCTION(cybercash_encr);
-PHP_FUNCTION(cybercash_decr);
-PHP_FUNCTION(cybercash_base64_encode);
-PHP_FUNCTION(cybercash_base64_decode);
-
-#else
-#define cybercash_module_ptr NULL
-#endif
-
-#define phpext_cybercash_ptr cybercash_module_ptr
-
-#endif
diff --git a/ext/cybercash/cyberlib.php b/ext/cybercash/cyberlib.php
deleted file mode 100644
index 5625e92c3e..0000000000
--- a/ext/cybercash/cyberlib.php
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-
-/*********************************************************************
- * Cyberlib - (C) American Metrocomm Internet Services *
- * by Timothy Whitfield <timothy@ametro.net> *
- * *
- * PHP Cybercash API - This requires that CyberCash support be *
- * compiled. *
- * *
- * *
- * This is an attempt to duplicate the cybercash API for PHP3 *
- * users. *
- *********************************************************************
- * This does not require merchant_conf for reasons that any file *
- * can be accessed by the web server can be accessed by any cgi. *
- *********************************************************************
- */
-
- function SendCC2_1Server($merchant,$merchant_key,
- $url,$operation,$CCNVList)
- {
- /* We need to make the url. */
- $url=$url."cr21api.cgi/".$operation;
-
- return SendCCServer($merchant,$merchant_key,$url,$CCNVList);
- }
-
- function SendCCServer($merchant,$merchant_key,$url,$CCNVList)
- {
- /* Break the url into parts. */
- $url=parse_url($url);
-
- /* Turn the name value pairs into a url encoded message. */
- $pairs="";
- $done=0;
- $more=list($key,$val)=each($CCNVList);
- while(!$done)
- {
- $pairs.=chop($key)."=".urlencode(chop($val));
-
- $more=list($key,$val)=each($CCNVList);
- if($more)
- {
- $pairs.="&";
- }
- else
- {
- $done=1;
- }
- }
-
- $encrypted_pairs=CCEncrypt($merchant_key,$pairs);
- $pairs_length=strlen($encrypted_pairs);
-
- $message=sprintf("POST %s/%s HTTP/1.0\r\n",$url["path"],$merchant);
- $message.=sprintf("User-Agent: CCMCK-%s\r\n","3.2.0.5");
- $message.="Content-type: application/x-www-form-urlencoded\r\n";
- $message.=sprintf("Content-length: %d\r\n",$pairs_length);
- $message.="\r\n";
- $message.=$encrypted_pairs."\r\n";
- $response=CCSocketSend($merchant_key,$url["host"],$url["port"],$message);
- return $response;
- }
-
- function CCEncrypt($merchant_key,$pairs)
- {
- $session_key=sprintf("%s #%ld",date("D M j H:i:s Y"),getmypid());
- $enc_msg=cybercash_encr($merchant_key,$session_key,$pairs);
- $pairs=cybercash_base64_encode($enc_msg["outbuff"]);
- $mac=cybercash_base64_encode($enc_msg["macbuff"]);
-
- /* This adds the information needed to decrypt. */
- $encrypted_pairs="message=".urlencode($pairs)."&";
- $encrypted_pairs.="session-key=".urlencode($session_key)."&";
- $encrypted_pairs.="mac=".urlencode($mac);
-
-
- return $encrypted_pairs;
- }
-
- function CCSocketSend($merchant_key,$host,$port,$message)
- {
-
- if(!$port)
- {
- $port="80";
- }
-
- /*This opens the port. */
- $fd=fsockopen($host,$port);
-
- /* Minor error checking. */
- if(!$fd)
- {
- $vars["MStatus"]="failure-hard";
- $vars["MErrMsg"]="Error contacting credit processor.";
-
- return $vars;
- }
-
- /*This sends the message. */
- fputs($fd,$message);
-
- /* We read the header in and parse at the same time. */
-
- /* Retrieve header. */
- $i=0;
- $response="";
- while(!feof($fd) && $response != "\n")
- {
- $response="";
- $more="";
- while(!feof($fd) && $more != "\n")
- {
- $more=fgetc($fd);
- if($more != "\n" || $response=="")
- {
- if($more != "\r")
- {
- $response.=$more;
- }
- }
- }
- $header[$i++]=$response;
- }
-
- /* We will now get the message. */
- $message="";
- while(!feof($fd))
- {
- $message.=fgets($fd,50);
- }
-
- /* It should be ok to close the socket now. */
- fclose($fd);
-
- /* This set of variables is encoded/encrypted. */
- $vars=CCGetVars($message);
- $vars["message"]=cybercash_base64_decode($vars["message"]);
- $vars["mac"]=cybercash_base64_decode($vars["mac"]);
-
- /* Check for errors with the request/decryption. */
- /* message is base64 and encrypted. */
- $dec_msg=cybercash_decr($merchant_key,$vars["session-key"],
- $vars["message"]);
-
- if($dec_msg["errcode"])
- {
- $vars["MStatus"]="failure-hard";
- $vars["MErrMsg"]="Response non-decodable.";
- return $vars;
- }
-
- if($dec_msg["macbuff"] != $vars["mac"])
- {
- $vars["MStatus"]="failure-hard";
- $vars["MErrMsg"]="Signitures do not match.";
- return $vars;
- }
-
- /* We will have to parse again to get more info. */
- $vars=CCGetVars($dec_msg["outbuff"]);
-
- return $vars;
- }
-
- function CCGetVars($message)
- {
- /* Retrieve variables.
- This function retrieves variables in var/value key pairs.
- So that $myvar["var"]==value
- */
-
- /* Need to find these variables too. */
- $cx=0;
- $response="";
- $more="";
- $message.="\n";
- $msg_len=strlen($message);
-
- while($cx<=$msg_len)
- {
- $more="";
- $varname="";
- $varval="";
- while($cx<=$msg_len && $more != "&" && $more != "\n")
- {
- $more=substr($message,$cx,1);
- $cx++;
- if($more != "&" && $more != "=" && $more != "\n")
- {
- $response=$response.$more;
- }
- if($more=="=")
- {
- $varname=$response;
- $response="";
- }
- if($more=="&" || $more=="\n")
- {
- $varval=$response;
- $response="";
- }
- }
-
- if($varname != "")
- {
- $cybervar[$varname]=urldecode($varval);
- }
- }
-
- return $cybervar;
- }
-?>
diff --git a/ext/cybercash/test.php b/ext/cybercash/test.php
deleted file mode 100644
index 2e5f3955ee..0000000000
--- a/ext/cybercash/test.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
- require "cyberlib.php";
-
- $merchant=""; /* Your merchant ID goes here. */
- $merchant_key=""; /* Your merchant key goes here. */
- $payment_url="http://cr.cybercash.com/cgi-bin/";
- $auth_type="mauthonly";
-
- $response=SendCC2_1Server($merchant,$merchant_key,$payment_url,
- $auth_type,array("Order-ID" => "2342322",
- "Amount" => "usd 11.50",
- "Card-Number" => "4111111111111111",
- "Card-Address" => "1600 Pennsylvania Avenue",
- "Card-City" => "Washington",
- "Card-State" => "DC",
- "Card-Zip" => "20500",
- "Card-Country" => "USA",
- "Card-Exp" => "12/99",
- "Card-Name" => "Bill Clinton"));
-
- while(list($key,$val)=each($response))
- {
- echo $key."=".$val."<br>";
- }
-
-?>