summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-29 13:17:05 +0100
committerlsces <lester@lsces.co.uk>2025-08-29 13:17:05 +0100
commit251ca624f8a38988224e4373c5c970acac210d86 (patch)
treefbb8f9eb5e551f0ef8dc416f1122ca658fe7bc9c /includes
parent03f2de05ae293d5c34a6828d3d8c62e0de8938e2 (diff)
downloadusers-251ca624f8a38988224e4373c5c970acac210d86.tar.gz
users-251ca624f8a38988224e4373c5c970acac210d86.tar.bz2
users-251ca624f8a38988224e4373c5c970acac210d86.zip
Extra code updated to PHP8.4 and namespace
Diffstat (limited to 'includes')
-rwxr-xr-x[-rw-r--r--]includes/bit_setup_inc.php96
-rwxr-xr-x[-rw-r--r--]includes/display_bituser_inc.php4
-rwxr-xr-x[-rw-r--r--]includes/lookup_user_inc.php37
-rwxr-xr-x[-rw-r--r--]includes/module_controls_inc.php8
-rwxr-xr-x[-rw-r--r--]includes/register_inc.php10
-rwxr-xr-x[-rw-r--r--]includes/solvemedialib.php7
-rwxr-xr-x[-rw-r--r--]includes/users_lib.php35
7 files changed, 114 insertions, 83 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 045fa9e..4609a95 100644..100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -3,31 +3,40 @@
* @version $Header$
* @package users
*/
+use Bitweaver\Users\RolePermUser;
+use Bitweaver\KernelTools;
+
global $gBitDbType, $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName, $gBitThemes;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'users',
'package_path' => dirname( dirname( __FILE__ ) ).'/',
- 'activatable' => FALSE,
- 'required_package'=> TRUE,
-);
-$gBitSystem->registerPackage( $registerHash );
+ 'activatable' => false,
+ 'required_package'=> true,
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+define( 'USERS_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'USERS_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'USERS_PKG_URI', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+
+$gBitSystem->registerPackage( $pRegisterHash );
/* ---- services ----- */
define( 'CONTENT_SERVICE_USERS_FAVS', 'users_favorites' );
$gLibertySystem->registerService( CONTENT_SERVICE_USERS_FAVS,
USERS_PKG_NAME,
- array(
+ [
'content_icon_tpl' => 'bitpackage:users/user_favs_service_icon_inc.tpl',
'content_list_sql_function' => 'users_favs_content_list_sql',
'content_user_collection_function' => 'users_collection_sql',
- ),
- array(
- 'description' => tra( 'Provides a ajax service enabling users to bookmark any content as a favorite.' ),
- )
+ ],
+ [
+ 'description' => KernelTools::tra( 'Provides a ajax service enabling users to bookmark any content as a favorite.' ),
+ ]
);
-$gBitSystem->registerNotifyEvent( array( "user_registers" => tra( "A user registers" )));
+$gBitSystem->registerNotifyEvent( [ "user_registers" => KernelTools::tra( "A user registers" ) ] );
if( !defined( 'AVATAR_MAX_DIM' )) {
define( 'AVATAR_MAX_DIM', 100 );
@@ -40,8 +49,7 @@ if( !defined( 'LOGO_MAX_DIM' )) {
}
// a package can decide to override the default user class
-$userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' );
-require_once( USERS_PKG_CLASS_PATH.$userClass.'.php' );
+$userClass = $gBitSystem->getConfig( 'user_class', (defined('ROLE_MODEL') ) ? '\Bitweaver\Users\RolePermUser' : '\Bitweaver\Users\BitPermUser' );
// set session lifetime
if( $gBitSystem->isFeatureActive( 'site_session_lifetime' )) {
@@ -51,11 +59,10 @@ if( $gBitSystem->isFeatureActive( 'site_session_lifetime' )) {
// is session data stored in DB or in filesystem?
if( $gBitSystem->isFeatureActive( 'site_store_session_db' ) && !empty( $gBitDbType )) {
if( file_exists( EXTERNAL_LIBS_PATH.'adodb/session/adodb-session.php' )) {
- include_once( EXTERNAL_LIBS_PATH . 'adodb/session/adodb-session.php' );
- } elseif( file_exists( UTIL_PKG_INCLUDE_PATH.'adodb/session/adodb-session.php' )) {
- include_once( UTIL_PKG_INCLUDE_PATH.'adodb/session/adodb-session.php' );
+ include_once EXTERNAL_LIBS_PATH . 'adodb/session/adodb-session.php';
}
- if ( class_exists( 'ADODB_Session' ) ) {
+
+/* if ( class_exists( 'ADODB_Session' ) ) {
ADODB_Session::dataFieldName( 'session_data' );
ADODB_Session::driver( $gBitDbType );
ADODB_Session::host( $gBitDbHost );
@@ -65,6 +72,7 @@ if( $gBitSystem->isFeatureActive( 'site_store_session_db' ) && !empty( $gBitDbTy
ADODB_Session::table( BIT_DB_PREFIX.'sessions' );
ini_set( 'session.save_handler', 'user' );
}
+*/
}
session_name( BIT_SESSION_NAME );
@@ -80,6 +88,10 @@ global $gShellScript;
if( empty( $gShellScript ) ) {
if (session_status() == PHP_SESSION_NONE) {
session_start();
+ if (empty($_SESSION['csp_nonce'])) {
+ $_SESSION['csp_nonce'] = bin2hex(random_bytes(16));
+ }
+ $cspNonce = $_SESSION['csp_nonce'];
}
}
@@ -90,23 +102,23 @@ if( !isset( $_SERVER['HTTP_USER_AGENT'] )) {
// load the user
global $gOverrideLoginFunction;
-$siteCookie = $userClass::getSiteCookieName();
+$siteCookie = RolePermUser::getSiteCookieName(); // $userClass::getSiteCookieName();
if( !empty( $gOverrideLoginFunction )) {
- $gBitUser = new $userClass();
+ $gBitUser = new RolePermUser(); // $userClass();
$gBitUser->mUserId = $gOverrideLoginFunction();
if( $gBitUser->mUserId ) {
$gBitUser->load();
$gBitUser->loadPermissions();
}
} elseif( !empty( $_COOKIE[$siteCookie] ) ) {
- if( $gBitUser = $userClass::loadFromCache( $_COOKIE[$siteCookie] ) ) {
+ if( $gBitUser = RolePermUser::loadFromCache( $_COOKIE[$siteCookie] ) ) {
// var_dump( 'load from cache' ); die;
} else {
- $gBitUser = new $userClass();
+ $gBitUser = new RolePermUser();
if( $gBitUser->mUserId = $gBitUser->getUserIdFromCookieHash( $_COOKIE[$siteCookie] ) ) {
// we have user with this cookie.
- if( $gBitUser->load( TRUE ) ) {
+ if( $gBitUser->load( true ) ) {
// maybe do something...
}
}
@@ -115,15 +127,37 @@ if( !empty( $gOverrideLoginFunction )) {
// if we still don't have a user loaded, we'll load the anonymous user
if( empty( $gBitUser ) || !$gBitUser->isValid() ) {
- if( !($gBitUser = $userClass::loadFromCache( ANONYMOUS_USER_ID ) ) ) {
- $gBitUser = new $userClass( ANONYMOUS_USER_ID );
- if( $gBitUser->load( TRUE ) ) {
+
+ if( !($gBitUser = RolePermUser::loadFromCache( ANONYMOUS_USER_ID ) ) ) { // $userClass::loadFromCache( ANONYMOUS_USER_ID ) ) ) {
+// if( $gBitUser->load( true ) ) {
+$gBitUser = new RolePermUser();
// maybe do something...
- }
+// }
}
}
-$gBitSmarty->assignByRef( 'gBitUser', $gBitUser );
+$gBitSmarty->assign( 'gBitUser', $gBitUser );
+// Set the custom header with the nonce value
+if ( !$gBitUser->isRegistered() ) {
+ header("X-CSP-Nonce: $cspNonce");
+ $cspDirectives = [
+ "default-src 'self'",
+ "script-src 'nonce-$cspNonce' 'sha256-S99CWnPGUJ/vgQ8bHZsDaLwIKm+1Hg9ub8jZLI6f1/Q=' 'sha256-0WXB7AMgcS+xLiiMpUHQ+DGvJWInYJxuWys653a29ZE=' 'sha256-fYs400oRz/dgBlT1c/azhsoAzEr0obW//5RKb2MJzuk=' 'sha256-KlIhJzKdUgEy3yPJtkvuP0s8o7CNc2dkogmuN6JDhbA=' 'sha256-hphOYdb9WX9dW4pYcQdXa8E450mGtzl7k4kSIg1GOIo=' 'sha256-aoMVRw2ucpPYBXLlubmE7JroRgIqnRaBsYqVEZDqCZU=' 'sha256-CbFXIncEh2zmvNahVKWLX5U8qZOCB+SLiq4tpvKPuo4=' 'strict-dynamic' 'unsafe-eval' 'unsafe-hashes'",
+ "style-src 'nonce-$cspNonce' 'sha256-kFAIUwypIt04FgLyVU63Lcmp2AQimPh/TdYjy04Flxs=' 'sha256-0EZqoz+oBhx7gF4nvY2bSqoGyy4zLjNF+SDQXGp/ZrY=' 'sha256-ZVjd2zfSTfAVh1y7eCcNk0SPGUQOP/H8vzrFJIVgg90=' 'sha256-J190NMj1lQxByFdlcNKRhhCCXiUM1r+jkSLWV+llFq4=' 'sha256-BtFkuTJeZaKF8Yq+TxnX0ul9r9PfZjZSFjnGN6WPlKQ=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-CpBM5JSFkNGGsPTpBLlT8YZs6iLghHxhCZJdNMnfnh4=' 'sha256-4phJwN0tL/ygVcuaCAWhoustE+HJDZLW5UQI4eUFPp8=' 'sha256-t6oewASd7J1vBg5mQtX4hl8bg8FeegYFM3scKLIhYUc=' 'sha256-2aWu0TvBcgs1/KaHywJ+/We8HuVKvHa4bPG9n23fN/I=' 'sha256-VXDM/lJYdk4BpdCUg/naqDj8ti+GKs0SZ8AJLc3k698=' 'sha256-h7qfp6iahc2crFUNooykEE411IXaaXOFZ8OB4kpGOf0=' 'sha256-FePUZaUvmD7uZkSy3DB3sfgvxqcggJmPmYjzgcM99kE=' 'sha256-eJOzNHAPfvDe5PZ6L0Av6TgmAexyPnw5S0hjhN45Pcw=' 'sha256-Jwm2I09DTLCg5XlmwQaT8zstSSvvnZ9n17x8kw/TBkE=' 'sha256-bGnJD/Fo4m+tE/x+1fgn17TdW+k1UQUdXnACfIm4TJc=' 'sha256-hphOYdb9WX9dW4pYcQdXa8E450mGtzl7k4kSIg1GOIo=' 'sha256-efTp7owq9MrTdSJFt54KABbw/1rE1C3dDKXRcKPlvd8=' 'sha256-BdubG9A59XWzmga/PvxzdL4u6NLBQrM5iY/uDn6bfNE=' 'sha256-ONZhBkNvCH59f9kAxZ+OSq/jBOXIwIUzl3AHlIugZME=' 'unsafe-hashes' 'self'",
+ "img-src 'self' https://*.tile.openstreetmap.fr/osmfr/;",
+ "font-src 'self'",
+ "connect-src 'self'",
+ "object-src 'none'",
+ "base-uri 'none'",
+ "form-action 'self'",
+ "frame-ancestors 'none'",
+ ];
+ $cspHeader = implode('; ', $cspDirectives);
+ // Set the CSP header with a placeholder for the nonce
+ header("Content-Security-Policy: $cspHeader");
+}
+
+$gBitSmarty->assign( 'gBitUser', $gBitUser );
// If we are processing a login then do not generate the challenge
// if we are in any other case then yes.
@@ -170,15 +204,13 @@ if( !empty( $theme )) {
// register 'my' menu
if( $gBitUser->isValid() && $gBitUser->isRegistered() ) {
- $menuHash = array(
+ $menuHash = [
'package_name' => USERS_PKG_NAME,
'index_url' => ( $gBitSystem->isFeatureActive( 'users_preferences' ) ? $gBitSystem->getConfig( 'users_login_homepage', USERS_PKG_URL.'my.php' ) : '' ),
'menu_title' => 'My '.$gBitSystem->getConfig( 'site_menu_title', $gBitSystem->getConfig( 'site_title', 'Site' )),
'menu_template' => 'bitpackage:users/menu_users.tpl',
- );
+ ];
$gBitSystem->registerAppMenu( $menuHash );
}
-require_once( USERS_PKG_CLASS_PATH.'BaseAuth.php' );
-
-?>
+require_once USERS_PKG_CLASS_PATH.'BaseAuth.php'; \ No newline at end of file
diff --git a/includes/display_bituser_inc.php b/includes/display_bituser_inc.php
index db8b663..1e4e537 100644..100755
--- a/includes/display_bituser_inc.php
+++ b/includes/display_bituser_inc.php
@@ -15,6 +15,4 @@
// this first version is a bit incomplete, but at least things work now. - spiderr
include USERS_PKG_PATH.'templates/center_user_wiki_page.php';
- $gBitSystem->display( 'bitpackage:users/center_user_wiki_page.tpl' , NULL, array( 'display_mode' => 'display' ));
-
-?>
+ $gBitSystem->display( 'bitpackage:users/center_user_wiki_page.tpl' , null, array( 'display_mode' => 'display' ));
diff --git a/includes/lookup_user_inc.php b/includes/lookup_user_inc.php
index 1eabcf8..78e1f7b 100644..100755
--- a/includes/lookup_user_inc.php
+++ b/includes/lookup_user_inc.php
@@ -5,6 +5,11 @@
* @package users
* @subpackage functions
*/
+
+namespace Bitweaver\Users;
+use Bitweaver\BitBase;
+use Bitweaver\HttpStatusCodes;
+use Bitweaver\KernelTools;
global $gQueryUser;
/**
@@ -15,22 +20,21 @@ if( isset( $_REQUEST['fHomepage'] )) {
$_REQUEST['home'] = $_REQUEST['fHomepage'];
} elseif( isset( $_REQUEST['home'] )) {
$_REQUEST['fHomepage'] = $_REQUEST['home'];
-} elseif( @BitBase::verifyId( $_REQUEST['content_id'] )) {
- $userInfo = $gBitUser->getUserInfo( array( 'content_id' => $_REQUEST['content_id'] ));
- $_REQUEST['home'] = !empty( $userInfo['login'] ) ? $userInfo['login'] : NULL;
-} elseif( @BitBase::verifyId( $_REQUEST['user_id'] )) {
+} elseif( isset($_REQUEST['content_id']) && BitBase::verifyId( $_REQUEST['content_id'] )) {
+ $userInfo = $gBitUser->getUserInfo( [ 'content_id' => $_REQUEST['content_id'] ?? 0 ]);
+ $_REQUEST['home'] = !empty( $userInfo['login'] ) ? $userInfo['login'] : null;
+} elseif( isset($_REQUEST['user_id']) && BitBase::verifyId( $_REQUEST['user_id'] )) {
$userInfo = $gBitUser->getUserInfo( array( 'user_id' => $_REQUEST['user_id'] ));
- $_REQUEST['home'] = !empty( $userInfo['login'] ) ? $userInfo['login'] : NULL;
+ $_REQUEST['home'] = !empty( $userInfo['login'] ) ? $userInfo['login'] : null;
}
if( isset( $_REQUEST['home'] )) {
// this allows for a numeric user_id or alpha_numeric user_id
- $queryUserId = $gBitUser->lookupHomepage( $_REQUEST['home'], $gBitSystem->getConfig( 'users_case_sensitive_login', 'y' ) == 'y' );
- $userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' );
- require_once( USERS_PKG_CLASS_PATH. $userClass .'.php' );
- $gQueryUser = new $userClass( $queryUserId );
- $gQueryUser->load( TRUE );
- $gQueryUser->setCacheableObject( FALSE );
+ $queryUserId = $gBitUser->lookupHomepage( $_REQUEST['home'] ); //, $gBitSystem->getConfig( 'users_case_sensitive_login' ) == 'y' );
+ $userClass = $gBitSystem->getConfig( 'user_class', (defined('ROLE_MODEL') ) ? '\Bitweaver\Users\RolePermUser' : '\Bitweaver\Users\BitPermUser' );
+ $gQueryUser = new RolePermUser( $queryUserId );
+ $gQueryUser->load( true );
+ $gQueryUser->setCacheableObject( false );
} elseif( $gBitUser->isValid() ) {
// We are looking at ourself, use our existing BitUser
global $gBitUser;
@@ -40,16 +44,15 @@ if( isset( $_REQUEST['home'] )) {
if( !$gBitUser->hasPermission( 'p_users_admin' ) ) {
if( $gQueryUser->mUserId != $gBitUser->mUserId && $gQueryUser->getPreference( 'users_information' ) == 'private' ) {
// don't spit error for SEO reasons
- $gBitSmarty->assign( 'metaNoIndex', TRUE );
- $gBitSystem->fatalError( tra( "This information is private" ) , NULL, NULL, HttpStatusCodes::HTTP_NOT_FOUND );
+ $gBitSmarty->assign( 'metaNoIndex', true );
+ $gBitSystem->fatalError( KernelTools::tra( "This information is private" ) , null, null, HttpStatusCodes::HTTP_NOT_FOUND );
}
}
if( $gQueryUser->isValid() ) {
$gQueryUser->sanitizeUserInfo();
- $gBitSmarty->assignByRef( 'gQueryUser', $gQueryUser );
- $gBitSmarty->assignByRef( 'userInfo', $gQueryUser->mInfo );
- $gBitSmarty->assignByRef( 'userPrefs', $gQueryUser->mPrefs );
+ $gBitSmarty->assign( 'gQueryUser', $gQueryUser );
+ $gBitSmarty->assign( 'userInfo', $gQueryUser->mInfo );
+ $gBitSmarty->assign( 'userPrefs', $gQueryUser->mPrefs );
$gBitSmarty->assign( 'homepage_header', $gQueryUser->getPreference( 'homepage_header' ) );
}
-?>
diff --git a/includes/module_controls_inc.php b/includes/module_controls_inc.php
index 304be64..3ef6fdc 100644..100755
--- a/includes/module_controls_inc.php
+++ b/includes/module_controls_inc.php
@@ -17,17 +17,17 @@ $check_req = (isset($_REQUEST["mc_unassign"])
|| isset($_REQUEST["mc_move"]));
if (!$gBitUser->hasPermission( 'p_tidbits_configure_modules' ) && $check_req) {
$gBitSmarty->assign('msg', tra("You dont have permission to use this feature"));
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}
if ($site_user_assigned_modules != 'y' && $check_req) {
$gBitSmarty->assign('msg', tra("This feature is disabled").": site_user_assigned_modules");
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}
if ( !$gBitUser->isRegistered() && $check_req) {
$gBitSmarty->assign('msg', tra("You must log in to use this feature"));
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}
$url = $_SERVER["REQUEST_URI"];
@@ -49,7 +49,7 @@ if ($check_req) {
// Remove module movemet paramaters from an URL
// \todo What if 'mc_xxx' arg was not at the end? (if smbd fix URL by hands...)
// should I handle this very special (hack?) case?
- $url = preg_replace('/(.*)(\?|&){1}(mc_up|mc_down|mc_move|mc_unassign)=[^&]*/','\1', $url);
+ $url = preg_replace('/(.*)(\?|&)[1](mc_up|mc_down|mc_move|mc_unassign)=[^&]*/','\1', $url);
}
// Fix locaton if parameter was removed...
if ($url != $_SERVER["REQUEST_URI"]) header('location: '.$url);
diff --git a/includes/register_inc.php b/includes/register_inc.php
index 36e7e05..e872d51 100644..100755
--- a/includes/register_inc.php
+++ b/includes/register_inc.php
@@ -4,7 +4,7 @@
$userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' );
$newUser = new $userClass();
- if( $newUser->preRegisterVerify( $registerHash ) && $newUser->register( $registerHash ) ) {
+ if( $newUser->preRegisterVerify( $pRegisterHash ) && $newUser->register( $pRegisterHash ) ) {
$gBitUser->mUserId = $newUser->mUserId;
// add user to user-selected group
@@ -12,7 +12,7 @@
$groupInfo = $gBitUser->getGroupInfo( $_REQUEST['group'] );
if ( empty($groupInfo) || $groupInfo['is_public'] != 'y' ) {
$errors[] = "You can't use this group";
- $gBitSmarty->assignByRef( 'errors', $errors );
+ $gBitSmarty->assign( 'errors', $errors );
} else {
$userId = $newUser->getUserId();
$gBitUser->addUserToGroup( $userId, $_REQUEST['group'] );
@@ -38,7 +38,7 @@
$_COOKIE[$gBitUser->getSiteCookieName()] = session_id();
}
// login with email since login is not technically required in the form, as it can be auto generated during store
- $afterRegDefault = $newUser->login( $registerHash['email'], $registerHash['password'], FALSE, FALSE );
+ $afterRegDefault = $newUser->login( $pRegisterHash['email'], $pRegisterHash['password'], false, false );
$url = $gBitSystem->getConfig( 'after_reg_url' )?BIT_ROOT_URI.$gBitSystem->getConfig( 'after_reg_url' ):$afterRegDefault;
// return to referring page
if( !empty( $_SESSION['returnto'] ) ) {
@@ -47,7 +47,7 @@
} elseif ( !empty( $_REQUEST['group'] ) && !empty( $groupInfo['after_registration_page'] ) ) {
if ( $newUser->verifyId( $groupInfo['after_registration_page'] ) ) {
$url = BIT_ROOT_URI."index.php?content_id=".$groupInfo['after_registration_page'];
- } elseif( strpos( $groupInfo['after_registration_page'], '/' ) === FALSE ) {
+ } elseif( strpos( $groupInfo['after_registration_page'], '/' ) === false ) {
$url = BitPage::getDisplayUrlFromHash( $groupInfo['after_registration_page'] );
} else {
$url = $groupInfo['after_registration_page'];
@@ -58,5 +58,5 @@
}
} else {
$gBitSystem->setHttpStatus( HttpStatusCodes::HTTP_BAD_REQUEST );
- $gBitSmarty->assignByRef( 'errors', $newUser->mErrors );
+ $gBitSmarty->assign( 'errors', $newUser->mErrors );
}
diff --git a/includes/solvemedialib.php b/includes/solvemedialib.php
index 58d86b8..51b4617 100644..100755
--- a/includes/solvemedialib.php
+++ b/includes/solvemedialib.php
@@ -261,10 +261,3 @@ function solvemedia_precheck_response ($privkey, $verifycode)
return $adcopy_response;
}
-
-
-/* Mailhide related code */
-/* [ deleted ] */
-
-?>
-
diff --git a/includes/users_lib.php b/includes/users_lib.php
index afefa41..90095f5 100644..100755
--- a/includes/users_lib.php
+++ b/includes/users_lib.php
@@ -10,12 +10,17 @@
*
* @param array $pParamHash
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return bool true on success, false on failure - mErrors will contain reason for failure
*/
+
+namespace Bitweaver\Users;
+
+use Bitweaver\KernelTools;
+
function users_admin_email_user( &$pParamHash ) {
global $gBitSmarty, $gBitSystem;
- $ret = FALSE;
+ $ret = false;
$siteName = $gBitSystem->getConfig('site_title', $_SERVER['HTTP_HOST'] );
$gBitSmarty->assign( 'siteName', $_SERVER["SERVER_NAME"] );
$gBitSmarty->assign( 'mail_site', $_SERVER["SERVER_NAME"] );
@@ -23,13 +28,13 @@ function users_admin_email_user( &$pParamHash ) {
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';
+ $machine = KernelTools::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" );
+ mail( $pParamHash['email'], $siteName.' - '.KernelTools::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(
@@ -40,10 +45,10 @@ function users_admin_email_user( &$pParamHash ) {
$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( $pParamHash["email"], KernelTools::tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n" );
+ $ret = [
+ 'welcome' => 'Welcome email sent to ' . $pParamHash['email'] . '.'
+ ];
}
return $ret;
}
@@ -51,16 +56,16 @@ function users_admin_email_user( &$pParamHash ) {
/**
* scramble_email
*
- * @param array $email
+ * @param string $email
* @param string $method
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return bool 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 ")
+ $trans = array( "@" => KernelTools::tra(" AT "),
+ "." => KernelTools::tra(" DOT ")
);
$ret = strtr($email, $trans);
break;
@@ -84,7 +89,7 @@ function scramble_email( $email, $method = 'unicode' ) {
break;
default:
- $ret = NULL;
+ $ret = false;
break;
}
return $ret;
@@ -117,13 +122,13 @@ function users_httpauth(){
if( $gBitUser->validate( $user, $pass, $challenge, $response ) ){
// log in user - returns a url so can't use it for validation check
$gBitUser->login( $user, $pass, $challenge, $response );
- return( TRUE );
+ return true;
}
// require http auth
else{
header('WWW-Authenticate: Basic realm="Test"');
header('HTTP/1.0 401 Unauthorized');
- $gBitSystem->fatalError( tra('HTTP Authentication Canceled') );
+ $gBitSystem->fatalError( KernelTools::tra('HTTP Authentication Canceled') );
exit;
}
}