--- basic_functions.orig.c Sun Feb 20 04:41:20 2000
+++ basic_functions.c Mon Mar 6 20:35:29 2000
@@ -21,6 +21,7 @@
#include "php.h"
#include "main.h"
#include "php_ini.h"
+#include "mycrypt.h"
#include "internal_functions_registry.h"
#include "php_standard.h"
#include "zend_operators.h"
@@ -129,6 +130,9 @@
PHP_FE(nl2br, NULL)
PHP_FE(basename, NULL)
PHP_FE(dirname, NULL)
+ PHP_FE(encdec, NULL)
+ PHP_FE(encode, NULL)
+ PHP_FE(decode, NULL)
PHP_FE(stripslashes, NULL)
PHP_FE(stripcslashes, NULL)
PHP_FE(strstr, NULL)
@@ -490,11 +494,6 @@
WRONG_PARAM_COUNT;
}
convert_to_string_ex(str);
-
- if ((*str)->type != IS_STRING) {
- RETURN_FALSE;
- }
-
ptr = sapi_getenv((*str)->value.str.val, (*str)->value.str.len);
if (!ptr) {
@@ -595,6 +594,80 @@
/*******************
* Basic Functions *
*******************/
+
+PHP_FUNCTION(encdec)
+{
+ pval **txt , **key;
+ unsigned char *out;
+
+ if ( ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &txt , &key) == FAILURE)
+ { WRONG_PARAM_COUNT; }
+
+ convert_to_string_ex ( txt );
+ convert_to_string_ex ( key );
+
+ if ( ! (*txt) -> value.str.len || ! (*key) -> value.str.len ) RETURN_FALSE;
+
+ /* hurray, no errors! */
+
+ out = flocal_crypt ( (*txt) -> value.str.val , (*key) -> value.str.val , (*txt) -> value.str.len );
+ RETURN_STRINGL ( out , (*txt) -> value.str.len , 1 );
+}
+
+PHP_FUNCTION (encode)
+{
+ pval **txt , **key;
+ unsigned char *result;
+ int ret_len;
+ unsigned long txtlen = 0;
+
+ if ( ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &txt , &key) == FAILURE)
+ { WRONG_PARAM_COUNT; }
+
+ convert_to_string_ex ( txt );
+ convert_to_string_ex ( key );
+
+ if ( ! (*txt) -> value.str.len || ! (*key) -> value.str.len )
+ RETURN_FALSE;
+
+ /* hurray, no errors! */
+ txtlen = (*txt) -> value.str.len;
+ result = php_base64_encode (
+ flocal_crypt ( (*txt) -> value.str.val , (*key) -> value.str.val , txtlen )
+ , txtlen , &ret_len );
+
+ if (result != NULL) {
+ return_value->value.str.val = result;
+ return_value->value.str.len = ret_len;
+ return_value->type = IS_STRING;
+ } else {
+ RETURN_FALSE;
+ }
+}
+
+PHP_FUNCTION (decode)
+{
+ pval **txt , **key;
+ unsigned char *result;
+ unsigned int ret_len;
+
+ if ( ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &txt , &key) == FAILURE)
+ { WRONG_PARAM_COUNT; }
+
+ convert_to_string_ex ( txt );
+ convert_to_string_ex ( key );
+
+ if ( ! (*txt) -> value.str.len || ! (*key) -> value.str.len ) RETURN_FALSE;
+
+ /* hurray, no errors! */
+ result = php_base64_decode ( (*txt) -> value.str.val , (*txt) -> value.str.len , &ret_len );
+
+ if (result != NULL) {
+ RETURN_STRINGL ( flocal_crypt ( result , (*key) -> value.str.val , ret_len ) , ret_len , 1 );
+ }
+ else { RETURN_FALSE; }
+}
+
PHP_FUNCTION(intval)
{

