diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-29 13:18:39 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-29 13:18:39 +0100 |
| commit | d388cface6a2f2bc7368fa21d8cb6be2e7179f27 (patch) | |
| tree | ef3403eb08c68bc333061f224a61775899a98295 | |
| parent | c32ecb5a1051f7c23f25219805af49a348e111c3 (diff) | |
| download | users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.tar.gz users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.tar.bz2 users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.zip | |
General tools updated to PHP8.4 and namespace
| -rwxr-xr-x[-rw-r--r--] | assigned_modules.php | 43 | ||||
| -rwxr-xr-x[-rw-r--r--] | bookmark.php | 6 | ||||
| -rwxr-xr-x[-rw-r--r--] | captcha_image.php | 7 | ||||
| -rwxr-xr-x[-rw-r--r--] | change_password.php | 27 | ||||
| -rwxr-xr-x[-rw-r--r--] | confirm.php | 14 | ||||
| -rwxr-xr-x[-rw-r--r--] | custom_home.php | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | edit_personal_page.php | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | index.php | 33 | ||||
| -rwxr-xr-x[-rw-r--r--] | logout.php | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | my.php | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | my_groups.php | 22 | ||||
| -rwxr-xr-x[-rw-r--r--] | my_images.php | 16 | ||||
| -rwxr-xr-x[-rw-r--r--] | my_roles.php | 65 | ||||
| -rwxr-xr-x[-rw-r--r--] | preferences.php | 104 | ||||
| -rwxr-xr-x[-rw-r--r--] | register.php | 45 | ||||
| -rwxr-xr-x[-rw-r--r--] | remind_password.php | 20 | ||||
| -rwxr-xr-x[-rw-r--r--] | role_register.php | 43 | ||||
| -rwxr-xr-x[-rw-r--r--] | signin.php | 17 | ||||
| -rwxr-xr-x[-rw-r--r--] | users_rss.php | 13 | ||||
| -rwxr-xr-x[-rw-r--r--] | validate.php | 74 | ||||
| -rwxr-xr-x[-rw-r--r--] | watches.php | 4 |
21 files changed, 297 insertions, 276 deletions
diff --git a/assigned_modules.php b/assigned_modules.php index a94d5df..83d7623 100644..100755 --- a/assigned_modules.php +++ b/assigned_modules.php @@ -14,36 +14,37 @@ $gEditMode = 'layout'; /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\KernelTools; $gBitSystem->fatalError( 'This page is not functional and will be fixed asap.' ); $gBitSystem->verifyPermission('p_tidbits_configure_modules'); if( !$gBitUser->canCustomizeLayout() && !$gBitUser->canCustomizeTheme() ) { - $gBitSmarty->assign('msg', tra("This feature is disabled").": user layout"); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra("This feature is disabled").": user layout"); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ] ); die; } if (!$gBitUser->isRegistered()) { - $gBitSmarty->assign('msg', tra("Permission denied: You are not logged in")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra("Permission denied: You are not logged in")); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ] ); die; } -include_once(USERS_PKG_INCLUDE_PATH.'lookup_user_inc.php'); +include_once USERS_PKG_INCLUDE_PATH.'lookup_user_inc.php'; if ($gQueryUser->mUserId != $gBitUser->mUserId && !$gBitUser->object_has_permission($gBitUser->mUserId, $gQueryUser->mInfo['content_id'], 'bituser', 'p_users_admin')) { - $gBitSmarty->assign('msg', tra('You do not have permission to edit this user\'s theme')); - $gBitSystem->display('error.tpl', NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra('You do not have permission to edit this user\'s theme')); + $gBitSystem->display('error.tpl', null, [ 'display_mode' => 'display' ] ); die; } $_REQUEST['fLayout'] = HOMEPAGE_LAYOUT; //we hardcode to a single layout for all users.... for now >:-) if (isset($_REQUEST['fSubmitSetTheme'] ) ) { if( $gBitUser->canCustomizeTheme() ) { - $gQueryUser->storePreference( 'theme', !empty( $_REQUEST["style"] ) ? $_REQUEST["style"] : NULL ); + $gQueryUser->storePreference( 'theme', !empty( $_REQUEST["style"] ) ? $_REQUEST["style"] : null ); $assignStyle = $_REQUEST["style"]; } } elseif (isset($_REQUEST['fSubmitSetHeading'] ) ) { @@ -56,7 +57,7 @@ if (isset($_REQUEST['fSubmitSetTheme'] ) ) { $fAssign['user_id'] = $gQueryUser->mUserId; $fAssign['layout'] = $_REQUEST['fLayout']; $gBitThemes->storeLayout( $fAssign ); - $gBitSmarty->assignByRef( 'fAssign', $fAssign ); + $gBitSmarty->assign( 'fAssign', $fAssign ); } elseif (isset($_REQUEST["fMove"])) { if( isset( $_REQUEST["fMove"] ) && isset( $_REQUEST["fModule"] ) ) { @@ -79,16 +80,16 @@ if (isset($_REQUEST['fSubmitSetTheme'] ) ) { } } } -$orders = array(); +$orders = []; for ($i = 1; $i < 20; $i++) { $orders[] = $i; } -$gBitSmarty->assignByRef('orders', $orders); +$gBitSmarty->assign('orders', $orders); $gBitSmarty->assign( 'homeHeaderData', $gQueryUser->getPreference( 'homepage_header' ) ); // get styles if( $gBitUser->canCustomizeTheme() ) { - $styles = $gBitThemes->getStyles( NULL, TRUE, TRUE ); - $gBitSmarty->assignByRef( 'styles', $styles ); + $styles = $gBitThemes->getStyles( null, true, true ); + $gBitSmarty->assign( 'styles', $styles ); if(!isset($_REQUEST["style"])){ $assignStyle = $gQueryUser->getPreference( 'theme' ); } @@ -100,15 +101,13 @@ if (count($assignables) > 0) { } else { $gBitSmarty->assign('canassign', 'n'); } -$modules = $gBitSystem->getLayout( $gQueryUser->mUserId, HOMEPAGE_LAYOUT, FALSE ); +$modules = $gBitSystem->getLayout( $gQueryUser->mUserId, HOMEPAGE_LAYOUT, false ); $gBitThemes->generateModuleNames( $modules ); //print_r($modules); -$gBitSmarty->assignByRef('assignables', $assignables); -$layoutAreas = array( 'left'=>'l', 'center'=>'c', 'right'=>'r' ); -$gBitSmarty->assignByRef( 'layoutAreas', $layoutAreas ); -$gBitSmarty->assignByRef('modules', $modules); +$gBitSmarty->assign('assignables', $assignables); +$layoutAreas = [ 'left'=>'l', 'center'=>'c', 'right'=>'r' ]; +$gBitSmarty->assign( 'layoutAreas', $layoutAreas ); +$gBitSmarty->assign('modules', $modules); //print_r($modules); -$gBitSystem->display( 'bitpackage:users/user_assigned_modules.tpl', 'Edit Layout', array( 'display_mode' => 'display' )); - -?> +$gBitSystem->display( 'bitpackage:users/user_assigned_modules.tpl', 'Edit Layout', [ 'display_mode' => 'display' ] ); diff --git a/bookmark.php b/bookmark.php index 18f753e..7ebfe2e 100644..100755 --- a/bookmark.php +++ b/bookmark.php @@ -10,10 +10,10 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; $statusCode = 205; -$error = TRUE; +$error = true; $msg = ""; if( $gBitUser->isRegistered() ){ @@ -39,7 +39,7 @@ if( $gBitUser->isRegistered() ){ } $gBitSmarty->assign( 'bookmarkState', $bookmarkState ); $gBitSmarty->assign( 'contentId', $_REQUEST['content_id'] ); - $error = FALSE; + $error = false; }else{ $statusCode = 401; $msg = tra( 'You can not bookmark this type of content, bookmarking denied' ); diff --git a/captcha_image.php b/captcha_image.php index a4735c4..872e9c9 100644..100755 --- a/captcha_image.php +++ b/captcha_image.php @@ -11,11 +11,11 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; // dimensions -$width = @BitBase::verifyId( $_REQUEST['width'] ) ? $_REQUEST['width'] : 140; -$height = @BitBase::verifyId( $_REQUEST['height'] ) ? $_REQUEST['height'] : 35; +$width = BitBase::verifyId( $_REQUEST['width'] ) ? $_REQUEST['width'] : 140; +$height = BitBase::verifyId( $_REQUEST['height'] ) ? $_REQUEST['height'] : 35; $img = @imagecreate( $width, $height ) or die( "The GD image library doesn't seem to be available or doesn't have JPG support." ); @@ -49,4 +49,3 @@ if( $gd["PNG Support"] ) { header( "Content-type: image/jpeg" ); imagejpeg( $img ); } -?> diff --git a/change_password.php b/change_password.php index 814e64a..97472a8 100644..100755 --- a/change_password.php +++ b/change_password.php @@ -1,4 +1,6 @@ <?php +use Bitweaver\KernelTools; + /** * change password * @@ -11,7 +13,8 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; + if( !isset( $_REQUEST['login'] )) { $_REQUEST['login'] = ''; } @@ -30,19 +33,19 @@ $gBitSmarty->assign( 'oldpass', $_REQUEST["oldpass"] ); $gBitSmarty->assign( 'provpass', $_REQUEST["provpass"] ); $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $_REQUEST['user_id'] )); -$gBitSmarty->assignByRef( 'userInfo', $userInfo ); +$gBitSmarty->assign( 'userInfo', $userInfo ); if( isset( $_REQUEST["change"] )) { if( $_REQUEST["pass"] == $_REQUEST["oldpass"] ) { - $gBitSystem->fatalError( tra( "You can not use the same password again" )); + $gBitSystem->fatalError( KernelTools::tra( "You can not use the same password again" )); } if( $passswordError = $gBitUser->verifyPasswordFormat( $_REQUEST["pass"], $_REQUEST["pass2"] )) { - $gBitSystem->fatalError( tra( $passswordError )); + $gBitSystem->fatalError( KernelTools::tra( $passswordError )); } - $validated = FALSE; + $validated = false; if( !empty( $_REQUEST["provpass"] ) ) { if( $validated = $gBitUser->confirmRegistration( $userInfo['user_id'], $_REQUEST["provpass"] ) ) { if( $gBitSystem->isFeatureActive( 'send_welcome_email' ) ) { @@ -54,24 +57,22 @@ if( isset( $_REQUEST["change"] )) { $gBitSmarty->assign( 'mailPassword',$_REQUEST['pass'] ); $gBitSmarty->assign( 'mailEmail',$validated['email'] ); $mail_data = $gBitSmarty->fetch('bitpackage:users/welcome_mail.tpl'); - mail($validated["email"], tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n"); + mail($validated["email"], KernelTools::tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n"); } } else { - $gBitSystem->fatalError( tra("Password reset request is invalid or has expired") ); + $gBitSystem->fatalError( KernelTools::tra("Password reset request is invalid or has expired") ); } } elseif( !( $validated = $gBitUser->validate( $userInfo['email'], $_REQUEST["oldpass"], '', '' )) ) { - $gBitSystem->fatalError( tra("Invalid old password") ); + $gBitSystem->fatalError( KernelTools::tra("Invalid old password") ); } if( $validated ) { - $gBitUser->storePassword( $_REQUEST["pass"], (!empty( $userInfo['login'] )?$userInfo['login']:$userInfo['email']) ); - $url = $gBitUser->login( (!empty( $userInfo['login'] )?$userInfo['login']:$userInfo['email']), $_REQUEST["pass"] ); + $gBitUser->storePassword( $_REQUEST["pass"], !empty( $userInfo['login'] ) ? $userInfo['login'] : $userInfo['email'] ); + $url = $gBitUser->login( !empty( $userInfo['login'] ) ? $userInfo['login'] : $userInfo['email'], $_REQUEST["pass"] ); } - bit_redirect( $url ); + KernelTools::bit_redirect( $url ); } // Display the template $gBitSystem->display( 'bitpackage:users/change_password.tpl', 'Change Password' , array( 'display_mode' => 'display' )); - -?> diff --git a/confirm.php b/confirm.php index dfb4fe4..b39c09e 100644..100755 --- a/confirm.php +++ b/confirm.php @@ -1,4 +1,7 @@ <?php +use Bitweaver\HttpStatusCodes; +use Bitweaver\KernelTools; + /** * confirm password change * @@ -11,16 +14,15 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; if( !empty( $_REQUEST["v"] ) && strpos( $_REQUEST["v"], ':' ) ) { - list( $userId, $provPass ) = explode( ':', $_REQUEST["v"] ); + [ $userId, $provPass ] = explode( ':', $_REQUEST["v"] ); } if( !empty( $userId ) && !empty( $provPass ) && $userInfo = $gBitUser->confirmRegistration( $userId, $provPass ) ) { - $gBitSmarty->assignByRef( 'userInfo', $userInfo ); - $gBitSystem->display( 'bitpackage:users/change_password.tpl', 'Confirm Password Change' , array( 'display_mode' => 'display' )); + $gBitSmarty->assign( 'userInfo', $userInfo ); + $gBitSystem->display( 'bitpackage:users/change_password.tpl', 'Confirm Password Change' , [ 'display_mode' => 'display' ]); } else { - $gBitSystem->fatalError( tra("This confirmation link is no longer valid. Please Login or <a href=\"".USERS_PKG_URL."remind_password.php\">request a new password change</a>"), NULL, NULL, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError( KernelTools::tra("This confirmation link is no longer valid. Please Login or <a href=\"".USERS_PKG_URL."remind_password.php\">request a new password change</a>"), null, null, HttpStatusCodes::HTTP_GONE ); } -?> diff --git a/custom_home.php b/custom_home.php index 2edc688..a53f3cb 100644..100755 --- a/custom_home.php +++ b/custom_home.php @@ -11,7 +11,7 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; //ini_set('include_path','.;pear/'); //include('foobar.php'); /* @@ -30,5 +30,5 @@ print_r($b); */ $gBitSystem->verifyFeature( 'users_custom_home' ); // Display the template -$gBitSystem->display( 'bitpackage:users/custom_home_2.tpl', NULL, array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:users/custom_home_2.tpl', null, array( 'display_mode' => 'display' )); ?> diff --git a/edit_personal_page.php b/edit_personal_page.php index ed41339..dfcf321 100644..100755 --- a/edit_personal_page.php +++ b/edit_personal_page.php @@ -11,7 +11,7 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; $gBitUser->verifyRegistered(); @@ -51,18 +51,18 @@ if(isset($_REQUEST["preview"])) { $gBitUser->mInfo['parsed_data'] = $parsed; /* SPELLCHECKING INITIAL ATTEMPT */ //This nice function does all the job! - $gBitSmarty->assignByRef( 'pageInfo', $gBitUser->mInfo ); + $gBitSmarty->assign( 'pageInfo', $gBitUser->mInfo ); $gBitUser->invokeServices( 'content_preview_function' ); } else { $gBitUser->invokeServices( 'content_edit_function' ); } -$gBitSmarty->assignByRef( 'pageInfo', $gBitUser->mInfo ); -$gBitSmarty->assignByRef( 'gContent', $gBitUser ); +$gBitSmarty->assign( 'pageInfo', $gBitUser->mInfo ); +$gBitSmarty->assign( 'gContent', $gBitUser ); $gBitSmarty->assign( 'show_page_bar', 'y' ); $gBitSystem->setConfig( 'wiki_description', 'n' ); -$gBitSystem->display( 'bitpackage:users/edit_personal_page.tpl', NULL, array( 'display_mode' => 'edit' ) ); +$gBitSystem->display( 'bitpackage:users/edit_personal_page.tpl', null, array( 'display_mode' => 'edit' ) ); ?> diff --git a/index.php b/index.php index d1fff64..8ab06a1 100644..100755 --- a/index.php +++ b/index.php @@ -11,7 +11,9 @@ global $gQueryUserId, $gBitSystem; /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\HttpStatusCodes; +use Bitweaver\KernelTools; $gBitSystem->setActivePackage( 'users' ); @@ -22,7 +24,7 @@ if( $gBitSystem->getConfig( 'custom_user_fields' )) { } // lookup may be via content_id which will then return user_id for search request -require_once( USERS_PKG_INCLUDE_PATH.'lookup_user_inc.php' ); +require_once USERS_PKG_INCLUDE_PATH.'lookup_user_inc.php'; // i think we should always allow looking at yourself - regardless of permissions if( !empty( $_REQUEST['home'] ) ) { @@ -34,7 +36,7 @@ if( !empty( $_REQUEST['home'] ) ) { } if( $gBitSystem->isPackageActive('stars') && $gBitSystem->isFeatureActive('stars_user_ratings')) { - require( STARS_PKG_PATH."templates/user_ratings.php" ); + require STARS_PKG_PATH."templates/user_ratings.php"; } $gBitSystem->setCanonicalLink( $gQueryUser->getDisplayUrl() ); @@ -68,9 +70,9 @@ if( !empty( $_REQUEST['home'] ) ) { $gBitSmarty->assign( 'user_id', $gQueryUserId); // now that we have all the offsets, we can get the content list - include_once( LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php' ); + include_once LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php'; - //$gBitSmarty->assignByRef('offset', $offset); + //$gBitSmarty->assign('offset', $offset); $gBitSmarty->assign( 'contentSelect', $contentSelect ); $gBitSmarty->assign( 'contentTypes', $contentTypes ); $gBitSmarty->assign( 'contentList', $contentList ); @@ -89,33 +91,32 @@ if( !empty( $_REQUEST['home'] ) ) { // need to load layout now that we can check for center pieces $layoutHash['layout'] = $gQueryUser->getField( 'login' ); - $layoutHash['fallback'] = TRUE; + $layoutHash['fallback'] = true; $layoutHash['fallback_layout'] = 'home'; $gBitThemes->loadLayout( $layoutHash ); $gBitSmarty->assign( 'pageCssId', 'userhomepage' ); - $centerDisplay = ( count( $gCenterPieces ) ? 'bitpackage:kernel/dynamic.tpl' : 'bitpackage:users/center_user_wiki_page.tpl' ); + $centerDisplay = count( $gCenterPieces ) ? 'bitpackage:kernel/dynamic.tpl' : 'bitpackage:users/center_user_wiki_page.tpl'; } else { - $gBitSmarty->assign( 'metaNoIndex', TRUE ); - $gBitSystem->fatalError( tra( "Page not found." ), NULL, NULL, HttpStatusCodes::HTTP_NOT_FOUND ); + $gBitSmarty->assign( 'metaNoIndex', true ); + $gBitSystem->fatalError( KernelTools::tra( "Page not found." ), null, null, HttpStatusCodes::HTTP_NOT_FOUND ); } } else { $gBitSystem->verifyPermission( 'p_users_view_user_list' ); $users = $gQueryUser->getList( $_REQUEST ); - $gBitSmarty->assignByRef( 'users', $users ); - $gBitSmarty->assignByRef( 'usercount', $_REQUEST["cant"] ); + $gBitSmarty->assign( 'users', $users ); + $gBitSmarty->assign( 'usercount', $_REQUEST["cant"] ); // display an error message if( !empty( $_REQUEST['home'] )) { $gBitSystem->setHttpStatus( HttpStatusCodes::HTTP_GONE ); - $feedback['error'] = tra( 'The following user could not be found' ).': '.$_REQUEST['home']; + $feedback['error'] = KernelTools::tra( 'The following user could not be found' ).': '.$_REQUEST['home']; $gBitSmarty->assign( 'feedback', $feedback ); } $_REQUEST['listInfo']["URL"] = USERS_PKG_URL."index.php"; - $gBitSmarty->assignByRef( 'control', $_REQUEST['listInfo'] ); - $gBitSmarty->assignByRef( 'listInfo', $_REQUEST['listInfo'] ); - $browserTitle = $gBitSystem->getConfig( 'site_title' ).' '.tra( 'Members' ); + $gBitSmarty->assign( 'control', $_REQUEST['listInfo'] ); + $gBitSmarty->assign( 'listInfo', $_REQUEST['listInfo'] ); + $browserTitle = $gBitSystem->getConfig( 'site_title' ).' '.KernelTools::tra( 'Members' ); $centerDisplay = 'bitpackage:users/index_list.tpl'; } $gBitSmarty->assign( 'gBitLanguage', $gBitLanguage ); $gBitSystem->display( $centerDisplay, $browserTitle , array( 'display_mode' => 'display' )); -?> diff --git a/logout.php b/logout.php index 8bc7ed0..41f9500 100644..100755 --- a/logout.php +++ b/logout.php @@ -13,7 +13,7 @@ $bypass_siteclose_check = 'y'; /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; global $gBitSystem; // go offline in Live Support if ($gBitSystem->isPackageActive( 'LIVE_SUPPORT_PKG_NAME' ) ) { @@ -11,7 +11,7 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; if( !$gBitUser->isRegistered() ) { Header( 'Location: '.USERS_PKG_URL.'signin.php' ); @@ -46,7 +46,7 @@ if( $gBitSystem->isFeatureActive( 'display_users_content_list' ) ) { $numPages = ceil( $contentListHash['cant'] / $gBitSystem->getConfig( 'max_records' ) ); $gBitSmarty->assign( 'numPages', $numPages ); - //$gBitSmarty->assignByRef('offset', $offset); + //$gBitSmarty->assign('offset', $offset); $gBitSmarty->assign( 'contentSelect', $contentSelect ); $gBitSmarty->assign( 'contentTypes', $contentTypes ); $gBitSmarty->assign( 'contentList', $contentList ); diff --git a/my_groups.php b/my_groups.php index 0c3f12c..6663426 100644..100755 --- a/my_groups.php +++ b/my_groups.php @@ -11,7 +11,7 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; global $gBitUser, $gBitSystem; @@ -26,7 +26,7 @@ if( !empty( $_REQUEST["cancel"] ) ) { if ( $gBitUser->hasPermission('p_users_create_personal_groups' ) ) { if( !empty( $_REQUEST['group_id'] ) ) { - $allPerms = $gBitUser->getGroupPermissions( array( 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : NULL )); + $allPerms = $gBitUser->getGroupPermissions( array( 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : null )); // get grouplist separately from the $users stuff to avoid splitting of data due to pagination $listHash = array( 'sort_mode' => 'group_name_asc' ); $groupList = $gBitUser->getAllGroups( $listHash ); @@ -96,7 +96,7 @@ if ( $gBitUser->hasPermission('p_users_create_personal_groups' ) ) { $gBitUser->getList($searchParams); $foundUsers = $searchParams['data']; $mid = 'bitpackage:users/my_group_edit.tpl'; - $gBitSmarty->assignByRef('foundUsers', $foundUsers); + $gBitSmarty->assign('foundUsers', $foundUsers); } elseif (!empty($_REQUEST['assignuser'])) { if( !empty($_REQUEST['group_id'] ) ) { if ($_REQUEST['group_id'] != -1 && $groupList[$_REQUEST['group_id']]['user_id'] == $gBitUser->mUserId) { @@ -121,9 +121,9 @@ if ( $gBitUser->hasPermission('p_users_create_personal_groups' ) ) { } $groupInfo = $gBitUser->getGroupInfo( $_REQUEST['group_id'] ); $groupUsers = $gBitUser->getGroupUsers( $_REQUEST['group_id'] ); - $gBitSmarty->assignByRef('groupUsers', $groupUsers); - $gBitSmarty->assignByRef('groupInfo', $groupInfo); - $gBitSmarty->assignByRef( 'allPerms', $allPerms ); + $gBitSmarty->assign('groupUsers', $groupUsers); + $gBitSmarty->assign('groupInfo', $groupInfo); + $gBitSmarty->assign( 'allPerms', $allPerms ); $gBitSystem->setBrowserTitle( 'Admininster Group: '.$groupInfo['group_name'].' '.(isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : '') ); $mid = 'bitpackage:users/my_group_edit.tpl'; } @@ -151,7 +151,7 @@ if ( ( !empty( $_REQUEST['add_public_group'] ) || !empty( $_REQUEST['remove_publ if ( !empty( $_REQUEST['add_public_group'] ) && !empty( $groupInfo['after_registration_page'] ) ) { if ( $gBitUser->verifyId( $groupInfo['after_registration_page'] ) ) { $url = BIT_ROOT_URL."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']; @@ -161,8 +161,8 @@ if ( ( !empty( $_REQUEST['add_public_group'] ) || !empty( $_REQUEST['remove_publ } /* Load up public groups and check if the user can join or leave them */ -$systemGroups = $gBitUser->getGroups( $gBitUser->mUserId, TRUE ); -$gBitSmarty->assignByRef( 'systemGroups', $systemGroups); +$systemGroups = $gBitUser->getGroups( $gBitUser->mUserId, true ); +$gBitSmarty->assign( 'systemGroups', $systemGroups); $listHash = array( 'is_public'=>'y', 'sort_mode' => array( 'is_default_asc', 'group_desc_asc' ), @@ -187,7 +187,7 @@ if( count( $publicGroups )) { break; } } - $gBitSmarty->assignByRef( 'publicGroups', $publicGroups ); + $gBitSmarty->assign( 'publicGroups', $publicGroups ); if (isset($canRemovePublic)) { $gBitSmarty->assign( 'canRemovePublic' , 'y'); } @@ -207,5 +207,5 @@ if (empty($mid)) { } // Display the template for group administration -$gBitSystem->display( $mid , NULL, array( 'display_mode' => 'display' )); +$gBitSystem->display( $mid , null, array( 'display_mode' => 'display' )); ?> diff --git a/my_images.php b/my_images.php index 80cf99f..358fde1 100644..100755 --- a/my_images.php +++ b/my_images.php @@ -11,19 +11,20 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +use Bitweaver\KernelTools; +require_once '../kernel/includes/setup_inc.php'; // User preferences screen $gBitSystem->verifyFeature( 'users_preferences' ); if( !$gBitUser->isRegistered() ) { - $gBitSystem->fatalError( tra( "You are not logged in" )); + $gBitSystem->fatalError( KernelTools::tra( "You are not logged in" )); } -include_once( USERS_PKG_INCLUDE_PATH.'lookup_user_inc.php' ); +include_once USERS_PKG_INCLUDE_PATH . 'lookup_user_inc.php'; if( $gQueryUser->mUserId != $gBitUser->mUserId && !$gBitUser->hasPermission( 'p_users_admin' ) ) { - $gBitSystem->fatalError( tra( "You do not have permission to edit this user's images" )); + $gBitSystem->fatalError( KernelTools::tra( "You do not have permission to edit this user's images" )); } $_REQUEST["user_id"] = $gQueryUser->mUserId; @@ -31,7 +32,7 @@ $_REQUEST["user_id"] = $gQueryUser->mUserId; // Upload avatar is processed here if( !empty( $_REQUEST['store'] )) { $gQueryUser->storeImages( $_REQUEST ); - bit_redirect( $gQueryUser->getDisplayUrl( $gQueryUser->mInfo['login'] )); + KernelTools::bit_redirect( $gQueryUser->getDisplayUrl( $gQueryUser->mInfo['login'] )); } elseif( !empty( $_REQUEST['delete_portrait'] )) { $gQueryUser->purgePortrait(); $gQueryUser->load(); @@ -45,7 +46,6 @@ if( !empty( $_REQUEST['store'] )) { // For some reason, we have to reassign here to make our changes to gBitUser->mInfo present in smarty. // dunno why, but this fixes the bug. XOXO spiderr -$gBitSmarty->assignByRef( 'gQueryUser', $gQueryUser ); +$gBitSmarty->assign( 'gQueryUser', $gQueryUser ); -$gBitSystem->display( 'bitpackage:users/my_images.tpl', tra( 'Personal Images' ), array( 'display_mode' => 'display' )); -?> +$gBitSystem->display( 'bitpackage:users/my_images.tpl', KernelTools::tra( 'Personal Images' ), array( 'display_mode' => 'display' )); diff --git a/my_roles.php b/my_roles.php index b64e5a3..4a3ed2a 100644..100755 --- a/my_roles.php +++ b/my_roles.php @@ -1,4 +1,7 @@ <?php + +use Bitweaver\KernelTools; +use Bitweaver\Wiki\BitPage; /** * my roles * @@ -11,22 +14,22 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; global $gBitUser, $gBitSystem; // PERMISSIONS: registered user required if ( !$gBitUser->isRegistered() ) { - $gBitSystem->fatalError( tra( "You are not logged in." )); + $gBitSystem->fatalError( KernelTools::tra( "You are not logged in." )); } if( !empty( $_REQUEST["cancel"] ) ) { - bit_redirect( USERS_PKG_URL.'my_roles.php' ); + KernelTools::bit_redirect( USERS_PKG_URL.'my_roles.php' ); } if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { if( !empty( $_REQUEST['role_id'] ) ) { - $allPerms = $gBitUser->getRolePermissions( array( 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : NULL )); + $allPerms = $gBitUser->getRolePermissions( array( 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : null )); // get rolelist separately from the $users stuff to avoid splitting of data due to pagination $listHash = array( 'sort_mode' => 'role_name_asc' ); $roleList = $gBitUser->getAllRoles( $listHash ); @@ -45,14 +48,14 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { $_REQUEST["name"] = $_REQUEST["olrole"]; } if( $gBitUser->storeRole( $_REQUEST ) ) { - $successMsg = tra("Role changes were saved sucessfully."); + $successMsg = KernelTools::tra("Role changes were saved sucessfully."); } else { $errorMsg = $gBitUser->mErrors['roles']; } // Update Permissions } elseif (isset($_REQUEST['updateperms'])) { $listHash = array( 'role_id' => $_REQUEST['role_id'] ); - $updatePerms = $gBitUser->getrolePermissions( $listHash ); + $updatePerms = $gBitUser->getRolePermissions( $listHash ); foreach (array_keys($_REQUEST['perm']) as $per) { if( isset($_REQUEST['perm'][$per]) && !isset($updatePerms[$per]) ) { // we have an unselected perm that is now selected @@ -69,25 +72,25 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { // Process a form to remove a role if( $_REQUEST["action"] == 'delete' ) { if( $gBitUser->getDefaultRole( $_REQUEST['role_id'] ) ) { - $errorMsg = tra("You cannot remove this role, as it is currently set as your 'Default' role"); + $errorMsg = KernelTools::tra("You cannot remove this role, as it is currently set as your 'Default' role"); } else { $gBitUser->expungeRole( $_REQUEST['role_id'] ); - $successMsg = tra("The role was deleted."); + $successMsg = KernelTools::tra("The role was deleted."); unset( $_REQUEST['role_id'] ); } // remove a permission from a role } elseif ($_REQUEST["action"] == 'remove') { $gBitUser->removePermissionFromRole( $_REQUEST["permission"], $_REQUEST['role_id'] ); - $successMsg = tra("Permission Removed"); + $successMsg = KernelTools::tra("Permission Removed"); $mid = 'bitpackage:users/my_role_edit.tpl'; // Create a new role } elseif( $_REQUEST["action"] == 'create' ) { - $gBitSystem->setBrowserTitle( tra('Create New Role') ); + $gBitSystem->setBrowserTitle( KernelTools::tra('Create New Role') ); $mid = 'bitpackage:users/my_role_edit.tpl'; // Assign a permission to a role } elseif ($_REQUEST["action"] == 'assign') { $gBitUser->assignPermissionToRole($_REQUEST["perm"], $_REQUEST['role_id']); - $successMsg = tra("Permission Assigned"); + $successMsg = KernelTools::tra("Permission Assigned"); $mid = 'bitpackage:users/my_role_edit.tpl'; } // Search for users to add @@ -96,14 +99,14 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { $gBitUser->getList($searchParams); $foundUsers = $searchParams['data']; $mid = 'bitpackage:users/my_role_edit.tpl'; - $gBitSmarty->assignByRef('foundUsers', $foundUsers); + $gBitSmarty->assign('foundUsers', $foundUsers); } elseif (!empty($_REQUEST['assignuser'])) { if( !empty($_REQUEST['role_id'] ) ) { if ($_REQUEST['role_id'] != -1 && $roleList[$_REQUEST['role_id']]['user_id'] == $gBitUser->mUserId) { $gBitUser->addUserToRole( $_REQUEST['assignuser'], $_REQUEST['role_id'] ); } else { - $errorMsg = tra("You can not assign users to this role."); + $errorMsg = KernelTools::tra("You can not assign users to this role."); } } $mid = 'bitpackage:users/my_role_edit.tpl'; @@ -111,7 +114,7 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { // get pagination url // get rolelist separately from the $users stuff to avoid splitting of data due to pagination - $listHash = array( 'sort_mode' => 'role_name_asc' ); + $listHash = [ 'sort_mode' => 'role_name_asc' ]; $roleList = $gBitUser->getAllUserRoles(); if( !empty( $_REQUEST['role_id'] ) ) { @@ -121,9 +124,9 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { } $roleInfo = $gBitUser->getRoleInfo( $_REQUEST['role_id'] ); $roleUsers = $gBitUser->getRoleUsers( $_REQUEST['role_id'] ); - $gBitSmarty->assignByRef('roleUsers', $roleUsers); - $gBitSmarty->assignByRef('roleInfo', $roleInfo); - $gBitSmarty->assignByRef( 'allPerms', $allPerms ); + $gBitSmarty->assign('roleUsers', $roleUsers); + $gBitSmarty->assign('roleInfo', $roleInfo); + $gBitSmarty->assign( 'allPerms', $allPerms ); $gBitSystem->setBrowserTitle( 'Admininster Role: '.$roleInfo['role_name'].' '.(isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : '') ); $mid = 'bitpackage:users/my_role_edit.tpl'; } @@ -136,12 +139,7 @@ if ( $gBitUser->hasPermission('p_users_create_personal_roles' ) ) { if ( ( !empty( $_REQUEST['add_public_role'] ) || !empty( $_REQUEST['remove_public_role'] ) ) && !empty( $_REQUEST['public_role_id'] ) ) { $roleInfo = $gBitUser->getRoleInfo( $_REQUEST['public_role_id'] ); if ( empty($roleInfo) || $roleInfo['is_public'] != 'y' ) { - if (empty($_REQUEST['add_public_role'])) { - $errorMsg[] = tra("You can't join this role."); - } - else { - $errorMsg[] = tra("You can't leave this role."); - } + $errorMsg[] = ( empty( $_REQUEST['add_public_role'] ) ) ? KernelTools::tra( "You can't join this role." ) : KernelTools::tra( "You can't leave this role." ); } elseif ( !empty( $_REQUEST['add_public_role'] ) ) { $gBitUser->addUserToRole( $gBitUser->mUserId, $_REQUEST['public_role_id'] ); } elseif ( !empty( $_REQUEST['remove_public_role'] ) ) { @@ -151,8 +149,8 @@ if ( ( !empty( $_REQUEST['add_public_role'] ) || !empty( $_REQUEST['remove_publi if ( !empty( $_REQUEST['add_public_role'] ) && !empty( $roleInfo['after_registration_page'] ) ) { if ( $gBitUser->verifyId( $roleInfo['after_registration_page'] ) ) { $url = BIT_ROOT_URL."index.php?content_id=".$roleInfo['after_registration_page']; - } elseif( strpos( $roleInfo['after_registration_page'], '/' ) === FALSE ) { - $url = BitPage::getDisplayUrl( $roleInfo['after_registration_page'] ); + } elseif( strpos( $roleInfo['after_registration_page'], '/' ) === false ) { + $url = BitPage::getDisplayUrlFromHash( $roleInfo['after_registration_page'] ); } else { $url = $roleInfo['after_registration_page']; } @@ -162,12 +160,12 @@ if ( ( !empty( $_REQUEST['add_public_role'] ) || !empty( $_REQUEST['remove_publi } /* Load up public roles and check if the user can join or leave them */ -$systemRoles = $gBitUser->getRoles( $gBitUser->mUserId, TRUE ); -$gBitSmarty->assignByRef( 'systemRoles', $systemRoles); -$listHash = array( - 'is_public'=>'y', - 'sort_mode' => array( 'is_default_asc', 'role_desc_asc' ), -); +$systemRoles = $gBitUser->getRoles( $gBitUser->mUserId ?? 0, true ); +$gBitSmarty->assign( 'systemRoles', $systemRoles); +$listHash = [ + 'is_public' => 'y', + 'sort_mode' => [ 'is_default_asc', 'role_desc_asc' ], +]; $publicRoles = $gBitUser->getAllRoles( $listHash ); if( count( $publicRoles )) { foreach ( $systemRoles as $roleId=>$roleInfo ) { @@ -188,7 +186,7 @@ if( count( $publicRoles )) { break; } } - $gBitSmarty->assignByRef( 'publicRoles', $publicRoles ); + $gBitSmarty->assign( 'publicRoles', $publicRoles ); if (isset($canRemovePublic)) { $gBitSmarty->assign( 'canRemovePublic' , 'y'); } @@ -208,5 +206,4 @@ if (empty($mid)) { } // Display the template for role administration -$gBitSystem->display( $mid , NULL, array( 'display_mode' => 'display' )); -?> +$gBitSystem->display( $mid , null, array( 'display_mode' => 'display' )); diff --git a/preferences.php b/preferences.php index 5c24744..85cd2b5 100644..100755 --- a/preferences.php +++ b/preferences.php @@ -1,4 +1,8 @@ <?php +namespace Bitweaver\Users; +use Bitweaver\KernelTools; +use function Bitweaver\Users\scramble_email; + /** * user preferences * @@ -11,26 +15,26 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; // User preferences screen $gBitSystem->verifyFeature( 'users_preferences' ); $gBitUser->verifyRegistered(); -$feedback = array(); +$feedback = []; // set up the user we're editing if( !empty( $_REQUEST["view_user"] ) && $_REQUEST["view_user"] <> $gBitUser->mUserId ) { $gBitSystem->verifyPermission( 'p_users_admin' ); - $userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' ); + $userClass = '\Bitweaver\Users\\'.$gBitSystem->getConfig( 'user_class', (defined('ROLE_MODEL') ) ? 'RolePermUser' : 'BitPermUser' ); $editUser = new $userClass( $_REQUEST["view_user"] ); - $editUser->load( TRUE ); + $editUser->load( true ); $gBitSmarty->assign('view_user', $_REQUEST["view_user"]); $watches = $editUser->getWatches(); $gBitSmarty->assign('watches', $watches ); } else { - $gBitUser->load( TRUE ); + $gBitUser->load( true ); $editUser = &$gBitUser; } @@ -41,11 +45,11 @@ $parsedUrl = parse_url( $_SERVER["REQUEST_URI"] ); // settings only applicable when the wiki package is active if( $gBitSystem->isPackageActive( 'wiki' )) { - include_once( WIKI_PKG_CLASS_PATH.'BitPage.php' ); + include_once WIKI_PKG_CLASS_PATH . 'BitPage.php'; $parsedUrl1 = str_replace( USERS_PKG_URL."user_preferences", WIKI_PKG_URL."edit", $parsedUrl["path"] ); $parsedUrl2 = str_replace( USERS_PKG_URL."user_preferences", WIKI_PKG_URL."index", $parsedUrl["path"] ); - $gBitSmarty->assign( 'url_edit', httpPrefix(). $parsedUrl1 ); - $gBitSmarty->assign( 'url_visit', httpPrefix(). $parsedUrl2 ); + $gBitSmarty->assign( 'url_edit', KernelTools::httpPrefix(). $parsedUrl1 ); + $gBitSmarty->assign( 'url_visit', KernelTools::httpPrefix(). $parsedUrl2 ); } // custom user fields @@ -58,7 +62,7 @@ if( $gBitSystem->isFeatureActive( 'custom_user_fields' )) { $includeFiles = $gBitSystem->getIncludeFiles( 'user_preferences_inc.php', 'user_preferences_inc.tpl' ); foreach( $includeFiles as $file ) { if( !empty( $file['php'] ) && is_file( $file['php'] ) ) { - require_once( $file['php'] ); + require_once $file['php']; } } $gBitSmarty->assign( 'includFiles', $includeFiles ); @@ -73,12 +77,12 @@ if( $gBitSystem->getConfig( 'users_themes' ) == 'y' ) { if( !empty( $_REQUEST['style'] ) && $_REQUEST['style'] != $gBitSystem->getConfig( 'style' ) ) { $editUser->storePreference( 'theme', $_REQUEST["style"] ); } else { - $editUser->storePreference( 'theme', NULL ); + $editUser->storePreference( 'theme', null ); } $assignStyle = $_REQUEST["style"]; } - $styles = $gBitThemes->getStyles( NULL, TRUE, TRUE ); - $gBitSmarty->assignByRef( 'styles', $styles ); + $styles = $gBitThemes->getStyles( null, true, true ); + $gBitSmarty->assign( 'styles', $styles ); if( !isset( $_REQUEST["style"] )) { $assignStyle = $editUser->getPreference( 'theme' ); @@ -92,20 +96,20 @@ if( isset( $_REQUEST["prefs"] )) { $feedback['error'] = $editUser->mErrors; } else { // preferences - $prefs = array( - 'users_homepage' => NULL, - 'site_display_utc' => 'Local', + $prefs = [ + 'users_homepage' => null, + 'site_display_utc' => 'Local', 'site_display_timezone' => 'UTC', - 'users_country' => NULL, + 'users_country' => null, 'users_information' => 'public', 'users_email_display' => 'n', - ); + ]; if( $_REQUEST['site_display_utc'] != 'Fixed' ) { unset( $_REQUEST['site_display_timezone'] ); - $editUser->storePreference( 'site_display_timezone', NULL, USERS_PKG_NAME ); + $editUser->storePreference( 'site_display_timezone', null ); } else { - $editUser->storePreference( 'site_display_timezone', $_REQUEST['site_display_timezone'], USERS_PKG_NAME ); + $editUser->storePreference( 'site_display_timezone', $_REQUEST['site_display_timezone'] ); } // we don't have to store http:// in the db @@ -117,25 +121,25 @@ if( isset( $_REQUEST["prefs"] )) { foreach( $prefs as $pref => $default ) { if( !empty( $_REQUEST[$pref] ) && $_REQUEST[$pref] != $default ) { - $editUser->storePreference( $pref, $_REQUEST[$pref], USERS_PKG_NAME ); + $editUser->storePreference( $pref, $_REQUEST[$pref] ); } else { - $editUser->storePreference( $pref, NULL, USERS_PKG_NAME ); + $editUser->storePreference( $pref, null ); } } if( $gBitSystem->isFeatureActive( 'users_change_language' )) { - $editUser->storePreference( 'bitlanguage', ( $_REQUEST['bitlanguage'] != $gBitLanguage->mLanguage ) ? $_REQUEST['bitlanguage'] : NULL, LANGUAGES_PKG_NAME ); + $editUser->storePreference( 'bitlanguage', ( $_REQUEST['bitlanguage'] != $gBitLanguage->mLanguage ) ? $_REQUEST['bitlanguage'] : null ); } /*/ toggles - $toggles = array( + $toggles = [] ); foreach( $toggles as $toggle => $package ) { if( isset( $_REQUEST[$toggle] )) { $editUser->storePreference( $toggle, 'y', $package ); } else { - $editUser->storePreference( $toggle, NULL, $package ); + $editUser->storePreference( $toggle, null, $package ); } } */ @@ -144,16 +148,16 @@ if( isset( $_REQUEST["prefs"] )) { if( isset( $customFields ) && is_array( $customFields )) { foreach( $customFields as $f ) { if( isset( $_REQUEST['CUSTOM'][$f] )) { - $editUser->storePreference( trim( $f ), trim( $_REQUEST['CUSTOM'][$f] ), USERS_PKG_NAME ); + $editUser->storePreference( trim( $f ), trim( $_REQUEST['CUSTOM'][$f] ) ); } } } // we need to reload the page for all the included user preferences if( isset( $_REQUEST['view_user'] )) { - bit_redirect ( USERS_PKG_URL."preferences.php?view_user=$editUser->mUserId" ); + KernelTools::bit_redirect ( USERS_PKG_URL."preferences.php?view_user=$editUser->mUserId" ); } else { - bit_redirect ( USERS_PKG_URL."preferences.php" ); + KernelTools::bit_redirect ( USERS_PKG_URL."preferences.php" ); } } } @@ -162,12 +166,12 @@ if( isset( $_REQUEST["prefs"] )) { if( isset( $_REQUEST['chgemail'] )) { // check user's password if( !$gBitUser->hasPermission( 'p_users_admin' ) && !$editUser->validate( $editUser->mUsername, $_REQUEST['pass'], '', '' )) { - $gBitSystem->fatalError( tra("Invalid password. Your current password is required to change your email address." )); + $gBitSystem->fatalError( KernelTools::tra("Invalid password. Your current password is required to change your email address." )); } $org_email = $editUser->getField( 'email' ); if( $editUser->changeUserEmail( $editUser->mUserId, $_REQUEST['email'] )) { - $feedback['success'] = tra( 'Your email address was updated successfully' ); + $feedback['success'] = KernelTools::tra( 'Your email address was updated successfully' ); /* this file really needs a once over we need to call services when various preferences are stored @@ -186,45 +190,45 @@ if( isset( $_REQUEST['chgemail'] )) { // change user password if( isset( $_REQUEST["chgpswd"] )) { if( $_REQUEST["pass1"] != $_REQUEST["pass2"] ) { - $gBitSystem->fatalError( tra("The passwords didn't match" )); + $gBitSystem->fatalError( KernelTools::tra("The passwords didn't match" )); } if( !$gBitUser->hasPermission( 'p_users_admin' ) && !$editUser->validate( $editUser->getField( 'email' ), $_REQUEST["old"], '', '' )) { - $gBitSystem->fatalError( tra( "Invalid old password" )); + $gBitSystem->fatalError( KernelTools::tra( "Invalid old password" )); } //Validate password here $users_min_pass_length = $gBitSystem->getConfig( 'users_min_pass_length', 4 ); if( strlen( $_REQUEST["pass1"] ) < $users_min_pass_length ) { - $gBitSystem->fatalError( tra( "Password should be at least" ).' '.$users_min_pass_length.' '.tra( "characters long" )); + $gBitSystem->fatalError( KernelTools::tra( "Password should be at least" ).' '.$users_min_pass_length.' '.KernelTools::tra( "characters long" )); } // Check this code if( $gBitSystem->isFeatureActive( 'users_pass_chr_num' )) { if (!preg_match_all("/[0-9]+/", $_REQUEST["pass1"], $parsedUrl ) || !preg_match_all("/[A-Za-z]+/", $_REQUEST["pass1"], $parsedUrl )) { - $gBitSystem->fatalError( tra( "Password must contain both letters and numbers" )); + $gBitSystem->fatalError( KernelTools::tra( "Password must contain both letters and numbers" )); } } if( $editUser->storePassword( $_REQUEST["pass1"] )) { - $feedback['success'] = tra( 'The password was updated successfully' ); + $feedback['success'] = KernelTools::tra( 'The password was updated successfully' ); } } // this should go in tidbits if( isset( $_REQUEST['tasksprefs'] )) { - $editUser->storePreference( 'tasks_max_records', $_REQUEST['tasks_max_records'], 'users' ); + $editUser->storePreference( 'tasks_max_records', $_REQUEST['tasks_max_records'] ); if( isset( $_REQUEST['tasks_use_dates'] ) && $_REQUEST['tasks_use_dates'] == 'on' ) { - $editUser->storePreference( 'tasks_use_dates', 'y', 'users' ); + $editUser->storePreference( 'tasks_use_dates', 'y' ); } else { - $editUser->storePreference( 'tasks_use_dates', 'n', 'users' ); + $editUser->storePreference( 'tasks_use_dates', 'n' ); } } // get available languages -$languages = array(); +$languages = []; $languages = $gBitLanguage->listLanguages(); -$gBitSmarty->assignByRef( 'languages', $languages ); +$gBitSmarty->assign( 'languages', $languages ); // Get flags -$flags = array(); +$flags = []; $h = opendir( USERS_PKG_PATH.'icons/flags/' ); while( $file = readdir( $h )) { if( strstr( $file, ".gif" )) { @@ -243,7 +247,7 @@ $gBitSmarty->assign( 'feedback', $feedback ); /* This should come from BitDate->get_timezone_list but that seems to rely on a global from PEAR that does not exist. */ if ( version_compare( phpversion(), "5.2.0", ">=" ) ) { - $user_timezones = DateTimeZone::listIdentifiers(); + $user_timezones = \DateTimeZone::listIdentifiers(); } else { for($i=-12;$i<=12;$i++) { $user_timezones[$i * 60 * 60] = $i; // Stored offset needs to be in seconds. @@ -252,17 +256,17 @@ if ( version_compare( phpversion(), "5.2.0", ">=" ) ) { $gBitSmarty->assign( 'userTimezones', $user_timezones); // email scrambling methods -$scramblingMethods = array( "n", "strtr", "unicode", "x" ); -$gBitSmarty->assignByRef( 'scramblingMethods', $scramblingMethods ); -$scramblingEmails = array( - tra( "no" ), +$scramblingMethods = [ "n", "strtr", "unicode", "x" ]; +$gBitSmarty->assign( 'scramblingMethods', $scramblingMethods ); +$scramblingEmails = [ + KernelTools::tra( "no" ), scramble_email( $editUser->mInfo['email'], 'strtr' ), - scramble_email( $editUser->mInfo['email'], 'unicode' )."-".tra( "unicode" ), - scramble_email( $editUser->mInfo['email'], 'x' ) -); -$gBitSmarty->assignByRef( 'scramblingEmails', $scramblingEmails ); + scramble_email( $editUser->mInfo['email'], 'unicode' ) . "-" . KernelTools::tra( "unicode" ), + scramble_email( $editUser->mInfo['email'], 'x' ), +]; +$gBitSmarty->assign( 'scramblingEmails', $scramblingEmails ); // edit services $editUser->invokeServices( 'content_edit_function' ); -$gBitSystem->display( 'bitpackage:users/user_preferences.tpl', 'Edit User Preferences' , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:users/user_preferences.tpl', 'Edit User Preferences' , [ 'display_mode' => 'display' ]); diff --git a/register.php b/register.php index f0bdde0..4654fd3 100644..100755 --- a/register.php +++ b/register.php @@ -1,4 +1,6 @@ <?php + +use Bitweaver\KernelTools; /** * register new user * @@ -12,24 +14,26 @@ * required setup */ // Avoid user hell +use Bitweaver\BitBase; +use Bitweaver\HttpStatusCodes; +use Bitweaver\Users\BitHybridAuthManager; + if( isset( $_REQUEST['tk'] ) ) { unset( $_REQUEST['tk'] ); } +require_once '../kernel/includes/setup_inc.php'; -require_once( '../kernel/includes/setup_inc.php' ); -require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' ); -include_once( KERNEL_PKG_INCLUDE_PATH.'notification_lib.php' ); +include_once KERNEL_PKG_INCLUDE_PATH . 'notification_lib.php'; $gBitSystem->verifyFeature( 'users_allow_register' ); -require_once( USERS_PKG_CLASS_PATH.'BitHybridAuthManager.php' ); BitHybridAuthManager::loadSingleton(); global $gBitHybridAuthManager; $gBitSmarty->assign( 'hybridProviders', $gBitHybridAuthManager->getEnabledProviders() ); // Everything below here is needed for registration -require_once( USERS_PKG_CLASS_PATH.'BaseAuth.php' ); +use Bitweaver\Users\BaseAuth; if( !empty( $_REQUEST['returnto'] ) ) { $_SESSION['returnto'] = $_REQUEST['returnto']; @@ -41,20 +45,20 @@ if( !empty( $_REQUEST['returnto'] ) ) { } if( $gBitUser->isRegistered() ) { - bit_redirect( $gBitSystem->getDefaultPage() ); + KernelTools::bit_redirect( $gBitSystem->getDefaultPage() ); } if( isset( $_REQUEST["register"] ) ) { - $registerHash = $_REQUEST; + $pRegisterHash = $_REQUEST; - include( USERS_PKG_INCLUDE_PATH.'register_inc.php' ); + include USERS_PKG_INCLUDE_PATH . 'register_inc.php'; - $gBitSmarty->assignByRef( 'reg', $registerHash ); + $gBitSmarty->assign( 'reg', $pRegisterHash ); } else { if( $gBitSystem->isFeatureActive( 'custom_user_fields' ) ) { $fields= explode( ',', $gBitSystem->getConfig( 'custom_user_fields' ) ); - trim_array( $fields ); + KernelTools::trim_array( $fields ); $gBitSmarty->assign('customFields', $fields); } @@ -71,13 +75,13 @@ if( isset( $_REQUEST["register"] ) ) { } } -$languages = array(); +$languages = []; $languages = $gBitLanguage->listLanguages(); -$gBitSmarty->assignByRef( 'languages', $languages ); -$gBitSmarty->assignByRef( 'gBitLanguage', $gBitLanguage ); +$gBitSmarty->assign( 'languages', $languages ); +$gBitSmarty->assign( 'gBitLanguage', $gBitLanguage ); // Get flags here -$flags = array(); +$flags = []; $h = opendir( USERS_PKG_PATH.'icons/flags/' ); while( $file = readdir( $h )) { if( strstr( $file, ".gif" )) { @@ -94,25 +98,25 @@ $listHash = array( 'sort_mode' => array( 'is_default_asc', 'group_desc_asc' ), ); $groupList = $gBitUser->getAllGroups( $listHash ); -$gBitSmarty->assignByRef( 'groupList', $groupList ); +$gBitSmarty->assign( 'groupList', $groupList ); // include preferences settings from other packages - these will be included as individual tabs -$packages = array(); +$packages = []; foreach( $gBitSystem->mPackages as $package ) { if( $gBitSystem->isPackageActive( $package['name'] )) { $php_file = $package['path'].'user_register_inc.php'; $tpl_file = $package['path'].'templates/user_register_inc.tpl'; if( file_exists( $tpl_file )) { if( file_exists( $php_file )) { - require( $php_file ); + require $php_file; } - $p=array(); + $p=[]; $p['template'] = $tpl_file; $packages[] = $p; } } } -$gBitSmarty->assignByRef('packages',$packages ); +$gBitSmarty->assign('packages',$packages ); if( !empty( $_REQUEST['error'] ) ) { $gBitSmarty->assign( 'error', $_REQUEST['error'] ); @@ -120,5 +124,4 @@ if( !empty( $_REQUEST['error'] ) ) { } $gBitSmarty->assign( 'metaKeywords', 'Login, Sign in, Registration, Register, Create new account' ); -$gBitSystem->display('bitpackage:users/register.tpl', 'Register' , array( 'display_mode' => 'display' )); -?> +$gBitSystem->display('bitpackage:users/register.tpl', 'Register' , array( 'display_mode' => 'display' ));
\ No newline at end of file diff --git a/remind_password.php b/remind_password.php index 67bc5a8..92141af 100644..100755 --- a/remind_password.php +++ b/remind_password.php @@ -11,11 +11,13 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +use Bitweaver\KernelTools; + +require_once '../kernel/includes/setup_inc.php'; $gBitSystem->verifyFeature( 'users_forgot_pass' ); -$pageTitle = tra( 'Request Password Reminder' ); +$pageTitle = KernelTools::tra( 'Request Password Reminder' ); if( $gBitUser->isRegistered() ) { header( 'Location: '.BIT_ROOT_URL ); @@ -26,29 +28,29 @@ if( $gBitUser->isRegistered() ) { $pLogin = trim( $_REQUEST["username"] ); if ( strlen ( $pLogin ) ) { $loginCol = strpos( $pLogin, '@' ) ? 'email' : 'login'; - $userInfo = $gBitUser->getUserInfo( array( $loginCol => $pLogin ) ); + $userInfo = $gBitUser->getUserInfo( [ $loginCol => $pLogin ] ); } if( $userInfo ) { $pass = $gBitUser->genPass(); - list($pass,$provpass) = $gBitUser->createTempPassword( $_REQUEST["username"], $pass ); + [ $pass, $provpass ] = $gBitUser->createTempPassword( $_REQUEST["username"], $pass ); $gBitSmarty->assign( 'mailProvPass', $provpass ); $gBitSmarty->assign( 'mailUserId', $userInfo['user_id'] ); - $pageTitle = tra( 'Change Your Password' ); - $tmp['success'] = tra("Information to change your password has been sent to the registered email address for")." " . $_REQUEST["username"] . "."; + $pageTitle = KernelTools::tra( 'Change Your Password' ); + $tmp['success'] = KernelTools::tra("Information to change your password has been sent to the registered email address for")." " . $_REQUEST["username"] . "."; $gBitSmarty->assign('mail_user', $userInfo[$loginCol]); $gBitSmarty->assign('mail_pass', $pass); $gBitSmarty->assign('linkUri', $gBitSystem->isFeatureActive("site_https_login_required") ? 'https://'.$_SERVER['HTTP_HOST'].USERS_PKG_URL : USERS_PKG_URI ); $mail_data = $gBitSmarty->fetch('bitpackage:users/password_reminder.tpl'); - $subject = tra( "Your password for" ).": ".$gBitSystem->getConfig( 'site_title', $_SERVER['HTTP_HOST'] ); + $subject = KernelTools::tra( "Your password for" ).": ".$gBitSystem->getConfig( 'site_title', $_SERVER['HTTP_HOST'] ); mail( $userInfo['email'], $subject, $mail_data, "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\nContent-type: text/plain;charset=utf-8\n"); // Just show "success" message and no form } else { // Show error message (and leave form visible so user can fix problem) $gBitSmarty->assign('showmsg', 'e'); - $tmp['error'] = tra("Invalid or unknown username").": ".$_REQUEST["username"]; + $tmp['error'] = KernelTools::tra("Invalid or unknown username").": ".$_REQUEST["username"]; } $gBitSmarty->assign('msg', $tmp); } // Display the template -$gBitSystem->display( 'bitpackage:users/remind_password.tpl', $pageTitle, array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:users/remind_password.tpl', $pageTitle, [ 'display_mode' => 'display' ]); diff --git a/role_register.php b/role_register.php index c87227d..e1eb0a6 100644..100755 --- a/role_register.php +++ b/role_register.php @@ -11,21 +11,25 @@ /** * required setup */ +namespace Bitweaver\Liberty; +use Bitweaver\HttpStatusCodes; +use Bitweaver\Users\BaseAuth; +use Bitweaver\Wiki\BitPage; + // Avoid user hell if( isset( $_REQUEST['tk'] ) ) { unset( $_REQUEST['tk'] ); } -require_once( '../kernel/includes/setup_inc.php' ); -require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' ); -include_once( KERNEL_PKG_INCLUDE_PATH.'notification_lib.php' ); +require_once '../kernel/includes/setup_inc.php'; + +include_once KERNEL_PKG_INCLUDE_PATH.'notification_lib.php'; +// no longer supported, needs update - spiderr require_once( USERS_PKG_INCLUDE_PATH.'recaptchalib.php' ); $gBitSystem->verifyFeature( 'users_allow_register' ); // Everything below here is needed for registration -require_once( USERS_PKG_CLASS_PATH.'BaseAuth.php' ); - if( !empty( $_REQUEST['returnto'] ) ) { $_SESSION['returnto'] = $_REQUEST['returnto']; } elseif( !empty( $_SERVER['HTTP_REFERER'] ) && !strpos( $_SERVER['HTTP_REFERER'], 'signin.php' ) && !strpos( $_SERVER['HTTP_REFERER'], 'role_register.php' ) ) { @@ -53,7 +57,7 @@ if( isset( $_REQUEST["register"] ) ) { $roleInfo = $gBitUser->getRoleInfo( $_REQUEST['role'] ); if ( empty($roleInfo) || $roleInfo['is_public'] != 'y' ) { $errors[] = "You can't use this role"; - $gBitSmarty->assignByRef( 'errors', $errors ); + $gBitSmarty->assign( 'errors', $errors ); } else { $userId = $newUser->getUserId(); $gBitUser->addUserToRole( $userId, $_REQUEST['role'] ); @@ -79,7 +83,7 @@ if( isset( $_REQUEST["register"] ) ) { $_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( $reg['email'], $reg['password'], FALSE, FALSE ); + $afterRegDefault = $newUser->login( $reg['email'], $reg['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'] ) ) { @@ -88,7 +92,7 @@ if( isset( $_REQUEST["register"] ) ) { } elseif ( !empty( $_REQUEST['role'] ) && !empty( $roleInfo['after_registration_page'] ) ) { if ( $newUser->verifyId( $roleInfo['after_registration_page'] ) ) { $url = BIT_ROOT_URI."index.php?content_id=".$roleInfo['after_registration_page']; - } elseif( strpos( $roleInfo['after_registration_page'], '/' ) === FALSE ) { + } elseif( strpos( $roleInfo['after_registration_page'], '/' ) === false ) { $url = BitPage::getDisplayUrlFromHash( $roleInfo['after_registration_page'] ); } else { $url = $roleInfo['after_registration_page']; @@ -99,10 +103,10 @@ if( isset( $_REQUEST["register"] ) ) { } } else { $gBitSystem->setHttpStatus( HttpStatusCodes::HTTP_BAD_REQUEST ); - $gBitSmarty->assignByRef( 'errors', $newUser->mErrors ); + $gBitSmarty->assign( 'errors', $newUser->mErrors ); } - $gBitSmarty->assignByRef( 'reg', $reg ); + $gBitSmarty->assign( 'reg', $reg ); } else { if( $gBitSystem->isFeatureActive( 'custom_user_fields' ) ) { @@ -124,13 +128,13 @@ if( isset( $_REQUEST["register"] ) ) { } } -$languages = array(); +$languages = []; $languages = $gBitLanguage->listLanguages(); -$gBitSmarty->assignByRef( 'languages', $languages ); -$gBitSmarty->assignByRef( 'gBitLanguage', $gBitLanguage ); +$gBitSmarty->assign( 'languages', $languages ); +$gBitSmarty->assign( 'gBitLanguage', $gBitLanguage ); // Get flags here -$flags = array(); +$flags = []; $h = opendir( USERS_PKG_PATH.'icons/flags/' ); while( $file = readdir( $h )) { if( strstr( $file, ".gif" )) { @@ -147,25 +151,25 @@ $listHash = array( 'sort_mode' => array( 'is_default_asc', 'role_desc_asc' ), ); $roleList = $gBitUser->getAllRoles( $listHash ); -$gBitSmarty->assignByRef( 'roleList', $roleList ); +$gBitSmarty->assign( 'roleList', $roleList ); // include preferences settings from other packages - these will be included as individual tabs -$packages = array(); +$packages = []; foreach( $gBitSystem->mPackages as $package ) { if( $gBitSystem->isPackageActive( $package['name'] )) { $php_file = $package['path'].'user_register_inc.php'; $tpl_file = $package['path'].'templates/user_register_inc.tpl'; if( file_exists( $tpl_file )) { if( file_exists( $php_file )) { - require( $php_file ); + require $php_file; } - $p=array(); + $p=[]; $p['template'] = $tpl_file; $packages[] = $p; } } } -$gBitSmarty->assignByRef('packages',$packages ); +$gBitSmarty->assign('packages',$packages ); if( !empty( $_REQUEST['error'] ) ) { $gBitSmarty->assign( 'error', $_REQUEST['error'] ); @@ -174,4 +178,3 @@ if( !empty( $_REQUEST['error'] ) ) { $gBitSmarty->assign( 'metaKeywords', 'Login, Sign in, Registration, Register, Create new account' ); $gBitSystem->display('bitpackage:users/role_register.tpl', 'Register' , array( 'display_mode' => 'display' )); -?> diff --git a/signin.php b/signin.php index f3f2080..5161f3d 100644..100755 --- a/signin.php +++ b/signin.php @@ -8,12 +8,16 @@ * @subpackage functions */ +namespace Bitweaver\Liberty; +use Bitweaver\KernelTools; +use Bitweaver\HttpStatusCodes; +use Bitweaver\Users\BitHybridAuthManager; + /** * required setup */ -include_once ("../kernel/includes/setup_inc.php"); +include_once "../kernel/includes/setup_inc.php"; -require_once( USERS_PKG_CLASS_PATH.'BitHybridAuthManager.php' ); BitHybridAuthManager::loadSingleton(); global $gBitHybridAuthManager; $gBitSmarty->assign( 'hybridProviders', $gBitHybridAuthManager->getEnabledProviders() ); @@ -28,7 +32,7 @@ if( !empty( $_REQUEST['returnto'] ) ) { } if( $gBitUser->isRegistered() ) { - bit_redirect( $gBitSystem->getConfig( 'users_login_homepage', $gBitSystem->getDefaultPage() ) ); + KernelTools::bit_redirect( $gBitSystem->getConfig( 'users_login_homepage', $gBitSystem->getDefaultPage() ) ); } if( !empty( $_REQUEST['error'] ) ) { @@ -36,11 +40,10 @@ if( !empty( $_REQUEST['error'] ) ) { $gBitSystem->setHttpStatus( HttpStatusCodes::HTTP_UNAUTHORIZED ); } -$languages = array(); +$languages = []; $languages = $gBitLanguage->listLanguages(); -$gBitSmarty->assignByRef( 'languages', $languages ); -$gBitSmarty->assignByRef( 'gBitLanguage', $gBitLanguage ); +$gBitSmarty->assign( 'languages', $languages ); +$gBitSmarty->assign( 'gBitLanguage', $gBitLanguage ); $gBitSmarty->assign( 'metaKeywords', 'Login, Sign in, Registration, Register, Create new account' ); $gBitSystem->display( 'bitpackage:users/signin.tpl', $gBitSystem->getConfig( 'site_title' ).' Login' , array( 'display_mode' => 'display' )); -?> diff --git a/users_rss.php b/users_rss.php index bfd315c..c730f8c 100644..100755 --- a/users_rss.php +++ b/users_rss.php @@ -5,24 +5,26 @@ * @subpackage functions */ + + /** * Initialization */ // ensure that we use absolute URLs everywhere -$_REQUEST['uri_mode'] = TRUE; -require_once( "../kernel/includes/setup_inc.php" ); +$_REQUEST['uri_mode'] = true; +require_once "../kernel/includes/setup_inc.php"; $gBitSystem->verifyPackage( 'rss' ); $gBitSystem->verifyFeature( 'users_rss' ); -require_once( RSS_PKG_INCLUDE_PATH.'rss_inc.php' ); +require_once RSS_PKG_INCLUDE_PATH.'rss_inc.php'; $rss->title = $gBitSystem->getConfig( 'users_rss_title', $gBitSystem->getConfig( 'site_title' ).' - '.tra( 'Registrations' ) ); $rss->description = $gBitSystem->getConfig( 'users_rss_description', $gBitSystem->getConfig( 'site_title' ).' - '.tra( 'RSS Feed' ) ); // check permission to view users pages if( !$gBitUser->hasPermission( 'p_users_view_user_list' ) ) { - require_once( RSS_PKG_PATH."rss_error.php" ); + require_once RSS_PKG_PATH."rss_error.php"; } else { // check if we want to use the cache file - users with users_admin permission use a different cache file $cacheFile = TEMP_PKG_PATH.RSS_PKG_NAME.'/'.USERS_PKG_NAME.'/'.$cacheFileTail; @@ -57,7 +59,6 @@ if( !$gBitUser->hasPermission( 'p_users_view_user_list' ) ) { if( $gBitUser->hasPermission( 'p_users_admin' ) ) { $item->description .= tra( "Email Address" ).': <a href="mailto:'.$feed['email'].'">'.$feed['email'].'</a><br />'; } - $gBitSmarty->loadPlugin( 'smarty_modifier_bit_short_datetime' ); $item->description .= tra( "Member Since" ).": ".smarty_modifier_bit_short_datetime( $feed['registration_date'] ).'<br />'; $item->date = ( int )$feed['registration_date']; @@ -65,7 +66,7 @@ if( !$gBitUser->hasPermission( 'p_users_view_user_list' ) ) { $item->author = $_SERVER['HTTP_HOST']; $item->descriptionTruncSize = $gBitSystem->getConfig( 'rssfeed_truncate', 5000 ); - $item->descriptionHtmlSyndicated = FALSE; + $item->descriptionHtmlSyndicated = false; // pass the item on to the rss feed creator $rss->addItem( $item ); diff --git a/validate.php b/validate.php index 9a068df..ddc5d0a 100644..100755 --- a/validate.php +++ b/validate.php @@ -8,36 +8,42 @@ * @subpackage functions */ + +namespace Bitweaver; +use Bitweaver\KernelTools; +use Bitweaver\Users\BitHybridAuthManager; +use Bitweaver\Users\RolePermUser; +use Bitweaver\Users\UserRepository; + /** * this is a dirty hack to allow admins to log in when we require a visit to the installer * used in kernel/setup_inc.php - xing - Friday Oct 03, 2008 16:44:48 CEST */ -define( 'LOGIN_VALIDATE', TRUE ); +define( 'LOGIN_VALIDATE', true ); /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; global $gBitSystem; -$redirectUrl = FALSE; +$redirectUrl = false; //Remember where user is logging in from and send them back later; using session variable for those of us who use WebISO services //do not use session loginfrom with signin.php or register.php - only "inline" login forms display in perm denied fatals, etc. -if( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/login' ) === FALSE && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/register' ) === FALSE && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/validate' ) === FALSE ) { +if( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/login' ) === false && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/register' ) === false && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/validate' ) === false ) { $from = parse_url( $_SERVER['HTTP_REFERER'] ); if( $_SERVER['HTTP_HOST'] == $from['host'] ) { // We have a referer from this site, but not an authentication URL $_SESSION['loginfrom'] = (!empty($from['path']) ? $from['path'] : '').( !empty( $from['query'] ) ? '?'.$from['query'] : '' ); } } else { - $_SESSION['loginfrom'] = NULL; - $_SESSION['returnto'] = NULL; + $_SESSION['loginfrom'] = null; + $_SESSION['returnto'] = null; } if( !empty( $_REQUEST['provider'] ) ) { - require_once( USERS_PKG_CLASS_PATH.'BitHybridAuthManager.php' ); BitHybridAuthManager::loadSingleton(); global $gBitHybridAuthManager; @@ -45,60 +51,60 @@ if( !empty( $_REQUEST['provider'] ) ) { if( $gBitUser->isRegistered() ) { $gBitHybridAuthManager->expungeUserProfile( $gBitUser->mUserId, $_REQUEST['provider'] ); } - bit_redirect( $_SESSION['loginfrom'] ); + \Bitweaver\bit_redirect( $_SESSION['loginfrom'] ); } else { try { $auth = $gBitHybridAuthManager->authenticate( $_REQUEST['provider'], $gBitUser ); - if( $auth === FALSE ) { + if( $auth === false ) { // social auth failed - throw new Exception( 'social auth failed' ); - } elseif( $auth === TRUE ) { + throw new \Exception( 'social auth failed' ); + } elseif( $auth === true ) { // account was connected to current object - throw new Exception( 'account was connected to current object' ); + throw new \Exception( 'account was connected to current object' ); } elseif( BitBase::verifyId( $auth ) ) { $redirectUrl = $gBitUser->getPostLoginUrl(); } elseif( is_object( $auth ) && is_a( $auth, 'Hybrid_User_Profile' ) ) { - $_SESSION['returnto'] = NULL; + $_SESSION['returnto'] = null; // an unconnected authProfile was found - $gBitSmarty->assignByRef( 'authProfile', $auth ); + $gBitSmarty->assign( 'authProfile', $auth ); $tpl = 'bitpackage:users/validate_auth.tpl'; if( !empty( $_REQUEST['auth_login'] ) ) { - $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : false; - $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : false; - $challenge = isset($_REQUEST['challenge']) ? $_REQUEST['challenge'] : false; - $response = isset($_REQUEST['response']) ? $_REQUEST['response'] : false; + $user = $_REQUEST['user'] ?? false; + $pass = $_REQUEST['pass'] ?? false; + $challenge = $_REQUEST['challenge'] ?? false; + $response = $_REQUEST['response'] ?? false; // if $referer is set, login() will return the user to whence he came $gBitUser->login( $user, $pass, $challenge, $response ); if( $gBitUser->isRegistered() ) { $gBitHybridAuthManager->storeUserProfile( $gBitUser->mUserId, $_REQUEST['provider'], $auth->identifier, $auth ); $redirectUrl = $gBitUser->getPostLoginUrl(); - $tpl = NULL; + $tpl = null; } else { - $redirectUrl = NULL; + $redirectUrl = null; } } else { if( $gBitUser->isRegistered() ) { $redirectUrl = $gBitUser->getPostLoginUrl(); - $tpl = NULL; + $tpl = null; } elseif( !empty( $_REQUEST['auth_new'] ) && !$gBitUser->isRegistered() ) { - $registerHash = $_REQUEST; - $registerHash['novalidation'] = TRUE; + $pRegisterHash = $_REQUEST; + $pRegisterHash['novalidation'] = true; foreach( array( 'displayName' => 'real_name', 'email'=>'email', 'emailVerified'=>'verified_email', 'gender'=>'customers_gender', 'firstName'=>'customers_firstname', 'lastName'=>'customers_lastname', 'phone'=>'customers_telephone' ) as $member=>$key ) { if( $auth->$member ) { - $registerHash[$key] = $auth->$member; + $pRegisterHash[$key] = $auth->$member; } } if( $auth->birthMonth && $auth->birthDay ) { - $registerHash['customers_dob'] = ($auth->birthYear ? $auth->birthYear : 1900).'-'.$auth->birthMonth.'-'.$auth->birthDay; + $pRegisterHash['customers_dob'] = ($auth->birthYear ? $auth->birthYear : 1900).'-'.$auth->birthMonth.'-'.$auth->birthDay; } $prefId = $gBitHybridAuthManager->getConfigName( $_REQUEST['provider'], 'id' ); $_SESSION['returnto'] = $_SERVER['SCRIPT_URI'].'?provider='.$_REQUEST['provider'].'&auth_login=1'; - include( USERS_PKG_INCLUDE_PATH.'register_inc.php' ); + include USERS_PKG_INCLUDE_PATH.'register_inc.php'; } } } - } catch( Exception $e ) { + } catch( \Exception $e ) { // Display the recived error, // to know more please refer to Exceptions handling section on the userguide switch( $e->getCode() ){ @@ -124,18 +130,18 @@ if( !empty( $_REQUEST['provider'] ) ) { break; } - $gBitSmarty->assignByRef( 'authError', $authError ); - $gBitSmarty->assignByRef( 'authExpection', $e ); + $gBitSmarty->assign( 'authError', $authError ); + $gBitSmarty->assign( 'authExpection', $e ); bit_error_log( $authError ); $tpl = 'bitpackage:users/validate_auth.tpl'; } } } else { - $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : false; - $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : false; - $challenge = isset($_REQUEST['challenge']) ? $_REQUEST['challenge'] : false; - $response = isset($_REQUEST['response']) ? $_REQUEST['response'] : false; + $user = $_REQUEST['user'] ?? false; + $pass = $_REQUEST['pass'] ?? false; + $challenge = $_REQUEST['challenge'] ?? false; + $response = $_REQUEST['response'] ?? false; // if $referer is set, login() will return the user to whence he came $redirectUrl = $gBitUser->login( $user, $pass, $challenge, $response ); @@ -150,6 +156,6 @@ if( !empty( $tpl ) ) { } if( !empty( $redirectUrl ) ) { - bit_redirect( $redirectUrl ); + KernelTools::bit_redirect( $redirectUrl ); } diff --git a/watches.php b/watches.php index 66a3616..61d5346 100644..100755 --- a/watches.php +++ b/watches.php @@ -15,7 +15,7 @@ include_once( '../kernel/includes/setup_inc.php' ); $user = $gBitUser->mUserId; if (!$user) { $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; } @@ -41,5 +41,5 @@ if (!isset($_REQUEST['event'])) $watches = $gBitUser->getWatches( $_REQUEST['event'] ); $gBitSmarty->assign('watches', $watches); -$gBitSystem->display( 'bitpackage:users/user_watches.tpl', NULL, array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:users/user_watches.tpl', null, array( 'display_mode' => 'display' )); ?> |
