summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDavid Croft <david@php.net>2001-01-14 08:54:01 +0000
committerDavid Croft <david@php.net>2001-01-14 08:54:01 +0000
commit560e218ee6869f3797812f244bd75d92556b8f94 (patch)
tree1b6afeda3ff140f1551122e85d8d1825e513ec58 /ext
parentc61a557808f5c4a73c2b923bac0310440c46644f (diff)
downloadphp-git-560e218ee6869f3797812f244bd75d92556b8f94.tar.gz
vpopmail extension
Diffstat (limited to 'ext')
-rw-r--r--ext/vpopmail/CREDITS2
-rw-r--r--ext/vpopmail/Makefile.in8
-rw-r--r--ext/vpopmail/config.m445
-rw-r--r--ext/vpopmail/php_vpopmail.c335
-rw-r--r--ext/vpopmail/php_vpopmail.h81
5 files changed, 471 insertions, 0 deletions
diff --git a/ext/vpopmail/CREDITS b/ext/vpopmail/CREDITS
new file mode 100644
index 0000000000..dfb39d5518
--- /dev/null
+++ b/ext/vpopmail/CREDITS
@@ -0,0 +1,2 @@
+Vpopmail
+David Croft
diff --git a/ext/vpopmail/Makefile.in b/ext/vpopmail/Makefile.in
new file mode 100644
index 0000000000..fbb38775d2
--- /dev/null
+++ b/ext/vpopmail/Makefile.in
@@ -0,0 +1,8 @@
+# $Id$
+
+LTLIBRARY_NAME = libvpopmail.la
+LTLIBRARY_SOURCES = php_vpopmail.c
+LTLIBRARY_SHARED_NAME = vpopmail.la
+LTLIBRARY_SHARED_LIBADD = $(VPOPMAIL_SHARED_LIBADD)
+
+include $(top_srcdir)/build/dynlib.mk
diff --git a/ext/vpopmail/config.m4 b/ext/vpopmail/config.m4
new file mode 100644
index 0000000000..6c20a46704
--- /dev/null
+++ b/ext/vpopmail/config.m4
@@ -0,0 +1,45 @@
+dnl $Id$
+dnl config.m4 for extension vpopmail
+
+PHP_ARG_WITH(vpopmail, whether to include vpopmail support,
+[ --with-vpopmail[=DIR] Include vpopmail support])
+
+if test "$PHP_VPOPMAIL" != "no"; then
+
+ for i in /home/vpopmail /home/popmail /var/qmail/vpopmail /var/qmail/popmail $PHP_VPOPMAIL; do
+ if test -r $i/vpopmail.h; then
+ VPOPMAIL_INC_DIR=$i
+ elif test -r $i/include/vpopmail.h; then
+ VPOPMAIL_INC_DIR=$i/include
+ fi
+
+ if test -r $i/libvpopmail.a; then
+ VPOPMAIL_LIB_DIR=$i
+ elif test -r $i/lib/libvpopmail.a; then
+ VPOPMAIL_LIB_DIR=$i/lib
+ fi
+ done
+
+ if test -z "$VPOPMAIL_INC_DIR"; then
+ AC_MSG_ERROR(Could not find vpopmail.h. Please make sure you have
+ vpopmail installed. Use
+ ./configure --with-vpopmail=<vpopmail-home-dir> if necessary)
+ fi
+
+ if test -z "$VPOPMAIL_LIB_DIR"; then
+ AC_MSG_ERROR(Could not find libvpopmail.a. Please make sure you have
+ vpopmail installed. Use
+ ./configure --with-vpopmail=<vpopmail-home-dir> if necessary)
+ fi
+
+ AC_MSG_RESULT(found in $VPOPMAIL_LIB_DIR)
+
+ AC_ADD_INCLUDE($VPOPMAIL_INC_DIR)
+
+ PHP_SUBST(VPOPMAIL_SHARED_LIBADD)
+ AC_ADD_LIBRARY_WITH_PATH(vpopmail, $VPOPMAIL_LIB_DIR, VPOPMAIL_SHARED_LIBADD)
+
+ AC_DEFINE(HAVE_VPOPMAIL, 1, [ ])
+
+ PHP_EXTENSION(vpopmail, $ext_shared)
+fi
diff --git a/ext/vpopmail/php_vpopmail.c b/ext/vpopmail/php_vpopmail.c
new file mode 100644
index 0000000000..81bd105c06
--- /dev/null
+++ b/ext/vpopmail/php_vpopmail.c
@@ -0,0 +1,335 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 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: David Croft <david@infotrek.co.uk> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "php.h"
+#include "php_ini.h"
+#include "php_vpopmail.h"
+
+#include "vpopmail.h"
+
+#include "ext/standard/php_string.h"
+
+#ifdef ZTS
+int vpopmail_globals_id;
+#else
+php_vpopmail_globals vpopmail_globals;
+#endif
+
+/* Function table */
+
+function_entry vpopmail_functions[] = {
+ PHP_FE(vpopmail_auth_user, NULL)
+ PHP_FE(vpopmail_adddomain, NULL)
+ PHP_FE(vpopmail_deldomain, NULL)
+ PHP_FE(vpopmail_adduser, NULL)
+ PHP_FE(vpopmail_deluser, NULL)
+ PHP_FE(vpopmail_passwd, NULL)
+ PHP_FE(vpopmail_setuserquota, NULL)
+ {NULL, NULL, NULL}
+};
+
+zend_module_entry vpopmail_module_entry = {
+ "vpopmail",
+ vpopmail_functions,
+ PHP_MINIT(vpopmail),
+ PHP_MSHUTDOWN(vpopmail),
+ NULL,
+ NULL,
+ PHP_MINFO(vpopmail),
+ STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_VPOPMAIL
+ZEND_GET_MODULE(vpopmail)
+#endif
+
+
+PHP_INI_BEGIN()
+ /* STD_PHP_INI_ENTRY("pfpro.proxypassword", "", PHP_INI_ALL, OnUpdateString, proxypassword, php_pfpro_globals, pfpro_globals) */
+PHP_INI_END()
+
+
+PHP_MINIT_FUNCTION(vpopmail)
+{
+ REGISTER_INI_ENTRIES();
+ return SUCCESS;
+}
+
+PHP_MSHUTDOWN_FUNCTION(vpopmail)
+{
+ UNREGISTER_INI_ENTRIES();
+ return SUCCESS;
+}
+
+PHP_MINFO_FUNCTION(vpopmail)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "vpopmail support", "enabled");
+ /* php_info_print_table_row(2, "vpopmail version", "Who knows"); */
+ php_info_print_table_end();
+
+ DISPLAY_INI_ENTRIES();
+}
+
+
+
+/* {{{ proto void vpopmail_adddomain($domain, $dir, $uid, $gid)
+ Add a new virtual domain */
+PHP_FUNCTION(vpopmail_adddomain)
+{
+ zval **domain;
+ zval **dir;
+ zval **uid;
+ zval **gid;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 4
+ || zend_get_parameters_ex(4, &domain, &dir, &uid, &gid) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(domain);
+ convert_to_string_ex(dir);
+ convert_to_long_ex(uid);
+ convert_to_long_ex(gid);
+
+ retval = vadddomain(Z_STRVAL_PP(domain),
+ /* Z_STRVAL_PP(dir),
+ Z_LVAL_PP(uid), */
+ Z_LVAL_PP(gid));
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_deldomain($domain)
+ Delete a virtual domain */
+PHP_FUNCTION(vpopmail_deldomain)
+{
+ zval **domain;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &domain) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(domain);
+
+ retval = vdeldomain(Z_STRVAL_PP(domain));
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_adduser($user, $domain, $password[, $gecos[, $apop]])
+ Add a new user to the specified virtual domain */
+PHP_FUNCTION(vpopmail_adduser)
+{
+ zval **user;
+ zval **domain;
+ zval **password;
+ zval **gecos;
+ zval **apop;
+ int is_apop = 0;
+ char *the_gecos = "";
+ int retval;
+
+ if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 5
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &password, &gecos, &apop) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ switch (ZEND_NUM_ARGS()) {
+ case 5:
+ convert_to_boolean_ex(apop);
+ is_apop = (Z_BVAL_PP(apop) ? 1 : 0);
+ /* fall through */
+
+ case 4:
+ convert_to_string_ex(gecos);
+ the_gecos = Z_STRVAL_PP(gecos);
+ /* fall through */
+
+ default:
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+ convert_to_string_ex(password);
+ }
+
+ retval = vadduser(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(password),
+ the_gecos,
+ is_apop);
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_deluser($user, $domain)
+ Delete a user from a virtual domain */
+PHP_FUNCTION(vpopmail_deluser)
+{
+ zval **user;
+ zval **domain;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 2
+ || zend_get_parameters_ex(2, &user, &domain) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+
+ retval = vdeluser(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain));
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_passwd($user, $domain, $password)
+ Change a virtual user's password */
+PHP_FUNCTION(vpopmail_passwd)
+{
+ zval **user;
+ zval **domain;
+ zval **password;
+ zval **apop;
+ int is_apop = 0;
+ int retval;
+
+ if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 4
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &password, &apop) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ if (ZEND_NUM_ARGS() > 3) {
+ convert_to_boolean_ex(apop);
+ is_apop = (Z_BVAL_PP(apop) ? 1 : 0);
+ }
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+ convert_to_string_ex(password);
+
+ retval = vpasswd(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(password),
+ is_apop);
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_setuserquota($user, $domain, $quota)
+ Sets a virtual user's quota */
+PHP_FUNCTION(vpopmail_setuserquota)
+{
+ zval **user;
+ zval **domain;
+ zval **quota;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 3
+ || zend_get_parameters_ex(3, &user, &domain, &quota) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+ convert_to_string_ex(quota);
+
+ retval = vsetuserquota(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(quota));
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void vpopmail_auth_user($user, $domain, $password)
+ Attempt to validate a username/domain/password. Returns true/false */
+PHP_FUNCTION(vpopmail_auth_user)
+{
+ zval **user;
+ zval **domain;
+ zval **password;
+ struct passwd *retval;
+
+ if (ZEND_NUM_ARGS() != 3
+ || zend_get_parameters_ex(3, &user, &domain, &password) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+ convert_to_string_ex(password);
+
+ retval = vauth_user(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(password));
+
+ if (retval == NULL) {
+ RETURN_FALSE;
+ }
+ else {
+ RETURN_TRUE;
+ }
+}
+/* }}} */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/ext/vpopmail/php_vpopmail.h b/ext/vpopmail/php_vpopmail.h
new file mode 100644
index 0000000000..83be22ec63
--- /dev/null
+++ b/ext/vpopmail/php_vpopmail.h
@@ -0,0 +1,81 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000 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: David Croft <david@infotrek.co.uk> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_VPOPMAIL_H
+#define PHP_VPOPMAIL_H
+
+#if HAVE_VPOPMAIL
+
+extern zend_module_entry vpopmail_module_entry;
+#define phpext_vpopmail_ptr &vpopmail_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_VPOPMAIL_API __declspec(dllexport)
+#else
+#define PHP_VPOPMAIL_API
+#endif
+
+PHP_MINIT_FUNCTION(vpopmail);
+PHP_MSHUTDOWN_FUNCTION(vpopmail);
+PHP_MINFO_FUNCTION(vpopmail);
+
+PHP_FUNCTION(vpopmail_adddomain);
+PHP_FUNCTION(vpopmail_deldomain);
+PHP_FUNCTION(vpopmail_adduser);
+PHP_FUNCTION(vpopmail_deluser);
+PHP_FUNCTION(vpopmail_passwd);
+PHP_FUNCTION(vpopmail_setuserquota);
+PHP_FUNCTION(vpopmail_auth_user);
+
+typedef struct {
+ int le_vpopmail;
+ int initialised;
+ char *defaulthost;
+ int defaultport;
+ int defaulttimeout;
+ char *proxyaddress;
+ int proxyport;
+ char *proxylogon;
+ char *proxypassword;
+} php_vpopmail_globals;
+
+#ifdef ZTS
+#define VPOPMAILG(v) (vpopmail_globals->v)
+#define VPOPMAILLS_FETCH() php_vpopmail_globals *vpopmail_globals = ts_resource(gd_vpopmail_id)
+#else
+#define VPOPMAILG(v) (vpopmail_globals.v)
+#define VPOPMAILLS_FETCH()
+#endif
+
+#else
+
+#define phpext_vpopmail_ptr NULL
+
+#endif
+
+#endif /* PHP_VPOPMAIL_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */