summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2008-10-16 10:18:26 +0000
committerMax Kremmel <xing@synapse.plus.com>2008-10-16 10:18:26 +0000
commitdc54458db549e6809004e9e0d16527919b87df66 (patch)
tree10a715b70478c6c11460afbdbda3f3e6ccfa89c0
parentc7eb05308e8be7639a2b48d1bb85864288dfda57 (diff)
downloadusers-dc54458db549e6809004e9e0d16527919b87df66.tar.gz
users-dc54458db549e6809004e9e0d16527919b87df66.tar.bz2
users-dc54458db549e6809004e9e0d16527919b87df66.zip
move scrambleEmail to users/users_lib.php and rename it to scramble_email
-rw-r--r--BitUser.php38
-rw-r--r--preferences.php12
-rw-r--r--users_lib.php91
3 files changed, 81 insertions, 60 deletions
diff --git a/BitUser.php b/BitUser.php
index 9174d3c..d33a91b 100644
--- a/BitUser.php
+++ b/BitUser.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.194 2008/10/16 09:57:58 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.195 2008/10/16 10:18:26 squareing Exp $
*
* Lib for user administration, groups and permissions
* This lib uses pear so the constructor requieres
@@ -12,7 +12,7 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: BitUser.php,v 1.194 2008/10/16 09:57:58 squareing Exp $
+ * $Id: BitUser.php,v 1.195 2008/10/16 10:18:26 squareing Exp $
* @package users
*/
@@ -40,7 +40,7 @@ define("ACCOUNT_DISABLED", -6);
* Class that holds all information for a given user
*
* @author spider <spider@steelsun.com>
- * @version $Revision: 1.194 $
+ * @version $Revision: 1.195 $
* @package users
* @subpackage BitUser
*/
@@ -154,7 +154,7 @@ class BitUser extends LibertyMime {
);
//print("displayName: ".$this->mInfo['display_name']);
$this->defaults();
- $this->mInfo['publicEmail'] = scrambleEmail( $this->mInfo['email'], ( $this->getPreference( 'users_email_display' ) ? $this->getPreference( 'users_email_display' ) : NULL ) );
+ $this->mInfo['publicEmail'] = scramble_email( $this->mInfo['email'], ( $this->getPreference( 'users_email_display' ) ? $this->getPreference( 'users_email_display' ) : NULL ) );
}
$this->mTicket = substr( md5( session_id() . $this->mUserId ), 0, 20 );
} else {
@@ -2442,35 +2442,5 @@ class BitUser extends LibertyMime {
// }}}
}
-function scrambleEmail($email, $method='unicode') {
- switch ($method) {
- case 'strtr':
- $trans = array( "@" => tra(" AT "),
- "." => tra(" DOT ")
- );
- $ret = strtr($email, $trans);
- break;
- case 'x' :
- $encoded = $email;
- for ($i = strpos($email, "@") + 1; $i < strlen($email); $i++) {
- if ($encoded[$i] != ".") $encoded[$i] = 'x';
- }
- $ret = $encoded;
- break;
- case 'unicode':
- case 'y':// for previous compatibility
- $encoded = '';
- for ($i = 0; $i < strlen($email); $i++) {
- $encoded .= '&#' . ord($email[$i]). ';';
- }
- $ret = $encoded;
- break;
- default:
- $ret = NULL;
- break;
- }
- return $ret;
-}
-
/* vim: :set fdm=marker : */
?>
diff --git a/preferences.php b/preferences.php
index 281f383..e2e9b9a 100644
--- a/preferences.php
+++ b/preferences.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_users/preferences.php,v 1.55 2008/08/29 06:30:35 laetzer Exp $
+ * $Header: /cvsroot/bitweaver/_bit_users/preferences.php,v 1.56 2008/10/16 10:18:26 squareing Exp $
*
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
@@ -8,7 +8,7 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: preferences.php,v 1.55 2008/08/29 06:30:35 laetzer Exp $
+ * $Id: preferences.php,v 1.56 2008/10/16 10:18:26 squareing Exp $
* @package users
* @subpackage functions
*/
@@ -244,10 +244,10 @@ $gBitSmarty->assign( 'userTimezones', $user_timezones);
$scramblingMethods = array( "n", "strtr", "unicode", "x" );
$gBitSmarty->assign_by_ref( 'scramblingMethods', $scramblingMethods );
$scramblingEmails = array(
- tra("no"),
- scrambleEmail( $editUser->mInfo['email'], 'strtr' ),
- scrambleEmail( $editUser->mInfo['email'], 'unicode' )."-".tra( "unicode" ),
- scrambleEmail( $editUser->mInfo['email'], 'x' )
+ tra( "no" ),
+ scramble_email( $editUser->mInfo['email'], 'strtr' ),
+ scramble_email( $editUser->mInfo['email'], 'unicode' )."-".tra( "unicode" ),
+ scramble_email( $editUser->mInfo['email'], 'x' )
);
$gBitSmarty->assign_by_ref( 'scramblingEmails', $scramblingEmails );
diff --git a/users_lib.php b/users_lib.php
index e60c734..19d1243 100644
--- a/users_lib.php
+++ b/users_lib.php
@@ -1,42 +1,93 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_users/users_lib.php,v 1.2 2007/11/18 12:00:19 lsces Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_users/users_lib.php,v 1.3 2008/10/16 10:18:26 squareing Exp $
* @package users
* @subpackage functions
*/
/**
- * users_admin_email_user
+ * users_admin_email_user
+ *
+ * @param array $pParamHash
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
function users_admin_email_user( &$pParamHash ) {
global $gBitSmarty, $gBitSystem;
$ret = FALSE;
$siteName = $gBitSystem->getConfig('site_title', $_SERVER['HTTP_HOST'] );
- $gBitSmarty->assign('siteName',$_SERVER["SERVER_NAME"]);
- $gBitSmarty->assign('mail_site',$_SERVER["SERVER_NAME"]);
- $gBitSmarty->assign('mail_user',$pParamHash['login']);
- if( !empty( $_REQUEST['admin_verify_user'] ) && !empty($pParamHash['user_store']['provpass']) ) {
- $apass = addslashes(substr(md5($gBitSystem->genPass()),0,25));
+ $gBitSmarty->assign( 'siteName', $_SERVER["SERVER_NAME"] );
+ $gBitSmarty->assign( 'mail_site', $_SERVER["SERVER_NAME"] );
+ $gBitSmarty->assign( 'mail_user', $pParamHash['login'] );
+ if( !empty( $_REQUEST['admin_verify_user'] ) && !empty( $pParamHash['user_store']['provpass'] )) {
+ $apass = addslashes( substr( md5( $gBitSystem->genPass() ), 0, 25 ));
$apass = $pParamHash['user_store']['provpass'];
$machine = httpPrefix().USERS_PKG_URL.'confirm.php';
// Send the mail
- $gBitSmarty->assign('mail_machine',$machine);
- $gBitSmarty->assign('mailUserId',$pParamHash['user_store']['user_id']);
- $gBitSmarty->assign('mailProvPass',$apass);
- $mail_data = $gBitSmarty->fetch('bitpackage:users/admin_validation_mail.tpl');
- mail($pParamHash['email'], $siteName.' - '.tra('Your registration information'),$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n");
- $gBitSmarty->assign('showmsg','n');
-
- $ret = array('confirm' => 'Validation email sent to ' . $pParamHash['email'] . '.');
- } elseif( !empty( $pParamHash['password'] ) ) {
+ $gBitSmarty->assign( 'mail_machine', $machine );
+ $gBitSmarty->assign( 'mailUserId', $pParamHash['user_store']['user_id'] );
+ $gBitSmarty->assign( 'mailProvPass', $apass );
+ $mail_data = $gBitSmarty->fetch( 'bitpackage:users/admin_validation_mail.tpl' );
+ mail( $pParamHash['email'], $siteName.' - '.tra( 'Your registration information' ),$mail_data,"From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n" );
+ $gBitSmarty->assign( 'showmsg', 'n' );
+
+ $ret = array(
+ 'confirm' => 'Validation email sent to '.$pParamHash['email'].'.'
+ );
+ } elseif( !empty( $pParamHash['password'] )) {
// Send the welcome mail
$gBitSmarty->assign( 'mailPassword',$pParamHash['password'] );
$gBitSmarty->assign( 'mailEmail',$pParamHash['email'] );
- $mail_data = $gBitSmarty->fetch('bitpackage:users/admin_welcome_mail.tpl');
- mail($pParamHash["email"], tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n");
- $ret = array('welcome'=>'Welcome email sent to ' . $pParamHash['email'] . '.');
+ $mail_data = $gBitSmarty->fetch( 'bitpackage:users/admin_welcome_mail.tpl' );
+ mail( $pParamHash["email"], tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n" );
+ $ret = array(
+ 'welcome' => 'Welcome email sent to '.$pParamHash['email'].'.'
+ );
}
return $ret;
}
-?> \ No newline at end of file
+
+/**
+ * scramble_email
+ *
+ * @param array $email
+ * @param string $method
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function scramble_email( $email, $method = 'unicode' ) {
+ switch( $method ) {
+ case 'strtr':
+ $trans = array( "@" => tra(" AT "),
+ "." => tra(" DOT ")
+ );
+ $ret = strtr($email, $trans);
+ break;
+
+ case 'x' :
+ $encoded = $email;
+ for ($i = strpos($email, "@") + 1; $i < strlen($email); $i++) {
+ if ($encoded[$i] != ".") $encoded[$i] = 'x';
+ }
+ $ret = $encoded;
+ break;
+
+ // for legacy code
+ case 'y':
+ case 'unicode':
+ $encoded = '';
+ for( $i = 0; $i < strlen( $email ); $i++) {
+ $encoded .= '&#' . ord( $email[$i] ). ';';
+ }
+ $ret = $encoded;
+ break;
+
+ default:
+ $ret = NULL;
+ break;
+ }
+ return $ret;
+}
+
+?>