2006-12-02 04:36:16 +00:00
< ? php
2009-07-23 06:55:39 +00:00
2006-12-02 04:36:16 +00:00
/*
2008-12-22 03:15:04 +00:00
* e107 website system
*
2012-11-05 13:06:48 +00:00
* Copyright ( C ) 2008 - 2012 e107 Inc ( e107 . org )
2008-12-22 03:15:04 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Administration Area - Users
*
2010-03-13 18:59:28 +00:00
* $URL $
* $Id $
2008-12-22 03:15:04 +00:00
*
2006-12-02 04:36:16 +00:00
*/
2009-07-23 06:55:39 +00:00
require_once ( '../class2.php' );
2011-05-11 11:56:42 +00:00
2011-05-11 22:25:02 +00:00
if ( ! getperms ( '4|U0|U1|U2|U3' ) )
2011-05-11 11:56:42 +00:00
{
2011-11-26 18:17:42 +00:00
header ( 'location:' . $e107 -> url -> create ( '/' ));
2008-12-22 03:15:04 +00:00
exit ;
2006-12-02 04:36:16 +00:00
}
2009-08-28 16:11:02 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE );
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_user.php' );
2010-05-14 18:45:51 +00:00
2009-07-23 06:55:39 +00:00
if ( varset ( $_POST [ 'useraction' ]))
2009-07-08 06:58:00 +00:00
{
2009-07-23 06:55:39 +00:00
foreach ( $_POST [ 'useraction' ] as $key => $val )
2009-07-08 06:58:00 +00:00
{
2009-07-23 06:55:39 +00:00
if ( $val )
2009-07-08 07:00:26 +00:00
{
2009-07-23 06:55:39 +00:00
$_POST [ 'useraction' ] = $val ;
$_POST [ 'userip' ] = $_POST [ 'userip' ][ $key ];
$_POST [ 'userid' ] = $key ;
2009-07-08 07:00:26 +00:00
break ;
}
2009-07-08 06:58:00 +00:00
}
}
2010-05-14 18:45:51 +00:00
if ( e_QUERY == 'logoutas' || varset ( $_POST [ 'useraction' ]) == 'logoutas' )
2007-08-06 19:35:17 +00:00
{
2010-05-14 18:45:51 +00:00
$asuser = e107 :: getSystemUser ( e107 :: getUser () -> getSessionDataAs (), false );
if ( e107 :: getUser () -> logoutAs ())
{ // TODO - lan
e107 :: getMessage () -> addSuccess ( 'Successfully logged out from ' . ( $asuser && $asuser -> getValue ( 'name' ) ? $asuser -> getValue ( 'name' ) : 'unknown' ) . ' account' , 'default' , true );
2010-05-17 14:13:50 +00:00
e107 :: getEvent () -> trigger ( 'logoutas' , array ( 'user_id' => $asuser , 'admin_id' => e107 :: getUser () -> getId ()));
2010-05-14 18:45:51 +00:00
}
header ( 'location:' . e_ADMIN_ABS . 'users.php' );
2006-12-02 04:36:16 +00:00
exit ;
2010-05-14 18:45:51 +00:00
}
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'usersettings' )
2007-08-06 19:35:17 +00:00
{
2011-11-26 18:17:42 +00:00
// __URLFIX__ - user name
header ( 'location:' . $e107 -> url -> create ( 'user/profile/edit' , 'id=' . ( int ) $_POST [ 'userid' ], 'full=1&encode=0' ));
2006-12-02 04:36:16 +00:00
exit ;
}
2007-08-06 19:35:17 +00:00
2006-12-02 04:36:16 +00:00
2009-01-18 01:39:20 +00:00
2009-07-23 06:55:39 +00:00
require_once ( e_HANDLER . 'message_handler.php' );
$emessage = & eMessage :: getInstance ();
if ( isset ( $_POST [ 'delete_rank' ]))
2009-01-18 01:39:20 +00:00
{
2009-07-23 06:55:39 +00:00
foreach ( $_POST [ 'delete_rank' ] as $k => $v )
2009-01-18 01:39:20 +00:00
{
deleteRank ( $k );
}
}
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'updateRanks' ]))
2009-01-11 04:13:01 +00:00
{
updateRanks ();
}
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'users' ;
2009-07-23 06:55:39 +00:00
require_once ( e_HANDLER . 'form_handler.php' );
require_once ( e_HANDLER . 'userclass_class.php' );
include_once ( e_HANDLER . 'user_extended_class.php' );
require_once ( e_HANDLER . 'validator_class.php' );
2012-05-23 13:59:12 +00:00
$user = new users ;
2012-06-04 09:08:54 +00:00
//require_once ('auth.php');
2012-05-23 13:59:12 +00:00
2009-11-22 14:10:09 +00:00
// require_once (e_HANDLER.'user_handler.php');
2009-07-23 06:55:39 +00:00
// $userMethods = new UserHandler;
2009-07-08 06:58:00 +00:00
// $colList = $userMethods->getNiceNames(TRUE);
2008-12-29 09:31:36 +00:00
$ue = new e107_user_extended ;
2010-10-26 07:41:20 +00:00
$userMethods = e107 :: getUserSession ();
2008-06-13 20:20:23 +00:00
$user_data = array ();
2009-07-08 06:58:00 +00:00
$frm = new e_form ;
2009-07-08 10:31:53 +00:00
$rs = new form ;
2008-12-22 03:15:04 +00:00
if ( e_QUERY )
2008-01-01 12:38:05 +00:00
{
2012-04-18 21:07:20 +00:00
// $tmp = explode('.',e_QUERY);
// $action = $tmp[0];
// $sub_action = varset($tmp[1],'');
// $id = varset($tmp[2],0);
// $from = varset($tmp[3],0);
// unset ($tmp);
$action = $_GET [ 'action' ];
$sub_action = varset ( $_GET [ 'sub' ], '' );
$id = varset ( $_GET [ 'id' ], 0 );
$from = varset ( $_GET [ 'frm' ], 0 );
2009-07-23 06:55:39 +00:00
unset ( $tmp );
2012-04-18 21:07:20 +00:00
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
$from = varset ( $from , 0 );
2012-04-18 21:07:20 +00:00
$amount = 20 ;
2011-05-11 11:56:42 +00:00
2006-12-02 04:36:16 +00:00
// ------- Check for Bounces --------------
2007-08-06 19:35:17 +00:00
$bounce_act = '' ;
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'check_bounces' ]))
$bounce_act = 'first_check' ;
if ( isset ( $_POST [ 'delnonbouncesubmit' ]))
$bounce_act = 'delnonbounce' ;
if ( isset ( $_POST [ 'clearemailbouncesubmit' ]))
$bounce_act = 'clearemailbounce' ;
if ( isset ( $_POST [ 'delcheckedsubmit' ]))
$bounce_act = 'delchecked' ;
if ( isset ( $_POST [ 'delallsubmit' ]))
$bounce_act = 'delall' ;
2007-08-06 19:35:17 +00:00
if ( $bounce_act )
{
2009-07-23 06:55:39 +00:00
$user -> check_bounces ( $bounce_act , implode ( ',' , $_POST [ 'delete_email' ]));
require_once ( " footer.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
2007-08-06 19:35:17 +00:00
// ------- Resend Email. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'resend_mail' ]))
2007-08-06 19:35:17 +00:00
{
$user -> resend ( $_POST [ 'resend_id' ], $_POST [ 'resend_key' ], $_POST [ 'resend_name' ], $_POST [ 'resend_email' ]);
2006-12-02 04:36:16 +00:00
}
2007-08-06 19:35:17 +00:00
2006-12-02 04:36:16 +00:00
// ------- Resend Email. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'resend_to_all' ]))
2007-08-06 19:35:17 +00:00
{
2006-12-02 04:36:16 +00:00
$user -> resend_to_all ();
}
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'execute_batch' ]))
2009-07-22 17:04:59 +00:00
{
$user -> process_batch ();
}
2006-12-02 04:36:16 +00:00
2009-07-23 06:55:39 +00:00
2006-12-02 04:36:16 +00:00
// ------- Test Email. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'test_mail' ]))
2007-08-06 19:35:17 +00:00
{
2009-07-23 06:55:39 +00:00
require_once ( e_HANDLER . 'mail_validation_class.php' );
2010-10-28 20:17:40 +00:00
list ( $adminuser , $adminhost ) = explode ( '@' , SITEADMINEMAIL , 2 );
2006-12-02 04:36:16 +00:00
$validator = new email_validation_class ;
2009-07-23 06:55:39 +00:00
$validator -> localuser = $adminuser ;
$validator -> localhost = $adminhost ;
$validator -> timeout = 5 ;
$validator -> debug = 1 ;
$validator -> html_debug = 1 ;
2006-12-02 04:36:16 +00:00
$text = " <div style=' " . ADMIN_WIDTH . " '> " ;
ob_start ();
$email_status = $validator -> ValidateEmailBox ( $_POST [ 'test_email' ]);
$text .= ob_get_contents ();
ob_end_clean ();
$text .= " </div> " ;
$caption = $_POST [ 'test_email' ] . " - " ;
2009-07-23 06:55:39 +00:00
$caption .= ( $email_status == 1 ) ? " Valid " : " Invalid " ;
if ( $email_status == 1 )
{
2006-12-02 04:36:16 +00:00
$text .= " <form method='post' action=' " . e_SELF . $qry . " '>
2008-12-22 03:15:04 +00:00
< div style = 'text-align:left' >
< input type = 'hidden' name = 'useraction' value = 'resend' /> \n
< input type = 'hidden' name = 'userid' value = '".$_POST[' test_id ']."' /> \n
< input class = 'button' type = 'submit' name = 'resend_' value = '".USRLAN_112."' /> \n </ div ></ form > \n " ;
$text .= " <div> " ;
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( $caption , $text );
unset ( $id , $action , $sub_cation );
2006-12-02 04:36:16 +00:00
}
// ------- Update Options. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'update_options' ]))
2007-08-06 19:35:17 +00:00
{
2012-06-15 04:15:46 +00:00
$mes = e107 :: getMessage ();
2008-12-21 11:07:58 +00:00
$temp = array ();
$temp [ 'avatar_upload' ] = ( FILE_UPLOADS ? $_POST [ 'avatar_upload' ] : 0 );
$temp [ 'im_width' ] = $_POST [ 'im_width' ];
$temp [ 'im_height' ] = $_POST [ 'im_height' ];
$temp [ 'photo_upload' ] = ( FILE_UPLOADS ? $_POST [ 'photo_upload' ] : 0 );
$temp [ 'del_unv' ] = $_POST [ 'del_unv' ];
$temp [ 'profile_rate' ] = $_POST [ 'profile_rate' ];
$temp [ 'profile_comments' ] = $_POST [ 'profile_comments' ];
$temp [ 'track_online' ] = $_POST [ 'track_online' ];
$temp [ 'force_userupdate' ] = $_POST [ 'force_userupdate' ];
$temp [ 'memberlist_access' ] = $_POST [ 'memberlist_access' ];
$temp [ 'user_new_period' ] = $_POST [ 'user_new_period' ];
2012-06-19 09:08:41 +00:00
$temp [ 'signature_access' ] = $_POST [ 'signature_access' ];
2009-07-23 06:55:39 +00:00
if ( $admin_log -> logArrayDiffs ( $temp , $pref , 'USET_03' ))
2008-12-21 11:07:58 +00:00
{
2009-07-23 06:55:39 +00:00
save_prefs ();
// Only save if changes
2012-06-04 09:08:54 +00:00
$mes -> addSuccess ( USRLAN_1 );
//$user->show_message(USRLAN_1);
2008-12-21 11:07:58 +00:00
}
else
{
2012-06-04 09:08:54 +00:00
$mes -> addError ( USRLAN_193 );
// $user->show_message(USRLAN_193);
2008-12-21 11:07:58 +00:00
}
2006-12-02 04:36:16 +00:00
}
// ------- Prune Users. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'prune' ]))
2007-12-09 16:42:23 +00:00
{
2008-12-22 03:15:04 +00:00
$e107cache -> clear ( 'online_menu_member_total' );
$e107cache -> clear ( 'online_menu_member_newest' );
$text = USRLAN_56 . ' ' ;
$bantype = $_POST [ 'prune_type' ];
2009-07-23 06:55:39 +00:00
if ( $bantype == 30 )
// older than 30 days.
2009-06-24 20:10:34 +00:00
{
2009-07-23 06:55:39 +00:00
$bantype = 2 ;
2009-06-24 20:10:34 +00:00
$ins = " AND user_join < " . strtotime ( " -30 days " );
}
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Select ( " user " , " user_id, user_name " , " user_ban= { $bantype } " . $ins ))
2006-12-02 04:36:16 +00:00
{
2008-12-22 03:15:04 +00:00
$uList = $sql -> db_getList ();
2009-07-23 06:55:39 +00:00
foreach ( $uList as $u )
2008-12-22 03:15:04 +00:00
{
$text .= $u [ 'user_name' ] . " " ;
2009-07-23 06:55:39 +00:00
$sql -> db_Delete ( " user " , " user_id=' { $u [ 'user_id' ] } ' " );
$sql -> db_Delete ( " user_extended " , " user_extended_id=' { $u [ 'user_id' ] } ' " );
2008-12-22 03:15:04 +00:00
}
$admin_log -> log_event ( 'USET_04' , str_replace ( array ( '--COUNT--' , '--TYPE--' ), array ( count ( $uList ), $bantype ), USRLAN_160 ), E_LOG_INFORMATIVE );
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( USRLAN_57 , " <div style='text-align:center'><b> " . $text . " </b></div> " );
unset ( $text );
2006-12-02 04:36:16 +00:00
}
2009-11-12 05:11:47 +00:00
2006-12-02 04:36:16 +00:00
// ------- Quick Add User --------------
2012-06-04 09:08:54 +00:00
function addUser ()
2008-01-01 12:38:05 +00:00
{
2012-06-04 09:08:54 +00:00
$e107cache = e107 :: getCache ();
$userMethods = e107 :: getUserSession ();
$mes = e107 :: getMessage ();
$sql = e107 :: getDb ();
$e_event = e107 :: getEvent ();
global $admin_log ;
2008-12-22 03:15:04 +00:00
if ( ! $_POST [ 'ac' ] == md5 ( ADMINPWCHANGE ))
2008-01-01 12:38:05 +00:00
{
2008-12-22 03:15:04 +00:00
exit ;
2006-12-02 04:36:16 +00:00
}
2008-12-21 11:07:58 +00:00
$e107cache -> clear ( 'online_menu_member_total' );
$e107cache -> clear ( 'online_menu_member_newest' );
2009-07-23 06:55:39 +00:00
$error = false ;
if ( isset ( $_POST [ 'generateloginname' ]))
2008-06-13 20:20:23 +00:00
{
2008-12-21 11:07:58 +00:00
$_POST [ 'loginname' ] = $userMethods -> generateUserLogin ( $pref [ 'predefinedLoginName' ]);
2008-06-13 20:20:23 +00:00
}
2012-05-23 11:38:49 +00:00
/*
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'generatepassword' ]))
2008-06-13 20:20:23 +00:00
{
2009-07-23 06:55:39 +00:00
$_POST [ 'password1' ] = $userMethods -> generateRandomString ( '**********' );
// 10-char password should be enough
2008-12-21 11:07:58 +00:00
$_POST [ 'password2' ] = $_POST [ 'password1' ];
2008-06-13 20:20:23 +00:00
}
2012-05-23 11:38:49 +00:00
*/
$_POST [ 'password2' ] = $_POST [ 'password1' ];
2008-12-21 11:07:58 +00:00
// Now validate everything
2009-07-23 06:55:39 +00:00
$allData = validatorClass :: validateFields ( $_POST , $userMethods -> userVettingInfo , true );
// Do basic validation
validatorClass :: checkMandatory ( 'user_name,user_loginname' , $allData );
// Check for missing fields (email done in userValidation() )
validatorClass :: dbValidateArray ( $allData , $userMethods -> userVettingInfo , 'user' , 0 );
// Do basic DB-related checks
$userMethods -> userValidation ( $allData );
// Do user-specific DB checks
if ( ! isset ( $allData [ 'errors' ][ 'user_password' ]))
{
// No errors in password - keep it outside the main data array
2009-01-11 21:06:52 +00:00
$savePassword = $allData [ 'data' ][ 'user_password' ];
2009-07-23 06:55:39 +00:00
unset ( $allData [ 'data' ][ 'user_password' ]);
// Delete the password value in the output array
2008-01-01 12:38:05 +00:00
}
2009-07-23 06:55:39 +00:00
unset ( $_POST [ 'password1' ]);
// Restrict the scope of this
unset ( $_POST [ 'password2' ]);
if ( ! check_class ( $pref [ 'displayname_class' ], $allData [ 'data' ][ 'user_class' ]))
2008-01-01 12:38:05 +00:00
{
2009-01-11 21:06:52 +00:00
if ( $allData [ 'data' ][ 'user_name' ] != $allData [ 'data' ][ 'user_loginname' ])
2008-12-21 11:07:58 +00:00
{
$allData [ 'errors' ][ 'user_name' ] = ERR_FIELDS_DIFFERENT ;
}
2008-01-01 12:38:05 +00:00
}
2008-12-21 11:07:58 +00:00
if ( count ( $allData [ 'errors' ]))
2008-01-01 12:38:05 +00:00
{
2012-06-04 09:08:54 +00:00
// require_once (e_HANDLER."message_handler.php");
2009-07-23 06:55:39 +00:00
$temp = validatorClass :: makeErrorList ( $allData , 'USER_ERR_' , '%n - %x - %t: %v' , '<br />' , $userMethods -> userVettingInfo );
2012-06-04 09:08:54 +00:00
// message_handler('P_ALERT',$temp);
$mes -> addError ( $temp );
2009-07-23 06:55:39 +00:00
$error = true ;
2008-01-01 12:38:05 +00:00
}
2008-06-13 20:20:23 +00:00
// Always save some of the entered data - then we can redisplay on error
2009-07-23 06:55:39 +00:00
$user_data = & $allData [ 'data' ];
2008-12-22 03:15:04 +00:00
if ( ! $error )
2008-06-13 20:20:23 +00:00
{
2010-03-13 18:59:28 +00:00
2009-11-12 01:53:16 +00:00
if ( varset ( $_POST [ 'perms' ]))
{
$allData [ 'data' ][ 'user_admin' ] = 1 ;
$allData [ 'data' ][ 'user_perms' ] = implode ( '.' , $_POST [ 'perms' ]);
}
2010-03-13 18:59:28 +00:00
2008-12-21 11:07:58 +00:00
$message = '' ;
2010-09-05 12:12:46 +00:00
$user_data [ 'user_password' ] = $userMethods -> HashPassword ( $savePassword , $user_data [ 'user_login' ]);
2008-12-21 11:07:58 +00:00
$user_data [ 'user_join' ] = time ();
2011-05-04 09:22:09 +00:00
2008-12-21 11:07:58 +00:00
if ( $userMethods -> needEmailPassword ())
2009-07-23 06:55:39 +00:00
{
// Save separate password encryption for use with email address
$user_data [ 'user_prefs' ] = serialize ( array ( 'email_password' => $userMethods -> HashPassword ( $savePassword , $user_data [ 'user_email' ])));
2008-12-29 09:31:36 +00:00
}
2011-05-04 09:22:09 +00:00
2009-07-23 06:55:39 +00:00
$userMethods -> userClassUpdate ( $allData [ 'data' ], 'userall' );
// Set any initial classes
2008-12-21 11:07:58 +00:00
$userMethods -> addNonDefaulted ( $user_data );
2009-07-23 06:55:39 +00:00
validatorClass :: addFieldTypes ( $userMethods -> userVettingInfo , $allData );
2009-06-12 20:41:35 +00:00
//FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later)
2009-04-27 10:42:14 +00:00
$allData [ 'data' ][ 'user_realm' ] = '' ;
2011-05-04 09:22:09 +00:00
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Insert ( 'user' , $allData ))
2008-12-21 11:07:58 +00:00
{
2011-05-04 09:22:09 +00:00
// Add to admin log
2008-12-21 11:07:58 +00:00
$admin_log -> log_event ( 'USET_02' , " UName: { $user_data [ 'user_name' ] } ; Email: { $user_data [ 'user_email' ] } " , E_LOG_INFORMATIVE );
2011-05-04 09:22:09 +00:00
2008-12-21 11:07:58 +00:00
// Add to user audit trail
2009-07-23 06:55:39 +00:00
$admin_log -> user_audit ( USER_AUDIT_ADD_ADMIN , $user_data , 0 , $user_data [ 'user_loginname' ]);
$e_event -> trigger ( 'userfull' , $user_data );
2011-05-04 09:22:09 +00:00
2009-07-23 06:55:39 +00:00
// send everything available for user data - bit sparse compared with user-generated signup
if ( isset ( $_POST [ 'sendconfemail' ]))
{
// Send confirmation email to user
2011-05-04 09:22:09 +00:00
require_once ( e_HANDLER . 'mail.php' );
include_once ( e107 :: coreTemplatePath ( 'email' , 'front' )); //correct way to load a core template.
if ( ! isset ( $QUICKADDUSER_TEMPLATE ))
{
$QUICKADDUSER_TEMPLATE = USRLAN_185 . USRLAN_186 ;
}
2011-05-18 08:58:35 +00:00
$var_search = array (
'{SITEURL}' ,
'{LOGIN}' ,
'{USERNAME}' ,
'{PASSWORD}' ,
'{EMAIL}'
);
$var_replace = array (
SITEURL ,
$user_data [ 'user_name' ],
$user_data [ 'user_login' ],
$savePassword ,
$user_data [ 'user_email' ]
);
$e_message = str_replace ( $var_search , $var_replace , $QUICKADDUSER_TEMPLATE );
2011-05-04 09:22:09 +00:00
2008-12-21 11:07:58 +00:00
if ( sendemail ( $user_data [ 'user_email' ], USRLAN_187 . SITEURL , $e_message , $user_data [ 'user_login' ], '' , '' ))
{
$message = USRLAN_188 . '<br /><br />' ;
}
else
{
$message = USRLAN_189 . '<br /><br />' ;
}
}
2011-05-04 09:22:09 +00:00
2009-07-23 06:55:39 +00:00
$message .= str_replace ( '--NAME--' , $user_data [ 'user_name' ], USRLAN_174 );
2011-05-04 09:22:09 +00:00
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'generateloginname' ]))
2011-05-04 09:22:09 +00:00
{
$message .= '<br /><br />' . USRLAN_173 . ': ' . $user_data [ 'user_login' ];
}
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'generatepassword' ]))
2011-05-04 09:22:09 +00:00
{
$message .= '<br /><br />' . USRLAN_172 . ': ' . $savePassword ;
}
2009-07-23 06:55:39 +00:00
unset ( $user_data );
// Don't recycle the data once the user's been accepted without error
2008-01-01 12:38:05 +00:00
}
2012-06-04 09:08:54 +00:00
$mes -> addSuccess ( $message );
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
else
2011-05-04 09:22:09 +00:00
{
2012-06-04 09:08:54 +00:00
2011-05-04 09:22:09 +00:00
}
2012-06-04 09:08:54 +00:00
// $mes = e107::getMessage();
2011-05-04 09:22:09 +00:00
2006-12-02 04:36:16 +00:00
}
2007-08-06 19:35:17 +00:00
// ------- Bounce --> Unverified --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " reqverify " )
2007-08-06 19:35:17 +00:00
{
2009-07-23 06:55:39 +00:00
$sql -> db_Select ( " user " , " * " , " user_id=' " . $_POST [ 'userid' ] . " ' " );
2007-08-06 19:35:17 +00:00
$row = $sql -> db_Fetch ();
extract ( $row );
2009-07-23 06:55:39 +00:00
$sql -> db_Update ( " user " , " user_ban='2' WHERE user_id=' " . $_POST [ 'userid' ] . " ' " );
2007-08-06 19:35:17 +00:00
$user -> show_message ( " User now has to verify " );
$action = " main " ;
2009-07-23 06:55:39 +00:00
if ( ! $sub_action )
2006-12-02 04:36:16 +00:00
{
2009-07-23 06:55:39 +00:00
$sub_action = " user_id " ;
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
}
2012-06-04 09:08:54 +00:00
/*
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " ban " )
{
$user -> user_ban ( $_POST [ 'userid' ]);
}
2007-08-06 19:35:17 +00:00
2006-12-02 04:36:16 +00:00
// ------- Unban User --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " unban " )
2008-01-01 12:38:05 +00:00
{
2009-07-22 17:04:59 +00:00
$user -> user_unban ( $_POST [ 'userid' ]);
}
2009-08-05 16:02:09 +00:00
// User Info.
if (( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " userinfo " ) || $_GET [ 'userinfo' ])
{
$ip = ( $_POST [ 'userip' ]) ? $_POST [ 'userip' ] : $_GET [ 'userinfo' ];
$user -> user_info ( $ip );
}
2009-07-22 17:04:59 +00:00
// ------- Delete User --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'deluser' )
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
$user -> user_delete ( $_POST [ 'userid' ], true );
}
// ---- Update User's class --------------------
if ( isset ( $_POST [ 'updateclass' ]))
{
2009-09-22 19:43:34 +00:00
$user -> user_userclass ( $_POST [ 'userid' ], $_POST [ 'userclass' ], 'clear' );
2009-07-23 06:55:39 +00:00
}
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'userclass' )
{
// header('location:'.e_ADMIN.'userclass.php?'.$e107->tp->toDB($_POST['userid'].'.'.e_QUERY));
// exit;
$user -> show_userclass ( $_POST [ 'userid' ]);
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
*/
2010-05-14 18:45:51 +00:00
// ---- Login as another user --------------------
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'loginas' )
{
if ( e107 :: getUser () -> getSessionDataAs ())
{
e107 :: getMessage () -> addWarning ( USRLAN_AS_3 );
}
elseif ( e107 :: getUser () -> loginAs ( $_POST [ 'userid' ]))
{ // TODO - lan
e107 :: getMessage () -> addSuccess ( 'Successfully logged in as ' . e107 :: getSystemUser ( $_POST [ 'userid' ]) -> getValue ( 'name' ) . ' <a href="' . e_ADMIN_ABS . 'users.php?logoutas">[logout]</a>' )
-> addSuccess ( 'Please, <a href="' . SITEURL . '" rel="external">Leave Admin</a> to browse the system as this user. Use "Logout" option in Administration to end front-end session' );
2010-05-17 14:13:50 +00:00
e107 :: getEvent () -> trigger ( 'loginas' , array ( 'user_id' => $_POST [ 'userid' ], 'admin_id' => e107 :: getUser () -> getId ()));
2010-05-14 18:45:51 +00:00
}
}
2006-12-02 04:36:16 +00:00
// ------- Resend Email Confirmation. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'resend' )
2008-01-01 12:38:05 +00:00
{
2006-12-02 04:36:16 +00:00
$qry = ( e_QUERY ) ? " ? " . e_QUERY : " " ;
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Select ( " user " , " * " , " user_id=' " . $_POST [ 'userid' ] . " ' " ))
{
2006-12-02 04:36:16 +00:00
$resend = $sql -> db_Fetch ();
$text .= " <form method='post' action=' " . e_SELF . $qry . " '><div style='text-align:center'> \n " ;
$text .= USRLAN_116 . " <b> " . $resend [ 'user_name' ] . " </b><br /><br />
2008-12-22 03:15:04 +00:00
< input type = 'hidden' name = 'resend_id' value = '".$_POST[' userid ']."' /> \n
< input type = 'hidden' name = 'resend_name' value = '".$resend[' user_name ']."' /> \n
< input type = 'hidden' name = 'resend_key' value = '".$resend[' user_sess ']."' /> \n
< input type = 'hidden' name = 'resend_email' value = '".$resend[' user_email ']."' /> \n
< input class = 'button' type = 'submit' name = 'resend_mail' value = '".USRLAN_112."' /> \n </ div ></ form > \n " ;
2006-12-02 04:36:16 +00:00
$caption = USRLAN_112 ;
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( $caption , $text );
require_once ( " footer.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
}
// ------- TEst Email confirmation. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == 'test' )
2008-01-01 12:38:05 +00:00
{
2006-12-02 04:36:16 +00:00
$qry = ( e_QUERY ) ? " ? " . e_QUERY : " " ;
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Select ( " user " , " * " , " user_id=' " . $_POST [ 'userid' ] . " ' " ))
{
2006-12-02 04:36:16 +00:00
$test = $sql -> db_Fetch ();
$text .= " <form method='post' action=' " . e_SELF . $qry . " '><div style='text-align:center'> \n " ;
$text .= USRLAN_117 . " <br /><b> " . $test [ 'user_email' ] . " </b><br /><br />
2008-12-22 03:15:04 +00:00
< input type = 'hidden' name = 'test_email' value = '".$test[' user_email ']."' /> \n
< input type = 'hidden' name = 'test_id' value = '".$_POST[' userid ']."' /> \n
< input class = 'button' type = 'submit' name = 'test_mail' value = '".USRLAN_118."' /> \n </ div ></ form > \n " ;
2006-12-02 04:36:16 +00:00
$caption = USRLAN_118 ;
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( $caption , $text );
require_once ( " footer.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
}
2009-11-12 05:11:47 +00:00
$prm = e107 :: getUserPerms ();
2008-01-01 12:38:05 +00:00
// ------- Make Admin --------------
2012-06-04 09:08:54 +00:00
/*
2009-11-12 05:11:47 +00:00
if (( varset ( $_POST [ 'useraction' ]) == " admin " || varset ( $_POST [ 'useraction' ]) == " adminperms " ) && getperms ( '3' ))
2008-01-01 12:38:05 +00:00
{
2009-11-12 05:11:47 +00:00
$sql -> db_Select ( " user " , " user_id, user_name, user_perms " , " user_id=' " . $_POST [ 'userid' ] . " ' " );
2006-12-02 04:36:16 +00:00
$row = $sql -> db_Fetch ();
2010-03-13 18:59:28 +00:00
2009-11-12 05:11:47 +00:00
if ( varset ( $_POST [ 'useraction' ]) == " admin " )
{
$sql -> db_Update ( " user " , " user_admin='1' WHERE user_id=' " . $_POST [ 'userid' ] . " ' " );
}
2010-03-13 18:59:28 +00:00
2008-01-16 22:18:27 +00:00
$admin_log -> log_event ( 'USET_08' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $row [ 'user_id' ], $row [ 'user_name' ]), USRLAN_164 ), E_LOG_INFORMATIVE );
2007-03-25 02:01:06 +00:00
$user -> show_message ( $row [ 'user_name' ] . " " . USRLAN_3 . " <a href=' " . e_ADMIN . " administrator.php?edit. { $row [ 'user_id' ] } '> " . USRLAN_4 . " </a> " );
2006-12-02 04:36:16 +00:00
$action = " main " ;
2009-07-23 06:55:39 +00:00
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
if ( ! $id )
{
$id = " DESC " ;
}
2010-03-13 18:59:28 +00:00
2009-11-12 05:11:47 +00:00
$prm -> edit_administrator ( $row );
require_once ( " footer.php " );
exit ;
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
*/
2010-03-13 18:59:28 +00:00
if ( varset ( $_POST [ 'update_admin' ])) // Update admin Perms.
{
$prm -> updatePerms ( $_POST [ 'a_id' ], $_POST [ 'perms' ]);
2009-11-12 05:11:47 +00:00
}
2006-12-02 04:36:16 +00:00
// ------- Remove Admin --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " unadmin " && getperms ( '3' ))
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
$sql -> db_Select ( " user " , " * " , " user_id=' " . $_POST [ 'userid' ] . " ' " );
2008-12-22 03:15:04 +00:00
$row = $sql -> db_Fetch ();
extract ( $row );
if ( $user_perms == " 0 " )
{
$user -> show_message ( USRLAN_5 );
}
else
{
2009-07-23 06:55:39 +00:00
$sql -> db_Update ( " user " , " user_admin='0', user_perms='' WHERE user_id=' " . $_POST [ 'userid' ] . " ' " );
2008-12-22 03:15:04 +00:00
$admin_log -> log_event ( 'USET_09' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $row [ 'user_id' ], $row [ 'user_name' ]), USRLAN_165 ), E_LOG_INFORMATIVE );
$user -> show_message ( $user_name . " " . USRLAN_6 );
$action = " main " ;
2009-07-23 06:55:39 +00:00
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
if ( ! $id )
{
$id = " DESC " ;
}
2008-12-22 03:15:04 +00:00
}
2006-12-02 04:36:16 +00:00
}
// ------- Approve User. --------------
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'useraction' ]) && $_POST [ 'useraction' ] == " verify " )
2006-12-02 04:36:16 +00:00
{
2009-07-22 17:04:59 +00:00
$user -> user_activate ( $_POST [ 'userid' ]);
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
if ( isset ( $action ) && $action == " uset " )
2008-01-01 12:38:05 +00:00
{
2008-12-22 03:15:04 +00:00
$user -> show_message ( USRLAN_87 );
$action = " main " ;
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
if ( isset ( $action ) && $action == " cu " )
2008-01-01 12:38:05 +00:00
{
2008-12-22 03:15:04 +00:00
$user -> show_message ( USRLAN_88 );
$action = " main " ;
// $sub_action = "user_id";
2006-12-02 04:36:16 +00:00
}
/*
echo " action= " . $action . " <br /> " ;
echo " subaction= " . $sub_action . " <br /> " ;
echo " id= " . $id . " <br /> " ;
echo " from= " . $from . " <br /> " ;
echo " amount= " . $amount . " <br /> " ;
*/
2011-05-11 11:56:42 +00:00
// $unverified = $sql->db_Count("user","(*)","WHERE user_ban = 2");
2012-06-04 09:08:54 +00:00
// ----------------------------- START NEW --------------------------
class users_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'users_admin_ui' ,
'path' => null ,
'ui' => 'users_admin_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
'main/list' => array ( 'caption' => 'Manage' , 'perm' => '0' ),
'main/add' => array ( 'caption' => LAN_USER_QUICKADD , 'perm' => '4|U0|U1' ),
'main/prefs' => array ( 'caption' => LAN_OPTIONS , 'perm' => '4|U2' ),
'main/ranks' => array ( 'caption' => LAN_USER_RANKS , 'perm' => '4|U3' )
);
/*
$var [ 'prune' ][ 'text' ] = LAN_USER_PRUNE ;
$var [ 'prune' ][ 'link' ] = e_ADMIN . 'users.php?action=prune' ; // Will be moved to "Schedule tasks"
$var [ 'prune' ][ 'perm' ] = '4' ;
*/
protected $adminMenuAliases = array (
'main/edit' => 'main/list'
);
protected $menuTitle = 'users' ;
}
class users_admin_ui extends e_admin_ui
{
protected $pluginTitle = LAN_USER ;
protected $pluginName = 'core' ;
protected $table = " user " ;
// protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #users"; // without any Order or Limit.
protected $listQry = " SELECT u.*,ue.* from #user AS u left join #user_extended AS ue ON u.user_id = ue.user_extended_id " ; // without any Order or Limit.
//protected $editQry = "SELECT * FROM #users WHERE comment_id = {ID}";
protected $pid = " user_id " ;
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $listOrder = 'user_id DESC' ;
//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'user_id' => array ( 'title' => 'Id' , 'type' => 'integer' , 'width' => '5%' , 'forced' => true ),
// 'user_status' => array('title' => LAN_STATUS, 'type' => 'method', 'alias'=>'user_status', 'width' => 'auto','forced' => true, 'nosort'=>TRUE),
'user_ban' => array ( 'title' => LAN_STATUS , 'type' => 'method' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'thclass' => 'center' , 'class' => 'center' ),
'user_name' => array ( 'title' => LAN_USER_01 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left first' ), // Display name
'user_loginname' => array ( 'title' => LAN_USER_02 , 'type' => 'text' , 'width' => 'auto' ), // User name
'user_login' => array ( 'title' => LAN_USER_03 , 'type' => 'text' , 'width' => 'auto' ), // Real name (no real vetting)
'user_customtitle' => array ( 'title' => LAN_USER_04 , 'type' => 'text' , 'width' => 'auto' ), // No real vetting
2012-07-18 03:47:28 +00:00
'user_password' => array ( 'title' => LAN_USER_05 , 'type' => 'password' , 'width' => 'auto' ), //TODO add md5 option to form handler?
2012-07-12 23:26:03 +00:00
'user_sess' => array ( 'title' => 'Session' , 'type' => 'text' , 'width' => 'auto' ), // Photo
2012-06-04 09:08:54 +00:00
'user_image' => array ( 'title' => LAN_USER_07 , 'type' => 'text' , 'width' => 'auto' ), // Avatar
'user_email' => array ( 'title' => LAN_USER_08 , 'type' => 'text' , 'width' => 'auto' ),
'user_hideemail' => array ( 'title' => LAN_USER_10 , 'type' => 'boolean' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'filter' => true , 'batch' => true , 'readParms' => 'trueonly=1' ),
2012-07-12 23:26:03 +00:00
'user_xup' => array ( 'title' => 'Xup' , 'type' => 'text' , 'width' => 'auto' ),
2012-08-02 02:11:22 +00:00
'user_class' => array ( 'title' => LAN_USER_12 , 'type' => 'method' , 'data' => 'comma' , 'filter' => true , 'batch' => true ),
2012-07-12 23:26:03 +00:00
'user_join' => array ( 'title' => LAN_USER_14 , 'type' => 'datestamp' , 'width' => 'auto' , 'writeParms' => 'readonly=1' ),
2012-06-04 09:08:54 +00:00
'user_lastvisit' => array ( 'title' => LAN_USER_15 , 'type' => 'datestamp' , 'width' => 'auto' ),
'user_currentvisit' => array ( 'title' => LAN_USER_16 , 'type' => 'datestamp' , 'width' => 'auto' ),
2012-07-12 23:26:03 +00:00
'user_comments' => array ( 'title' => LAN_USER_17 , 'type' => 'int' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
2012-06-04 09:08:54 +00:00
'user_lastpost' => array ( 'title' => 'Last Post' , 'type' => 'datestamp' , 'width' => 'auto' ),
'user_ip' => array ( 'title' => LAN_USER_18 , 'type' => 'ip' , 'width' => 'auto' ),
// 'user_prefs' => array('title' => LAN_USER_20, 'type' => 'text', 'width' => 'auto'),
2012-07-12 23:26:03 +00:00
'user_visits' => array ( 'title' => LAN_USER_21 , 'type' => 'int' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
2012-06-04 09:08:54 +00:00
'user_admin' => array ( 'title' => LAN_USER_22 , 'type' => 'boolean' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'filter' => true , 'batch' => true , 'readParms' => 'trueonly=1' ),
'user_perms' => array ( 'title' => LAN_USER_23 , 'type' => 'method' , 'width' => 'auto' ),
'user_pwchange' => array ( 'title' => LAN_USER_24 , 'type' => 'datestamp' , 'width' => 'auto' ),
);
protected $fieldpref = array ( 'user_ban' , 'user_name' , 'user_loginname' , 'user_login' , 'user_email' , 'user_class' , 'user_ban' , 'user_admin' );
protected $prefs = array (
// 'anon_post' => array('title'=>PRFLAN_32, 'type'=>'boolean'),
);
function init ()
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
if ( $sql -> db_Select ( 'user_extended_struct' , 'user_extended_struct_name,user_extended_struct_text' , " user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' ORDER BY user_extended_struct_parent ASC " ))
{
while ( $row = $sql -> db_Fetch ())
{
$field = " user_ " . $row [ 'user_extended_struct_name' ];
$title = ucfirst ( str_replace ( " user_ " , " " , $field ));
$label = $tp -> toHtml ( $row [ 'user_extended_struct_text' ], false , 'defs' );
2012-07-12 23:26:03 +00:00
$this -> fields [ $field ] = array ( 'title' => $label , 'width' => 'auto' , 'type' => 'text' , 'noedit' => true );
2012-06-04 09:08:54 +00:00
}
}
$this -> fields [ 'user_signature' ] = array ( 'title' => LAN_USER_09 , 'type' => 'bbarea' , 'width' => 'auto' );
2012-11-05 13:06:48 +00:00
$this -> fields [ 'options' ] = array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' );
2012-06-04 09:08:54 +00:00
if ( ! getperms ( '4|U0' )) // Quick Add User Access Only.
{
unset ( $this -> fields [ 'checkboxes' ]);
unset ( $this -> fields [ 'options' ]);
}
if (( varset ( $_POST [ 'useraction' ]) == " admin " || varset ( $_POST [ 'useraction' ]) == " adminperms " ) && getperms ( '3' ))
{
$this -> adminPerms ();
}
if ( isset ( $_POST [ 'adduser' ]))
{
addUser ();
}
}
function ranksPage ()
{
//echo "hello";
showRanks ();
}
function adminPerms () // ------- Make Admin -------------- // - maybe no longer needed - on 'edit' page now.
{
$sql = e107 :: getDb ();
global $admin_log , $user ;
$sql -> db_Select ( " user " , " user_id, user_name, user_perms " , " user_id=' " . $_POST [ 'userid' ] . " ' " );
$row = $sql -> db_Fetch ();
if ( varset ( $_POST [ 'useraction' ]) == " admin " )
{
$sql -> db_Update ( " user " , " user_admin='1' WHERE user_id=' " . $_POST [ 'userid' ] . " ' " );
}
$admin_log -> log_event ( 'USET_08' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $row [ 'user_id' ], $row [ 'user_name' ]), USRLAN_164 ), E_LOG_INFORMATIVE );
// $user->show_message($row['user_name']." ".USRLAN_3." <a href='".e_ADMIN."administrator.php?edit.{$row['user_id']}'>".USRLAN_4."</a>");
$action = " main " ;
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
if ( ! $id )
{
$id = " DESC " ;
}
$prm = e107 :: getUserPerms ();
$prm -> edit_administrator ( $row );
}
function addPage ()
{
global $rs , $pref , $e_userclass ;
$prm = e107 :: getUserPerms ();
$list = $prm -> getPermList ();
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
if ( ! is_object ( $e_userclass )) $e_userclass = new user_class ;
$text = " <div> " . $rs -> form_open ( " post " , e_SELF . ( e_QUERY ? '?' . e_QUERY : '' ), " adduserform " ) . "
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-06-04 09:08:54 +00:00
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > " .USRLAN_61. " </ td >
< td >
" . $rs->form_text ('username',40,varset( $user_data['user_name'] , " " ),varset( $pref['displayname_maxlength'] ,15)). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_128. " </ td >
< td >
" . $rs->form_text ('loginname',40,varset( $user_data['user_loginname'] , " " ),varset( $pref['loginname_maxlength'] ,30)). " & nbsp ; & nbsp ;
" . $frm->checkbox_label (USRLAN_170,'generateloginname', 1,varset( $pref['predefinedLoginName'] ,false)). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_129. " </ td >
< td >
" . $rs->form_text ( " realname " ,40,varset( $user_data['user_login'] , " " ),30). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_62. " </ td >
< td > " . $frm->password ('password','',20,array('size'=>40,'class'=>'tbox e-password-admin')). " </ td >
</ tr > " ;
$text .= "
< tr >
< td > " .USRLAN_64. " </ td >
< td >
" . $rs->form_text ( " email " ,60,varset( $user_data['user_email'] , " " ),100). "
</ td >
</ tr >
< tr style = 'vertical-align:top' >
< td > Require Confirmation </ td >
< td class = 'center' > " . $frm->checkbox_label (USRLAN_181,'sendconfemail', 1). " </ td >
</ tr > " ;
//FIXME check what this is doing exactly.. is it a confirmation email (activation link) or just a notification?
// Give drop-down option to: 1) Notify User and Activate. 2) Notify User and require activation. 3) Don't Notify
if ( ! isset ( $user_data [ 'user_class' ]))
$user_data [ 'user_class' ] = varset ( $pref [ 'initial_user_classes' ], '' );
$temp = $e_userclass -> vetted_tree ( 'class' , array ( $e_userclass , 'checkbox_desc' ), $user_data [ 'user_class' ], 'classes' );
if ( $temp )
{
$text .= " <tr style='vertical-align:top'>
< td >
" .USRLAN_120. "
</ td >< td >
< a href = '#set_class' class = 'e-expandit' > " .USRLAN_120. " </ a >
< div class = 'e-hideme' id = 'set_class' >
{ $temp }
</ div ></ td >
</ tr > \n " ;
}
// Make Admin.
$text .= " <tr>
< td > " .USRLAN_35. " </ td >
< td >
< a href = '#set_perms' class = 'e-expandit' > Set Permissions </ a >
< div class = 'e-hideme' id = 'set_perms' > \n " ;
$text .= $prm -> renderPermTable ( 'grouped' );
$text .= " </div></td>
</ tr > \n " ;
$text .= "
</ table >
< div class = 'buttons-bar center' > " .
$frm -> admin_button ( 'adduser' , USRLAN_60 , 'submit' ) . "
< input type = 'hidden' name = 'ac' value = '".md5(ADMINPWCHANGE)."' />
</ div >
</ form >
</ div >
" ;
echo $mes -> render () . $text ;
//$ns->tablerender(USRLAN_59,$mes->render().$text);
}
function prefsPage ()
{
global $ns , $pref , $e_userclass ;
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
if ( ! is_object ( $e_userclass ))
$e_userclass = new user_class ;
$pref [ 'memberlist_access' ] = varset ( $pref [ 'memberlist_access' ], e_UC_MEMBER );
$text = " <div style='text-align:center'>
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-06-04 09:08:54 +00:00
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > " .USRLAN_44. " :</ td >
< td > " .( $pref['avatar_upload'] ? " < input name = 'avatar_upload' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'avatar_upload' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'avatar_upload' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'avatar_upload' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO).(!FILE_UPLOADS ? " < span class = 'smalltext' > ( " .USRLAN_58. " ) </ span > " : " " ). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_53. " :</ td >
< td > " .( $pref['photo_upload'] ? " < input name = 'photo_upload' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'photo_upload' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'photo_upload' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'photo_upload' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO).(!FILE_UPLOADS ? " < span class = 'smalltext' > ( " .USRLAN_58. " ) </ span > " : " " ). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_47. " :</ td >
< td >
2012-11-03 00:57:29 +00:00
< input class = 'tbox e-spinner' type = 'text' name = 'im_width' size = '10' value = '".$pref[' im_width ']."' maxlength = '5' /> ( " .USRLAN_48. " )
2012-06-04 09:08:54 +00:00
</ td ></ tr >
< tr >
< td > " .USRLAN_49. " :</ td >
< td >
2012-11-03 00:57:29 +00:00
< input class = 'tbox e-spinner' type = 'text' name = 'im_height' size = '10' value = '".$pref[' im_height ']."' maxlength = '5' /> ( " .USRLAN_50. " )
2012-06-04 09:08:54 +00:00
</ td ></ tr >
< tr >
< td > " .USRLAN_126. " :</ td >
< td style = 'vertical-align:top' > " .( $pref['profile_rate'] ? " < input name = 'profile_rate' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_rate' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'profile_rate' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_rate' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
</ td >
</ tr >
< tr >
< td > " .USRLAN_127. " :</ td >
< td style = 'vertical-align:top' > " .( $pref['profile_comments'] ? " < input name = 'profile_comments' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_comments' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'profile_comments' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_comments' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
</ td >
</ tr >
< tr >
2012-06-19 09:08:41 +00:00
< td style = 'vertical-align:top' > " .USRLAN_133. " :</ td >
< td style = 'vertical-align:top' > " .e107::getForm()->radio_switch('force_userupdate',( $pref['force_userupdate'] )). // ? " < input name = 'force_userupdate' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'force_userupdate' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'force_userupdate' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'force_userupdate' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
" <div class='field-help'> " . USRLAN_134 . " </div>
2012-06-04 09:08:54 +00:00
</ td >
</ tr >
< tr >
2012-06-19 09:08:41 +00:00
< td style = 'vertical-align:top' > " .USRLAN_93. " :</ td >
2012-06-04 09:08:54 +00:00
< td >
2012-11-03 00:57:29 +00:00
< input class = 'tbox e-spinner' type = 'text' name = 'del_unv' size = '10' value = '".$pref[' del_unv ']."' maxlength = '5' /> " .USRLAN_95. "
2012-06-19 09:08:41 +00:00
< div class = 'field-help' > " .USRLAN_94. " </ div >
2012-06-04 09:08:54 +00:00
</ td ></ tr >
< tr >
2012-06-19 09:08:41 +00:00
< td > " .USRLAN_130. " :</ td >
< td > " .e107::getForm()->radio_switch('track_online', $pref['track_online'] ). "
< div class = 'field-help' > " .USRLAN_131. " </ div >
2012-06-04 09:08:54 +00:00
</ td >
</ tr >
< tr >
< td > " .USRLAN_146. " :</ td >
< td >< select name = 'memberlist_access' class = 'tbox' > \n " ;
$text .= $e_userclass -> vetted_tree ( 'memberlist_access' , array ( $e_userclass , 'select' ), $pref [ 'memberlist_access' ], " public,member,guest,admin,main,classes,nobody " );
$text .= " </select>
</ td >
</ tr >
2012-06-19 09:08:41 +00:00
< tr >
2012-07-21 03:55:04 +00:00
< td > " .USRLAN_194. " :</ td >
< td > " .
2012-06-19 09:08:41 +00:00
e107 :: getForm () -> uc_select ( 'signature_access' , $pref [ 'signature_access' ], " member,admin,main,classes,nobody " )
. " </td>
</ tr >
2012-06-04 09:08:54 +00:00
< tr >
2012-06-19 09:08:41 +00:00
< td style = 'vertical-align:top' > " .USRLAN_190. " :</ td >
2012-06-04 09:08:54 +00:00
< td >
2012-11-03 00:57:29 +00:00
< input class = 'tbox e-spinner' type = 'text' name = 'user_new_period' size = '10' value = '".varset($pref[' user_new_period '],0)."' maxlength = '5' /> " .LANDT_04s. "
2012-06-19 09:08:41 +00:00
< div class = 'field-help' > " .USRLAN_191. " </ div >
2012-06-04 09:08:54 +00:00
</ td ></ tr >
</ table >
< div class = 'buttons-bar center' >
" . $frm->admin_button ('update_options', USRLAN_51, 'submit'). "
</ div ></ form ></ div > " ;
//$emessage = & eMessage :: getInstance();
echo $mes -> render () . $text ;
//$ns->tablerender(USRLAN_52,$emessage->render().$text);
}
}
class users_admin_form_ui extends e_admin_form_ui
{
function user_perms ( $curval , $mode )
{
if ( $mode == 'read' )
{
$uid = $this -> getController () -> getListModel () -> get ( 'user_id' );
return e107 :: getUserPerms () -> renderPerms ( $curval , $uid );
}
if ( $mode == 'write' )
{
$prm = e107 :: getUserPerms ();
$text = " <a class='e-expandit' href='#perms'>Admin Permissions</a> " ;
$text .= " <div id='perms' style='display:none'> " . $prm -> renderPermTable ( 'grouped' , $curval ) . '</div>' ;
return $text ;
}
}
function user_ban ( $curval , $mode )
{
$bo = array ( 'Active' , LAN_BANNED , LAN_NOTVERIFIED , LAN_BOUNCED );
if ( $mode == 'filter' || $mode == 'batch' )
{
return $bo ;
}
if ( $mode == 'write' )
{
$frm = e107 :: getForm ();
return $frm -> selectbox ( 'user_ban' , $bo , $curval );
}
return vartrue ( $bo [ $curval ], ' ' ); // ($curval == 1) ? ADMIN_TRUE_ICON : '';
2012-07-12 23:26:03 +00:00
}
function user_class ( $curval , $mode )
{
2012-07-13 01:03:45 +00:00
$e_userclass = new user_class ;
$frm = e107 :: getForm ();
$list = $e_userclass -> uc_required_class_list ( " classes " );
2012-07-12 23:26:03 +00:00
if ( $mode == 'filter' )
{
return $list ;
}
2012-07-13 01:03:45 +00:00
if ( $mode == 'write' ) //FIXME userclasses are NOT be saved since they are an array.
{
return $frm -> selectbox ( 'user_class' , $list , $curval , 'description=1&multiple=1' );
// return $frm->uc_select('user_class[]', $curval, 'admin,classes', 'description=1&multiple=1');// doesn't work correctly.
}
2012-07-12 23:26:03 +00:00
//FIXME TODO - option to append userclass to existing value.
if ( $mode == 'batch' )
{
$list [ '#delete' ] = " (clear userclass) " ; // special
return $list ;
}
2012-08-02 02:11:22 +00:00
$tmp = explode ( " , " , $curval );
$text = array ();
foreach ( $tmp as $v )
{
$text [] = $list [ $v ];
}
return implode ( " <br /> " , $text ); // $list[$curval];
2012-07-12 23:26:03 +00:00
}
2012-06-04 09:08:54 +00:00
function user_status ( $curval , $mode )
{
$row = $this -> getController () -> getListModel () -> getData ();
$text = " " ;
if ( $row [ 'user_perms' ] == " 0 " )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap'> " . LAN_MAINADMIN . " </div> " ;
}
else
if ( $row [ 'user_admin' ])
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;;text-align:center'><a href=' " . e_SELF . " ?main.user_admin. " . ( $id == " desc " ? " asc " : " desc " ) . " '> " . LAN_ADMIN . " </a></div> " ;
}
else
if ( $row [ 'user_ban' ] == 1 )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap'><a href=' " . e_SELF . " ?main.user_ban. " . ( $id == " desc " ? " asc " : " desc " ) . " '> " . LAN_BANNED . " </a></div> " ;
}
else
if ( $row [ 'user_ban' ] == 2 )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap' > " . LAN_NOTVERIFIED . " </div> " ;
}
else
if ( $row [ 'user_ban' ] == 3 )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap' > " . LAN_BOUNCED . " </div> " ;
}
else
{
$text .= " " ;
}
return $text ;
}
function options () // old drop-down options.
{
// return 'hello';
$row = $this -> getController () -> getListModel () -> getData ();
// $this->getController()->getListModel()->
// return print_a($row,true);
if ( ! getperms ( '4' ))
{
// return;
}
extract ( $row );
$text .= " <div>
< input type = 'hidden' name = 'userid[{$user_id}]' value = '{$user_id}' />
< input type = 'hidden' name = 'userip[{$user_id}]' value = '{$user_ip}' />
< select name = 'useraction[{$user_id}]' onchange = 'this.form.submit()' class = 'tbox' style = 'width:75%' >
< option selected = 'selected' value = '' >& nbsp ; </ option > " ;
if ( $user_perms != " 0 " )
{
$text .= " <option value='userinfo'> " . USRLAN_80 . " </option>
< option value = 'usersettings' > " .LAN_EDIT. " </ option >
" ;
// login/logout As
if ( getperms ( '0' ) && ! ( $row [ 'user_admin' ] && getperms ( '0' , $row [ 'user_perms' ])))
{
if ( e107 :: getUser () -> getSessionDataAs () == $row [ 'user_id' ]) $text .= " <option value='logoutas'> " . sprintf ( USRLAN_AS_2 , $row [ 'user_name' ]) . " </option> " ;
else $text .= " <option value='loginas'> " . sprintf ( USRLAN_AS_1 , $row [ 'user_name' ]) . " </option> " ;
}
switch ( $user_ban )
{
case 0 :
$text .= " <option value='ban'> " . USRLAN_30 . " </option> \n " ;
break ;
case 1 :
// Banned user
$text .= " <option value='unban'> " . USRLAN_33 . " </option> \n " ;
break ;
case 2 :
// Unverified
$text .= " <option value='ban'> " . USRLAN_30 . " </option>
< option value = 'verify' > " .USRLAN_32. " </ option >
< option value = 'resend' > " .USRLAN_112. " </ option >
< option value = 'test' > " .USRLAN_118. " </ option > " ;
break ;
case 3 :
// Bounced
$text .= " <option value='ban'> " . USRLAN_30 . " </option>
< option value = 'reqverify' > " .USRLAN_181. " </ option >
< option value = 'verify' > " .USRLAN_182. " </ option >
< option value = 'test' > " .USRLAN_118. " </ option > " ;
break ;
default :
}
if ( ! $user_admin && ! $user_ban && $user_ban != 2 && getperms ( '3' ))
{
$text .= " <option value='admin'> " . USRLAN_35 . " </option> \n " ;
}
else
if ( $user_admin && $user_perms != " 0 " && getperms ( '3' ))
{
$text .= " <option value='adminperms'> " . USRLAN_221 . " </option> \n " ;
$text .= " <option value='unadmin'> " . USRLAN_34 . " </option> \n " ;
}
}
if ( $user_perms == " 0 " && ! getperms ( " 0 " ))
{
$text .= " " ;
}
elseif ( $user_id != USERID || getperms ( " 0 " ))
{
$text .= " <option value='userclass'> " . USRLAN_36 . " </option> \n " ;
}
if ( $user_perms != " 0 " )
{
$text .= " <option value='deluser'> " . LAN_DELETE . " </option> \n " ;
}
$text .= " </select></div> " ;
return $text ;
}
}
new users_admin ();
require_once ( 'auth.php' );
e107 :: getAdminUI () -> runPage ();
2009-07-23 06:55:39 +00:00
if ( ! e_QUERY )
2011-05-11 11:56:42 +00:00
{
// Determine the default based on perms.
foreach ( $user -> menuOptions as $act => $arr )
{
if ( getperms ( $arr [ 'perm' ]))
{
$action = $act ;
break ;
}
}
}
2008-01-01 12:38:05 +00:00
switch ( $action )
{
2009-07-23 06:55:39 +00:00
case " unverified " :
2012-06-04 09:08:54 +00:00
// $user->show_existing_users($action,$sub_action,$id,$from,$amount);
2011-05-11 11:56:42 +00:00
break ;
2009-07-23 06:55:39 +00:00
case " options " :
2011-05-11 11:56:42 +00:00
if ( getperms ( '4|U2' ))
{
2012-06-04 09:08:54 +00:00
// $user->show_prefs();
2011-05-11 11:56:42 +00:00
}
break ;
2008-12-21 11:07:58 +00:00
case " prune " :
2012-06-04 09:08:54 +00:00
// $user->show_prune(); // move to schedule tasks
2011-05-11 11:56:42 +00:00
break ;
2008-12-21 11:07:58 +00:00
case " create " :
2011-05-11 22:25:02 +00:00
if ( getperms (( '4|U1|U0' )))
2011-05-11 11:56:42 +00:00
{
2012-06-04 09:08:54 +00:00
// $userMethods->deleteExpired(); // Remove time-expired users
// $user->user_add($user_data);
2011-05-11 11:56:42 +00:00
}
break ;
case " ranks " :
if ( getperms (( '4|U3' )))
{
2012-06-04 09:08:54 +00:00
// showRanks();
2011-05-11 11:56:42 +00:00
}
break ;
2008-12-21 11:07:58 +00:00
default :
2011-05-11 22:25:02 +00:00
if ( getperms ( '4|U1|U0' ))
2011-05-11 11:56:42 +00:00
{
2012-06-04 09:08:54 +00:00
// $user->show_existing_users($action,$sub_action,$id,$from,$amount);
2011-05-11 11:56:42 +00:00
}
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
// ---------------------------------------------------------------------
2009-07-23 06:55:39 +00:00
require_once ( " footer.php " );
2007-12-09 16:42:23 +00:00
class users
{
2009-07-08 06:58:00 +00:00
var $fields = array ();
var $fieldpref = array ();
2009-07-17 07:53:13 +00:00
var $sortorder = " asc " ;
var $sortorderrev = " desc " ;
var $sortfield = " user_id " ;
var $from = 0 ;
2011-05-11 11:56:42 +00:00
var $menuOptions = array ();
2009-07-08 06:58:00 +00:00
function users ()
2007-12-09 16:42:23 +00:00
{
2011-05-11 11:56:42 +00:00
// Any changed need to be duplicated in /usersettings.php (end of the script)
$var = array ();
$var [ 'main' ][ 'text' ] = LAN_USER_LIST ;
$var [ 'main' ][ 'link' ] = e_ADMIN . 'users.php' ;
2011-05-11 22:25:02 +00:00
$var [ 'main' ][ 'perm' ] = '4|U0|U1' ;
2011-05-11 11:56:42 +00:00
$var [ 'create' ][ 'text' ] = LAN_USER_QUICKADD ;
2012-04-18 21:07:20 +00:00
$var [ 'create' ][ 'link' ] = e_ADMIN . 'users.php?action=create' ;
2011-05-11 22:25:02 +00:00
$var [ 'create' ][ 'perm' ] = '4|U0|U1' ;
2011-05-11 11:56:42 +00:00
$var [ 'prune' ][ 'text' ] = LAN_USER_PRUNE ;
2012-04-18 21:07:20 +00:00
$var [ 'prune' ][ 'link' ] = e_ADMIN . 'users.php?action=prune' ; // Will be moved to "Schedule tasks"
2011-05-11 11:56:42 +00:00
$var [ 'prune' ][ 'perm' ] = '4' ;
$var [ 'options' ][ 'text' ] = LAN_OPTIONS ;
2012-04-18 21:07:20 +00:00
$var [ 'options' ][ 'link' ] = e_ADMIN . 'users.php?action=options' ;
2011-05-11 11:56:42 +00:00
$var [ 'options' ][ 'perm' ] = '4|U2' ;
$var [ 'ranks' ][ 'text' ] = LAN_USER_RANKS ;
2012-04-18 21:07:20 +00:00
$var [ 'ranks' ][ 'link' ] = e_ADMIN . 'users.php?action=ranks' ;
2011-05-11 11:56:42 +00:00
$var [ 'ranks' ][ 'perm' ] = '4|U3' ;
// if ($unverified) // No longer needed - done with 'filter'.
// {
// $var ['unveri']['text'] = USRLAN_138." ($unverified)";
// $var ['unveri']['link'] = e_ADMIN.'users.php?unverified';
// }
$this -> menuOptions = $var ;
2009-07-23 06:55:39 +00:00
global $pref , $user_pref , $sql , $tp ;
if ( isset ( $pref [ 'admin_user_disp' ]))
2007-12-09 16:42:23 +00:00
{
2009-07-23 06:55:39 +00:00
$user_pref [ 'admin_users_columns' ] = ( $pref [ 'admin_user_disp' ]) ? explode ( " | " , $pref [ 'admin_user_disp' ]) : array ( 'user_status' , 'user_name' , 'user_class' );
save_prefs ( 'user' );
unset ( $pref [ 'admin_user_disp' ]);
2009-07-17 07:53:13 +00:00
save_prefs ();
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
// $this->usersSaveColumnPref();
2009-07-23 06:55:39 +00:00
$this -> fieldpref = ( ! $user_pref [ 'admin_users_columns' ]) ? array ( 'user_name' , 'user_class' ) : $user_pref [ 'admin_users_columns' ];
2009-07-08 06:58:00 +00:00
2009-07-23 06:55:39 +00:00
/* if ( e_QUERY )
2009-07-17 07:53:13 +00:00
{
2009-07-23 06:55:39 +00:00
$tmp = explode ( '.' , e_QUERY );
$action = $tmp [ 0 ]; // main
$sub_action = varset ( $tmp [ 1 ], '' );
$id = varset ( $tmp [ 2 ], 0 );
$from = varset ( $tmp [ 3 ], 0 );
unset ( $tmp );
2009-07-17 07:53:13 +00:00
} */
2009-07-23 06:55:39 +00:00
global $sub_action , $id , $from ;
if ( $from )
{
$this -> sortfield = $sub_action ;
2009-07-17 07:53:13 +00:00
$this -> sortorder = $id ;
$this -> sortorderrev = ( $this -> sortorder == 'asc' ) ? 'desc' : 'asc' ;
$this -> from = $from ;
}
2009-08-05 22:37:16 +00:00
$this -> fields = array (
'checkboxes' => array ( 'title' => '' , 'width' => '3%' , 'forced' => true , 'thclass' => 'center first' ),
'user_id' => array ( 'title' => 'Id' , 'width' => '5%' , 'forced' => true ),
2009-11-08 09:14:39 +00:00
'user_status' => array ( 'title' => LAN_STATUS , 'width' => 'auto' , 'nosort' => TRUE ),
2009-08-05 22:37:16 +00:00
'user_name' => array ( 'title' => LAN_USER_01 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left first' ), // Display name
'user_loginname' => array ( 'title' => LAN_USER_02 , 'type' => 'text' , 'width' => 'auto' ), // User name
'user_login' => array ( 'title' => LAN_USER_03 , 'type' => 'text' , 'width' => 'auto' ), // Real name (no real vetting)
'user_customtitle' => array ( 'title' => LAN_USER_04 , 'type' => 'text' , 'width' => 'auto' ), // No real vetting
'user_password' => array ( 'title' => LAN_USER_05 , 'type' => 'text' , 'width' => 'auto' ),
'user_sess' => array ( 'title' => LAN_USER_06 , 'type' => 'text' , 'width' => 'auto' ), // Photo
'user_image' => array ( 'title' => LAN_USER_07 , 'type' => 'text' , 'width' => 'auto' ), // Avatar
'user_email' => array ( 'title' => LAN_USER_08 , 'type' => 'text' , 'width' => 'auto' ),
'user_signature' => array ( 'title' => LAN_USER_09 , 'type' => 'text' , 'width' => 'auto' ),
2009-10-21 07:31:07 +00:00
'user_hideemail' => array ( 'title' => LAN_USER_10 , 'type' => 'boolean' , 'width' => 'auto' ),
2009-08-05 22:37:16 +00:00
'user_xup' => array ( 'title' => LAN_USER_11 , 'type' => 'text' , 'width' => 'auto' ),
2010-03-13 18:59:28 +00:00
'user_class' => array ( 'title' => LAN_USER_12 , 'type' => 'class' ),
2009-10-21 07:31:07 +00:00
'user_join' => array ( 'title' => LAN_USER_14 , 'type' => 'date' , 'width' => 'auto' ),
'user_lastvisit' => array ( 'title' => LAN_USER_15 , 'type' => 'date' , 'width' => 'auto' ),
'user_currentvisit' => array ( 'title' => LAN_USER_16 , 'type' => 'date' , 'width' => 'auto' ),
2009-08-05 22:37:16 +00:00
'user_comments' => array ( 'title' => LAN_USER_17 , 'width' => 'auto' ),
2009-10-21 07:31:07 +00:00
'user_lastpost' => array ( 'title' => 'Last Post' , 'type' => 'date' , 'width' => 'auto' ),
2009-08-05 22:37:16 +00:00
'user_ip' => array ( 'title' => LAN_USER_18 , 'width' => 'auto' ),
2009-10-21 07:31:07 +00:00
'user_ban' => array ( 'title' => LAN_USER_19 , 'type' => 'boolean' , 'width' => 'auto' ),
2009-08-05 22:37:16 +00:00
'user_prefs' => array ( 'title' => LAN_USER_20 , 'width' => 'auto' ),
2009-10-21 07:31:07 +00:00
'user_visits' => array ( 'title' => LAN_USER_21 , 'width' => 'auto' , 'thclass' => 'right' ),
'user_admin' => array ( 'title' => LAN_USER_22 , 'type' => 'boolean' , 'width' => 'auto' , 'thclass' => 'center' ),
2009-08-05 22:37:16 +00:00
'user_perms' => array ( 'title' => LAN_USER_23 , 'width' => 'auto' ),
'user_pwchange' => array ( 'title' => LAN_USER_24 , 'width' => 'auto' ),
);
2009-10-21 21:36:10 +00:00
if ( $sql -> db_Select ( 'user_extended_struct' , 'user_extended_struct_name' , " user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' ORDER BY user_extended_struct_parent ASC " ))
2007-12-09 16:42:23 +00:00
{
2009-10-21 21:36:10 +00:00
while ( $row = $sql -> db_Fetch ())
{
$field = " user_ " . $row [ 'user_extended_struct_name' ];
$title = ucfirst ( str_replace ( " user_ " , " " , $field ));
$this -> fields [ $field ] = array ( 'title' => $title , 'width' => 'auto' );
}
2007-12-09 16:42:23 +00:00
}
2009-07-23 06:55:39 +00:00
$this -> fields [ 'options' ] = array ( 'title' => LAN_OPTIONS , 'width' => '10%' , " thclass " => " center last " , 'forced' => true );
2011-05-11 11:56:42 +00:00
2011-05-11 22:25:02 +00:00
if ( ! getperms ( '4|U0' )) // Quick Add User Access Only.
2011-05-11 11:56:42 +00:00
{
unset ( $this -> fields [ 'checkboxes' ]);
unset ( $this -> fields [ 'options' ]);
2011-05-11 22:25:02 +00:00
$this -> fieldpref = array ( 'user_name' , 'user_loginname' , 'user_login' , 'user_email' , 'user_class' , 'user_ban' , 'user_admin' );
2011-05-11 11:56:42 +00:00
}
// print_a($this->fields);
2009-07-22 17:04:59 +00:00
}
2012-06-04 09:08:54 +00:00
/*
2009-07-23 06:55:39 +00:00
function process_batch ()
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
list ( $type , $tmp , $uclass ) = explode ( " _ " , $_POST [ 'execute_batch' ]);
2009-07-22 17:04:59 +00:00
$method = " user_ " . $type ;
2010-03-13 18:59:28 +00:00
2009-09-22 19:43:34 +00:00
if ( $method == " user_remuserclass " )
{
2010-03-13 18:59:28 +00:00
$method = " user_userclass " ;
2009-09-22 19:43:34 +00:00
}
if ( method_exists ( $this , $method ) && isset ( $_POST [ 'user_selected' ]) )
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
foreach ( $_POST [ 'user_selected' ] as $userid )
2009-07-22 17:04:59 +00:00
{
2010-03-13 18:59:28 +00:00
2009-08-10 15:34:28 +00:00
if ( $type == 'userclass' || $type == 'remuserclass' )
2010-03-13 18:59:28 +00:00
{
2009-09-22 19:43:34 +00:00
switch ( $type )
{
case 'userclass' :
$mode = 'append' ;
break ;
2010-03-13 18:59:28 +00:00
2009-09-22 19:43:34 +00:00
case 'remuserclass' :
$mode = ( $uclass != '0' ) ? 'remove' : 'clear' ;
break ;
}
2010-03-13 18:59:28 +00:00
2009-09-22 19:43:34 +00:00
$this -> $method ( $userid , array ( $uclass ), $mode );
2009-07-23 06:55:39 +00:00
}
else
{
$this -> $method ( $userid );
}
2009-07-22 17:04:59 +00:00
}
}
}
2012-06-04 09:08:54 +00:00
*/
/*
2009-07-23 06:55:39 +00:00
function user_delete ( $userid , $confirm = false )
{
global $sql , $admin_log , $e_event , $ns ;
if ( $_POST [ 'confirm' ] || ! $confirm )
2009-07-22 17:04:59 +00:00
{
$uid = ( $confirm ) ? intval ( $_POST [ 'userid' ]) : $userid ;
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Delete ( " user " , " user_id= " . $uid . " AND user_perms != '0' AND user_perms != '0.' " ))
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
$sql -> db_Delete ( " user_extended " , " user_extended_id=' " . $uid . " ' " );
2009-07-22 17:04:59 +00:00
$admin_log -> log_event ( 'USET_07' , str_replace ( '--UID--' , $uid , USRLAN_163 ), E_LOG_INFORMATIVE );
2009-07-23 06:55:39 +00:00
$e_event -> trigger ( 'userdelete' , $temp = array ( 'user_id' => $uid ));
2009-07-22 17:04:59 +00:00
$this -> show_message ( USRLAN_10 );
}
2009-07-23 06:55:39 +00:00
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
if ( ! $id )
{
$id = " DESC " ;
}
2009-07-22 17:04:59 +00:00
}
else
2009-07-23 06:55:39 +00:00
{
// Put up confirmation
if ( $sql -> db_Select ( " user " , " * " , " user_id=' " . $_POST [ 'userid' ] . " ' " ))
2009-07-22 17:04:59 +00:00
{
$row = $sql -> db_Fetch ();
$qry = ( e_QUERY ) ? " ? " . e_QUERY : " " ;
$text .= " <form method='post' action=' " . e_SELF . $qry . " '><div style='text-align:center'> \n " ;
$text .= " <div>
< input type = 'hidden' name = 'useraction' value = 'deluser' />
2009-07-23 06:55:39 +00:00
< input type = 'hidden' name = 'userid' value = '{$row[' user_id ']}' /></ div > " .USRLAN_13. "
2009-07-22 17:04:59 +00:00
< br />< br />< span class = 'indent' > #{$row['user_id']} : {$row['user_name']}</span>
< br />< br />
< input type = 'submit' class = 'button' name = 'confirm' value = '".USRLAN_17."' />
& nbsp ; & nbsp ;
< input type = 'button' class = 'button' name = 'cancel' value = '".LAN_CANCEL."' onclick = \ " location.href=' " . e_SELF . $qry . " ' \" />
</ div >
</ form >
" ;
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( USRLAN_16 , $text );
require_once ( " footer.php " );
2009-07-22 17:04:59 +00:00
exit ;
}
}
}
2012-06-04 09:08:54 +00:00
*/
/* FIXME banlist changes need to be integrated into the code above .
2009-07-23 06:55:39 +00:00
function user_unban ( $userid )
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
global $sql , $admin_log ;
$sql -> db_Select ( " user " , " user_name,user_ip " , " user_id=' " . $userid . " ' " );
2009-07-22 17:04:59 +00:00
$row = $sql -> db_Fetch ();
2009-07-23 06:55:39 +00:00
$sql -> db_Update ( " user " , " user_ban='0' WHERE user_id=' " . $userid . " ' " );
$sql -> db_Delete ( " banlist " , " banlist_ip=' { $row [ 'user_ip' ] } ' " );
2009-07-22 17:04:59 +00:00
$admin_log -> log_event ( 'USET_06' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $userid , $row [ 'user_name' ]), USRLAN_162 ), E_LOG_INFORMATIVE );
$this -> show_message ( USRLAN_9 . " ( " . $userid . " . " . $row [ 'user_name' ] . " ) " );
$action = " main " ;
2009-07-23 06:55:39 +00:00
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
2009-07-22 17:04:59 +00:00
}
2012-06-04 09:08:54 +00:00
*/
2009-07-23 06:55:39 +00:00
2009-07-22 17:04:59 +00:00
function user_activate ( $userid )
{
2009-07-23 06:55:39 +00:00
global $sql , $e_event , $admin_log , $userMethods ;
$uid = intval ( $userid );
if ( $sql -> db_Select ( " user " , " * " , " user_id=' " . $uid . " ' " ))
2009-07-22 17:04:59 +00:00
{
if ( $row = $sql -> db_Fetch ())
{
$dbData = array ();
$dbData [ 'WHERE' ] = " user_id= " . $uid ;
2009-07-23 06:55:39 +00:00
$dbData [ 'data' ] = array ( 'user_ban' => '0' , 'user_sess' => '' );
2009-07-22 17:04:59 +00:00
// Add in the initial classes as necessary
2009-07-23 06:55:39 +00:00
if ( $userMethods -> userClassUpdate ( $row , 'userall' ))
2009-07-22 17:04:59 +00:00
{
$dbData [ 'data' ][ 'user_class' ] = $row [ 'user_class' ];
}
$userMethods -> addNonDefaulted ( $dbData );
2009-07-23 06:55:39 +00:00
validatorClass :: addFieldTypes ( $userMethods -> userVettingInfo , $dbData );
2009-07-22 17:04:59 +00:00
$sql -> db_Update ( 'user' , $dbData );
$admin_log -> log_event ( 'USET_10' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $row [ 'user_id' ], $row [ 'user_name' ]), USRLAN_166 ), E_LOG_INFORMATIVE );
2009-07-23 06:55:39 +00:00
$e_event -> trigger ( 'userfull' , $row );
// 'New' event
2009-07-22 17:04:59 +00:00
$this -> show_message ( USRLAN_86 . " (# " . $userid . " : " . $row [ 'user_name' ] . " ) " );
2009-07-23 06:55:39 +00:00
if ( ! $action )
{
$action = " main " ;
}
if ( ! $sub_action )
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
$sub_action = " user_id " ;
}
if ( ! $id )
{
$id = " DESC " ;
}
if ( $pref [ 'user_reg_veri' ] == 2 )
{
if ( $sql -> db_Select ( " user " , " user_email, user_name " , " user_id = ' { $uid } ' " ))
2009-07-22 17:04:59 +00:00
{
$row = $sql -> db_Fetch ();
$message = USRLAN_114 . " " . $row [ 'user_name' ] . " , \n \n " . USRLAN_122 . " " . SITENAME . " . \n \n " . USRLAN_123 . " \n \n " ;
2009-07-23 06:55:39 +00:00
$message .= str_replace ( " { SITEURL} " , SITEURL , USRLAN_139 );
require_once ( e_HANDLER . " mail.php " );
if ( sendemail ( $row [ 'user_email' ], USRLAN_113 . " " . SITENAME , $message ))
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
// echo str_replace("\n","<br>",$message);
2009-07-22 17:04:59 +00:00
$this -> show_message ( " Email sent to: " . $row [ 'user_name' ]);
}
else
{
$this -> show_message ( " Failed to send to: " . $row [ 'user_name' ], 'error' );
}
}
}
}
}
2009-07-08 06:58:00 +00:00
}
2012-06-04 09:08:54 +00:00
/*
2009-07-23 06:55:39 +00:00
function usersSaveColumnPref ()
2009-07-08 06:58:00 +00:00
{
2009-07-23 06:55:39 +00:00
global $pref , $user_pref , $admin_log ;
2009-11-05 17:32:19 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ]))
2007-12-09 16:42:23 +00:00
{
2009-07-08 06:58:00 +00:00
$user_pref [ 'admin_users_columns' ] = $_POST [ 'e-columns' ];
save_prefs ( 'user' );
2006-12-02 04:36:16 +00:00
}
2009-07-08 06:58:00 +00:00
}
2009-07-23 06:55:39 +00:00
2009-08-05 16:02:09 +00:00
function user_info ( $ipd )
{
2009-08-23 10:57:51 +00:00
global $ns , $sql , $e107 ;
2009-08-05 16:02:09 +00:00
if ( isset ( $ipd ))
{
2009-08-23 10:57:51 +00:00
$bullet = '' ;
if ( defined ( 'BULLET' ))
{
$bullet = '<img src="' . THEME . 'images/' . BULLET . '" alt="" class="icon" />' ;
}
elseif ( file_exists ( THEME . 'images/bullet2.gif' ))
{
$bullet = '<img src="' . THEME . 'images/bullet2.gif" alt="" class="icon" />' ;
}
2009-08-05 16:02:09 +00:00
// TODO - move to e_userinfo.php
$obj = new convert ;
$sql -> db_Select ( " chatbox " , " * " , " cb_ip=' $ipd ' LIMIT 0,20 " );
$host = $e107 -> get_host_name ( $ipd );
$text = USFLAN_3 . " <b> " . $ipd . " </b> [ " . USFLAN_4 . " : $host ]<br />
< i >< a href = \ " banlist.php? " . $ipd . " \" > " . USFLAN_5 . " </a></i>
< br />< br /> " ;
while ( list ( $cb_id , $cb_nick , $cb_message , $cb_datestamp , $cb_blocked , $cb_ip ) = $sql -> db_Fetch ())
{
$datestamp = $obj -> convert_date ( $cb_datestamp , " short " );
$post_author_id = substr ( $cb_nick , 0 , strpos ( $cb_nick , " . " ));
$post_author_name = substr ( $cb_nick , ( strpos ( $cb_nick , " . " ) + 1 ));
2009-08-23 10:57:51 +00:00
$text .= $bullet . "
< span class = \ " defaulttext \" ><i> " . $post_author_name . " ( " . USFLAN_6 . " : " . $post_author_id . " )</i></span>
< div class = \ " mediumtext \" >
" . $datestamp . "
< br />
" . $cb_message . "
</ div >
< br /> " ;
2009-08-05 16:02:09 +00:00
}
$text .= " <hr /> " ;
$sql -> db_Select ( " comments " , " * " , " comment_ip=' $ipd ' LIMIT 0,20 " );
while ( list ( $comment_id , $comment_item_id , $comment_author , $comment_author_email , $comment_datestamp , $comment_comment , $comment_blocked , $comment_ip ) = $sql -> db_Fetch ())
{
$datestamp = $obj -> convert_date ( $comment_datestamp , " short " );
$post_author_id = substr ( $comment_author , 0 , strpos ( $comment_author , " . " ));
$post_author_name = substr ( $comment_author , ( strpos ( $comment_author , " . " ) + 1 ));
2009-08-23 10:57:51 +00:00
$text .= $bullet . "
< span class = \ " defaulttext \" ><i> " . $post_author_name . " ( " . USFLAN_6 . " : " . $post_author_id . " )</i></span>
< div class = \ " mediumtext \" >
" . $datestamp . "
< br /> " . $comment_comment . "
</ div >
< br /> " ;
2009-08-05 16:02:09 +00:00
}
}
$ns -> tablerender ( USFLAN_7 , $text );
}
2009-07-17 07:53:13 +00:00
function showUserStatus ( $row )
{
2009-07-23 06:55:39 +00:00
if ( $row [ 'user_perms' ] == " 0 " )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap'> " . LAN_MAINADMIN . " </div> " ;
}
else
if ( $row [ 'user_admin' ])
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;;text-align:center'><a href=' " . e_SELF . " ?main.user_admin. " . ( $id == " desc " ? " asc " : " desc " ) . " '> " . LAN_ADMIN . " </a></div> " ;
}
else
if ( $row [ 'user_ban' ] == 1 )
{
2009-07-17 07:53:13 +00:00
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap'><a href=' " . e_SELF . " ?main.user_ban. " . ( $id == " desc " ? " asc " : " desc " ) . " '> " . LAN_BANNED . " </a></div> " ;
}
2009-07-23 06:55:39 +00:00
else
if ( $row [ 'user_ban' ] == 2 )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap' > " . LAN_NOTVERIFIED . " </div> " ;
}
else
if ( $row [ 'user_ban' ] == 3 )
{
$text .= " <div class='fcaption' style='padding-left:3px;padding-right:3px;text-align:center;white-space:nowrap' > " . LAN_BOUNCED . " </div> " ;
}
else
{
$text .= " " ;
}
return $text ;
2009-07-17 07:53:13 +00:00
}
2009-07-23 06:55:39 +00:00
2009-07-17 07:53:13 +00:00
function showUserOptions ( $row )
{
2011-05-11 11:56:42 +00:00
if ( ! getperms ( '4' ))
{
// return;
}
2009-07-17 07:53:13 +00:00
extract ( $row );
$text .= " <div>
< input type = 'hidden' name = 'userid[{$user_id}]' value = '{$user_id}' />
< input type = 'hidden' name = 'userip[{$user_id}]' value = '{$user_ip}' />
< select name = 'useraction[{$user_id}]' onchange = 'this.form.submit()' class = 'tbox' style = 'width:75%' >
< option selected = 'selected' value = '' >& nbsp ; </ option > " ;
2009-07-23 06:55:39 +00:00
if ( $user_perms != " 0 " )
{
$text .= " <option value='userinfo'> " . USRLAN_80 . " </option>
2010-05-14 18:45:51 +00:00
< option value = 'usersettings' > " .LAN_EDIT. " </ option >
" ;
// login/logout As
if ( getperms ( '0' ) && ! ( $row [ 'user_admin' ] && getperms ( '0' , $row [ 'user_perms' ])))
{
if ( e107 :: getUser () -> getSessionDataAs () == $row [ 'user_id' ]) $text .= " <option value='logoutas'> " . sprintf ( USRLAN_AS_2 , $row [ 'user_name' ]) . " </option> " ;
else $text .= " <option value='loginas'> " . sprintf ( USRLAN_AS_1 , $row [ 'user_name' ]) . " </option> " ;
}
2009-07-23 06:55:39 +00:00
switch ( $user_ban )
{
case 0 :
$text .= " <option value='ban'> " . USRLAN_30 . " </option> \n " ;
break ;
case 1 :
// Banned user
$text .= " <option value='unban'> " . USRLAN_33 . " </option> \n " ;
break ;
case 2 :
// Unverified
$text .= " <option value='ban'> " . USRLAN_30 . " </option>
2009-07-17 07:53:13 +00:00
< option value = 'verify' > " .USRLAN_32. " </ option >
< option value = 'resend' > " .USRLAN_112. " </ option >
< option value = 'test' > " .USRLAN_118. " </ option > " ;
2009-07-23 06:55:39 +00:00
break ;
case 3 :
// Bounced
$text .= " <option value='ban'> " . USRLAN_30 . " </option>
2009-07-17 07:53:13 +00:00
< option value = 'reqverify' > " .USRLAN_181. " </ option >
< option value = 'verify' > " .USRLAN_182. " </ option >
< option value = 'test' > " .USRLAN_118. " </ option > " ;
2009-07-23 06:55:39 +00:00
break ;
default :
}
if ( ! $user_admin && ! $user_ban && $user_ban != 2 && getperms ( '3' ))
{
$text .= " <option value='admin'> " . USRLAN_35 . " </option> \n " ;
}
else
if ( $user_admin && $user_perms != " 0 " && getperms ( '3' ))
2009-07-17 07:53:13 +00:00
{
2009-11-12 05:11:47 +00:00
$text .= " <option value='adminperms'> " . USRLAN_221 . " </option> \n " ;
2009-07-23 06:55:39 +00:00
$text .= " <option value='unadmin'> " . USRLAN_34 . " </option> \n " ;
2009-07-17 07:53:13 +00:00
}
2009-07-23 06:55:39 +00:00
}
if ( $user_perms == " 0 " && ! getperms ( " 0 " ))
{
$text .= " " ;
}
elseif ( $user_id != USERID || getperms ( " 0 " ))
{
$text .= " <option value='userclass'> " . USRLAN_36 . " </option> \n " ;
}
if ( $user_perms != " 0 " )
{
$text .= " <option value='deluser'> " . LAN_DELETE . " </option> \n " ;
}
$text .= " </select></div> " ;
2009-07-17 07:53:13 +00:00
return $text ;
}
2009-07-23 06:55:39 +00:00
function show_search_filter ()
2009-07-22 17:04:59 +00:00
{
2009-08-03 16:43:46 +00:00
global $frm ;
2009-08-03 16:40:09 +00:00
$e_userclass = new user_class ;
// TODO - The search field (not the userclass drop-down) should be replaced with a generic ajax search-filter class element.
2009-11-17 13:12:43 +00:00
$text = " <form method='get' action=' " . e_SELF . " '>
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' > \n " ;
2009-11-17 13:12:43 +00:00
$text .= " <tr><td><input class='tbox' type='text' name='srch' size='20' value= \" " . $_GET [ 'srch' ] . " \" maxlength='50' /> \n " ;
2009-08-03 16:40:09 +00:00
$list = $e_userclass -> uc_required_class_list ( " public,member,admin,main,classes " );
$ulist = $list + array ( 'unverified' => LAN_NOTVERIFIED , 'banned' => LAN_BANNED , 'bounced' => LAN_BOUNCED );
2009-11-17 13:12:43 +00:00
$text .= " <select class='tbox' name='filter' onchange='this.form.submit()' > \n " ;
2009-08-03 16:40:09 +00:00
foreach ( $ulist as $key => $val )
{
2009-11-17 13:12:43 +00:00
$sel = ( $_SESSION [ 'filter' ] == $key ) ? " selected='selected' " : " " ;
2009-08-03 16:40:09 +00:00
$text .= " <option value=' $key ' { $sel } > " . $val . " </option> \n " ;
}
2009-08-03 16:43:46 +00:00
$text .= " </select> " ;
$text .= $frm -> admin_button ( 'searchsubmit' , ADLAN_142 );
// <input class='button' type='submit' name='searchsubmit' value='".ADLAN_142."' />\n
// \n";
2009-07-22 17:04:59 +00:00
$text .= " </td></tr></table>
</ form > \n " ;
return $text ;
}
2009-08-03 16:40:09 +00:00
function get_search_query ()
2009-07-08 06:58:00 +00:00
{
2009-08-03 16:40:09 +00:00
global $sql , $frm , $ns , $tp , $mySQLdefaultdb , $pref , $unverified , $userMethods , $sub_action , $id , $from , $amount ;
2009-11-17 13:12:43 +00:00
if ( isset ( $_GET [ 'srch' ])) // We could use $_GET, if so, would need to rework the ordering to use $_GET also.
2006-12-02 04:36:16 +00:00
{
2009-11-17 13:12:43 +00:00
$_SESSION [ 'srch' ] = $_GET [ 'srch' ];
2009-08-03 16:40:09 +00:00
}
2009-11-17 13:12:43 +00:00
if ( isset ( $_GET [ 'filter' ]))
2009-08-03 16:40:09 +00:00
{
2009-11-17 13:12:43 +00:00
$_SESSION [ 'filter' ] = $_GET [ 'filter' ];
2009-08-03 16:40:09 +00:00
}
2009-11-17 13:12:43 +00:00
if ( isset ( $_SESSION [ 'srch' ]) && $_SESSION [ 'srch' ] != " " )
2009-08-03 16:40:09 +00:00
{
2009-11-17 13:12:43 +00:00
$_SESSION [ 'srch' ] = $tp -> toDB ( trim ( $_SESSION [ 'srch' ]));
2009-08-03 16:40:09 +00:00
$query .= " ( " ;
2012-04-18 21:07:20 +00:00
$query .= ( strpos ( $_SESSION [ 'srch' ], " @ " ) !== false ) ? " u.user_email REGEXP(' " . $_SESSION [ 'srch' ] . " ') OR " : " " ;
$query .= ( strpos ( $_SESSION [ 'srch' ], " . " ) !== false ) ? " u.user_ip REGEXP(' " . $_SESSION [ 'srch' ] . " ') OR " : " " ;
2009-08-03 16:40:09 +00:00
$fquery = array ();
2012-04-18 21:07:20 +00:00
2009-08-03 16:40:09 +00:00
foreach ( $this -> fieldpref as $field )
2006-12-02 04:36:16 +00:00
{
2012-04-18 21:07:20 +00:00
if ( $field == 'user_status' ){ continue ; }
2009-11-17 13:12:43 +00:00
$fquery [] = $field . " REGEXP(' " . $_SESSION [ 'srch' ] . " ') " ;
2006-12-02 04:36:16 +00:00
}
2009-08-03 16:40:09 +00:00
$query .= implode ( " OR " , $fquery );
$query .= " ) " ;
2012-04-18 21:07:20 +00:00
$qry_order = ' ORDER BY u.user_id' ;
2008-12-22 03:15:04 +00:00
}
else
2008-12-21 11:07:58 +00:00
{
2008-12-22 03:15:04 +00:00
$query = '' ;
2012-06-04 09:08:54 +00:00
// if ($action == 'unverified')
// {
// $query = 'user_ban = 2 ';
// }
2012-04-18 21:07:20 +00:00
$qry_order = 'ORDER BY ' . ( $sub_action ? $sub_action : 'user_id' ) . ' ' . ( $id ? $id : 'DESC' );
2009-08-03 16:40:09 +00:00
}
2009-11-17 13:12:43 +00:00
if ( varset ( $_SESSION [ 'filter' ]))
2009-08-03 16:40:09 +00:00
{
$uqry [ e_UC_ADMIN ] = " u.user_admin = 1 " ;
$uqry [ e_UC_MEMBER ] = " u.user_ban = '0' " ;
2009-11-23 01:17:29 +00:00
$uqry [ e_UC_MAINADMIN ] = " (u.user_perms = '0' OR u.user_perms = '0.') " ;
2009-08-03 16:40:09 +00:00
$uqry [ 'unverified' ] = " u.user_ban = 2 " ;
$uqry [ 'banned' ] = " u.user_ban = 1 " ;
$uqry [ 'bounced' ] = " u.user_ban = 3 " ;
if ( $query )
{
$query .= " AND " ;
}
2009-11-17 13:12:43 +00:00
if ( isset ( $uqry [ $_SESSION [ 'filter' ]]))
2009-08-03 16:40:09 +00:00
{
2009-11-17 13:12:43 +00:00
$query .= $uqry [ $_SESSION [ 'filter' ]];
2009-08-03 16:40:09 +00:00
}
else
2006-12-02 04:36:16 +00:00
{
2009-11-17 13:12:43 +00:00
$query .= " FIND_IN_SET( " . $_SESSION [ 'filter' ] . " ,u.user_class) " ;
2006-12-02 04:36:16 +00:00
}
}
2009-08-03 16:40:09 +00:00
// $user_total = db_Count($table, $fields = '(*)',
2010-03-13 18:59:28 +00:00
2009-11-17 13:12:43 +00:00
if ( $_SESSION [ 'filter' ] == e_UC_ADMIN )
2009-10-21 07:31:07 +00:00
{
$this -> fieldpref [] = 'user_perms' ;
2010-03-13 18:59:28 +00:00
}
2008-12-22 03:15:04 +00:00
$qry_insert = 'SELECT u.*, ue.* FROM `#user` AS u LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id ' ;
2009-08-03 16:40:09 +00:00
return ( $query ) ? $qry_insert . " WHERE " . $query . $qry_order : $qry_insert . $qry_order ;
}
function show_existing_users ( $action , $sub_action , $id , $from , $amount )
{
2009-10-21 07:31:07 +00:00
global $mySQLdefaultdb , $pref , $unverified , $userMethods ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
$sql = e107 :: getDb ();
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$tp = e107 :: getParser ();
2010-03-13 18:59:28 +00:00
2011-05-11 11:56:42 +00:00
$e107 = e107 :: getInstance ();
2009-08-03 16:40:09 +00:00
$qry = $this -> get_search_query ();
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
$this -> fieldpref = array_unique ( $this -> fieldpref );
2011-05-11 22:25:02 +00:00
2009-08-03 16:40:09 +00:00
$text = " <div> " . $this -> show_search_filter ();
2012-04-18 21:07:20 +00:00
// echo "<br />qry=".$qry;
$user_total = $sql -> db_Select_gen ( $qry );
if ( $users = $sql -> db_Select_gen ( $qry . " LIMIT " . $from . " , " . $amount ))
2008-12-21 11:07:58 +00:00
{
2009-10-21 07:31:07 +00:00
$text .= "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
2009-07-08 06:58:00 +00:00
< fieldset id = 'core-users-list' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' > " .
2009-10-21 07:31:07 +00:00
$frm -> colGroup ( $this -> fields , $this -> fieldpref ) .
2012-04-18 21:07:20 +00:00
$frm -> thead ( $this -> fields , $this -> fieldpref , " action=main&sub=[FIELD]&id=[ASC]&filter= " . intval ( $_GET [ 'filter' ]) . '&srch=' . $_GET [ 'srch' ] . " &frm=[FROM] " ) .
2009-10-21 07:31:07 +00:00
" <tbody> \n " ;
2010-03-13 18:59:28 +00:00
2008-12-22 03:15:04 +00:00
while ( $row = $sql -> db_Fetch ())
2008-12-21 11:07:58 +00:00
{
2009-07-22 17:04:59 +00:00
2011-05-11 11:56:42 +00:00
$text .= " <tr> " ;
$text .= ( isset ( $this -> fields [ 'checkboxes' ])) ? " <td class='center' > " . $frm -> checkbox ( 'user_selected[]' , $row [ 'user_id' ]) . " </td> " : " " ;
$text .= " <td class='center' style='width:5%; text-align:center' > { $row [ 'user_id' ] } </td> " ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
foreach ( $this -> fieldpref as $disp )
2008-12-21 11:07:58 +00:00
{
2010-03-13 18:59:28 +00:00
$class = vartrue ( $this -> fields [ $disp ][ 'thclass' ]) ? " class=' " . $this -> fields [ $disp ][ 'thclass' ] . " ' " : " " ;
2009-10-21 07:31:07 +00:00
$text .= " <td " . $class . " style='white-space:nowrap'> " . $this -> renderValue ( $disp , $row ) . " </td> \n " ;
2008-12-21 11:07:58 +00:00
}
2010-03-13 18:59:28 +00:00
2011-05-11 11:56:42 +00:00
$text .= ( isset ( $this -> fields [ 'checkboxes' ])) ? " <td style='width:30%' class='center'> " . $this -> showUserOptions ( $row ) . " </td> " : " " ;
$text .= " </tr> \n " ;
2006-12-02 04:36:16 +00:00
}
2010-03-13 18:59:28 +00:00
2009-07-22 17:04:59 +00:00
$text .= " </tbody>
</ table >
2010-03-13 18:59:28 +00:00
2009-07-22 17:04:59 +00:00
< div class = 'buttons-bar center' > " . $this->show_batch_options ();
2012-04-18 21:07:20 +00:00
// $users = (e_QUERY != "unverified") ? $sql->db_Count("user") : $unverified;
2010-03-13 18:59:28 +00:00
2012-04-18 21:07:20 +00:00
if ( $user_total > $amount )
2008-12-21 11:07:58 +00:00
{
2012-04-18 21:07:20 +00:00
$parms = " { $user_total } , { $amount } , { $from } , " ;
// $parms .= e_SELF."?".(e_QUERY ? "action=".$action."&sub=".$sub_action."&id=".$id : "action=main&sub=user_id&id=desc&frm=")."[FROM]";
$parms .= e_SELF . " ?action= " . $action . " &sub= " . $sub_action . " &id= " . $id . " &filter= " . $_GET [ 'filter' ] . " &srch= " . $_GET [ 'srch' ] . " &frm=[FROM] " ;
2009-07-22 17:04:59 +00:00
$text .= $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2008-12-21 11:07:58 +00:00
}
2010-03-13 18:59:28 +00:00
2009-07-23 06:55:39 +00:00
if ( $action == " unverified " )
2008-12-21 11:07:58 +00:00
{
2009-10-21 07:31:07 +00:00
$qry = ( e_QUERY ) ? " ? " . e_QUERY : " " ;
2009-07-22 17:04:59 +00:00
$text .= "
< form method = 'post' action = '".e_SELF.$qry."' > " ;
2009-07-23 06:55:39 +00:00
if ( $pref [ 'mail_bounce_pop3' ] != '' )
{
2009-07-22 17:04:59 +00:00
$text .= " <input type='submit' class='button' name='check_bounces' value= \" " . USRLAN_143 . " \" /> \n " ;
}
$text .= " <input type='submit' class='button' name='resend_to_all' value= \" " . USRLAN_144 . " \" />
</ form > " ;
2008-12-21 11:07:58 +00:00
}
2009-07-22 17:04:59 +00:00
$text .= " </div> " ;
}
$text .= " </fieldset></form>
2006-12-02 04:36:16 +00:00
</ div > " ;
2012-04-18 21:07:20 +00:00
// echo "<br />amount=".$amount;
2010-05-14 18:45:51 +00:00
$emessage = eMessage :: getInstance ();
2009-10-21 07:31:07 +00:00
2009-11-17 13:12:43 +00:00
$total_cap = ( isset ( $_GET [ 'srch' ])) ? $user_total : $users ;
2011-05-11 11:56:42 +00:00
$caption = LAN_USER_LIST . " (total: $total_cap ) " ;
2009-07-23 06:55:39 +00:00
$ns -> tablerender ( $caption , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
2009-10-21 07:31:07 +00:00
function renderValue ( $key , $row )
{
$frm = e107 :: getForm ();
$e107 = e107 :: getInstance ();
$type = $this -> fields [ $key ][ 'type' ];
$pref = e107 :: getConfig () -> getPref ();
2009-11-12 05:11:47 +00:00
$prm = e107 :: getUserPerms ();
2010-03-13 18:59:28 +00:00
switch ( $key ) // switch based on field.
2009-10-21 07:31:07 +00:00
{
case 'user_class' :
if ( $row [ 'user_class' ])
{
$tmp = explode ( " , " , $row [ 'user_class' ]);
while ( list ( $key , $class_id ) = each ( $tmp ))
{
2010-03-13 18:59:28 +00:00
$text .= $frm -> uc_label ( $class_id ) . " <br /> \n " ;
2009-10-21 07:31:07 +00:00
}
return $text ;
}
else
{
return " " ;
}
break ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
case 'user_ip' :
2012-01-02 22:06:22 +00:00
return e107 :: getIPHandler () -> ipDecode ( $row [ 'user_ip' ]);
2009-10-21 07:31:07 +00:00
break ;
case 'user_status' :
return $this -> showUserStatus ( $row );
break ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
case 'user_name' :
2011-12-09 02:08:04 +00:00
return " <a href=' " . $e107 -> url -> create ( 'user/profile/view' , 'name=' . $row [ 'user_name' ] . '&id=' . $row [ 'user_id' ]) . " '> { $row [ 'user_name' ] } </a> " ;
2009-10-21 07:31:07 +00:00
break ;
2010-03-13 18:59:28 +00:00
case 'user_perms' : //TODO display link to popup window with editable perms.
// return $row[$key].' ';
2009-11-12 01:53:16 +00:00
return $prm -> renderPerms ( $row [ $key ], $row [ 'user_id' ]);
2009-10-21 07:31:07 +00:00
break ;
2010-03-13 18:59:28 +00:00
2010-02-07 18:32:35 +00:00
case 'user_ban' :
return ( $row [ $key ] == 1 ) ? ADMIN_TRUE_ICON : '' ; // We may want to show more of the status later
break ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
}
2010-03-13 18:59:28 +00:00
switch ( $type ) // switch based on type.
2009-10-21 07:31:07 +00:00
{
case 'date' :
return ( $row [ $key ]) ? strftime ( $pref [ 'shortdate' ], $row [ $key ]) . ' ' : ' ' ;
break ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
case 'boolean' :
return ( $row [ $key ] == 1 ) ? ADMIN_TRUE_ICON : '' ;
break ;
case 'user_status' :
return $this -> showUserStatus ( $row );
2010-03-13 18:59:28 +00:00
break ;
2009-10-21 07:31:07 +00:00
}
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
return $row [ $key ] . ' ' ;
2010-03-13 18:59:28 +00:00
2009-10-21 07:31:07 +00:00
}
2009-07-23 06:55:39 +00:00
function show_batch_options ()
2009-07-22 17:04:59 +00:00
{
2011-05-11 22:25:02 +00:00
if ( ! getperms ( '4|U0' ))
2011-05-11 11:56:42 +00:00
{
return ;
}
2009-08-19 21:33:20 +00:00
$e107 = e107 :: getInstance ();
$classObj = $e107 -> getUserClass ();
$frm = new e_form ();
$classes = $classObj -> uc_get_classlist ();
2010-03-13 18:59:28 +00:00
2009-09-22 19:43:34 +00:00
2009-08-14 23:22:38 +00:00
$assignClasses = array (); // Userclass list of userclasses that can be assigned
2009-07-23 06:55:39 +00:00
foreach ( $classes as $key => $val )
{
2009-08-19 21:33:20 +00:00
if ( $classObj -> isEditableClass ( $key ))
2009-07-22 17:04:59 +00:00
{
2009-08-14 23:22:38 +00:00
$assignClasses [ $key ] = $classes [ $key ];
2009-07-22 17:04:59 +00:00
}
2009-07-23 06:55:39 +00:00
}
2009-09-22 19:43:34 +00:00
unset ( $assignClasses [ 0 ]);
2010-03-13 18:59:28 +00:00
2009-08-14 23:22:38 +00:00
$removeClasses = $assignClasses ; // Userclass list of userclasses that can be removed
$removeClasses [ 0 ] = array ( 'userclass_name' => array ( 'userclass_id' => 0 , 'userclass_name' => USRLAN_220 ));
2010-03-13 18:59:28 +00:00
2009-11-23 01:17:29 +00:00
if ( count ( $assignClasses ))
{
$uclasses = array (
'userclass' => array ( 'Assign Userclass...' , $assignClasses ),
'remuserclass' => array ( 'Remove Userclass..' , $removeClasses )
);
}
else
{
2010-03-13 18:59:28 +00:00
$uclasses = FALSE ;
}
2009-11-23 01:17:29 +00:00
return $frm -> batchoptions (
array (
'ban_selected' => USRLAN_30 ,
'unban_selected' => USRLAN_33 ,
'activate_selected' => USRLAN_32 ,
'delete_selected' => LAN_DELETE
2010-03-13 18:59:28 +00:00
), $uclasses
2009-11-23 01:17:29 +00:00
);
2009-07-22 17:04:59 +00:00
}
2008-01-01 12:38:05 +00:00
2009-07-23 06:55:39 +00:00
2008-12-22 03:15:04 +00:00
function show_options ( $action )
2008-01-01 12:38:05 +00:00
{
2009-08-05 22:03:23 +00:00
// Please duplicate any changes to this function also in /usersettings.php. (at the end of the script)
2008-12-22 03:15:04 +00:00
// ##### Display options
if ( $action == '' )
2007-09-28 20:50:23 +00:00
{
2008-12-22 03:15:04 +00:00
$action = 'main' ;
2006-12-02 04:36:16 +00:00
}
2011-05-11 11:56:42 +00:00
show_admin_menu ( LAN_USER_OPTIONS , $action , $this -> menuOptions );
2006-12-02 04:36:16 +00:00
}
2008-01-01 12:38:05 +00:00
2008-12-22 03:15:04 +00:00
function show_prefs ()
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
global $ns , $pref , $e_userclass ;
if ( ! is_object ( $e_userclass ))
$e_userclass = new user_class ;
$pref [ 'memberlist_access' ] = varset ( $pref [ 'memberlist_access' ], e_UC_MEMBER );
2006-12-02 04:36:16 +00:00
$text = " <div style='text-align:center'>
2008-12-22 03:15:04 +00:00
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2008-12-22 03:15:04 +00:00
< colgroup >
< col style = 'width:60%' />
< col style = 'width:40%' />
</ colgroup >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_44. " :</ td >
2009-07-23 06:55:39 +00:00
< td > " .( $pref['avatar_upload'] ? " < input name = 'avatar_upload' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'avatar_upload' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'avatar_upload' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'avatar_upload' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO).(!FILE_UPLOADS ? " < span class = 'smalltext' > ( " .USRLAN_58. " ) </ span > " : " " ). "
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_53. " :</ td >
2009-07-23 06:55:39 +00:00
< td > " .( $pref['photo_upload'] ? " < input name = 'photo_upload' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'photo_upload' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'photo_upload' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'photo_upload' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO).(!FILE_UPLOADS ? " < span class = 'smalltext' > ( " .USRLAN_58. " ) </ span > " : " " ). "
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_47. " :</ td >
< td >
2008-12-22 03:15:04 +00:00
< input class = 'tbox' type = 'text' name = 'im_width' size = '10' value = '".$pref[' im_width ']."' maxlength = '5' /> ( " .USRLAN_48. " )
</ td ></ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_49. " :</ td >
< td >
2008-12-22 03:15:04 +00:00
< input class = 'tbox' type = 'text' name = 'im_height' size = '10' value = '".$pref[' im_height ']."' maxlength = '5' /> ( " .USRLAN_50. " )
</ td ></ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_126. " :</ td >
2009-07-23 06:55:39 +00:00
< td style = 'vertical-align:top' > " .( $pref['profile_rate'] ? " < input name = 'profile_rate' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_rate' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'profile_rate' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_rate' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_127. " :</ td >
2009-07-23 06:55:39 +00:00
< td style = 'vertical-align:top' > " .( $pref['profile_comments'] ? " < input name = 'profile_comments' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_comments' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'profile_comments' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'profile_comments' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td style = 'vertical-align:top' > " .USRLAN_133. " :< br />< span class = 'smalltext' > " .USRLAN_134. " </ span ></ td >
2009-07-23 06:55:39 +00:00
< td style = 'vertical-align:top' > " .( $pref['force_userupdate'] ? " < input name = 'force_userupdate' type = 'radio' value = '1' checked = 'checked' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'force_userupdate' type = 'radio' value = '0' /> " .LAN_NO : " < input name = 'force_userupdate' type = 'radio' value = '1' /> " .LAN_YES. " & nbsp ; & nbsp ; < input name = 'force_userupdate' type = 'radio' value = '0' checked = 'checked' /> " .LAN_NO). "
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td style = 'vertical-align:top' > " .USRLAN_93. " < br />< span class = 'smalltext' > " .USRLAN_94. " </ span ></ td >
< td >
2008-12-22 03:15:04 +00:00
< input class = 'tbox' type = 'text' name = 'del_unv' size = '10' value = '".$pref[' del_unv ']."' maxlength = '5' /> " .USRLAN_95. "
</ td ></ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_130. " < br />< span class = 'smalltext' > " .USRLAN_131. " </ span ></ td >
< td >& nbsp ;
2008-12-22 03:15:04 +00:00
< input type = 'checkbox' name = 'track_online' value = '1' " .( $pref['track_online'] ? " checked = 'checked' " : " " ). " /> " .USRLAN_132. " & nbsp ; & nbsp ;
</ td >
</ tr >
< tr >
2009-07-08 06:58:00 +00:00
< td > " .USRLAN_146. " :</ td >
< td >< select name = 'memberlist_access' class = 'tbox' > \n " ;
2009-07-23 06:55:39 +00:00
$text .= $e_userclass -> vetted_tree ( 'memberlist_access' , array ( $e_userclass , 'select' ), $pref [ 'memberlist_access' ], " public,member,guest,admin,main,classes,nobody " );
2008-01-01 18:18:12 +00:00
$text .= " </select>
2008-12-22 03:15:04 +00:00
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
2008-12-21 11:07:58 +00:00
2008-12-22 03:15:04 +00:00
< tr >
2009-07-08 06:58:00 +00:00
< td style = 'vertical-align:top' > " .USRLAN_190. " < br />< span class = 'smalltext' > " .USRLAN_191. " </ span ></ td >
< td >
2008-12-22 03:15:04 +00:00
< input class = 'tbox' type = 'text' name = 'user_new_period' size = '10' value = '".varset($pref[' user_new_period '],0)."' maxlength = '5' /> " .USRLAN_192. "
</ td ></ tr >
2008-12-21 11:07:58 +00:00
2008-12-22 03:15:04 +00:00
< tr >
2009-07-08 06:58:00 +00:00
< td colspan = '2' class = 'center button-bar' >
2008-12-22 03:15:04 +00:00
< input class = 'button' type = 'submit' name = 'update_options' value = '".USRLAN_51."' />
</ td ></ tr >
2006-12-02 04:36:16 +00:00
2008-12-22 03:15:04 +00:00
</ table ></ form ></ div > " ;
2009-07-23 06:55:39 +00:00
$emessage = & eMessage :: getInstance ();
2009-07-22 17:04:59 +00:00
$ns -> tablerender ( USRLAN_52 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-01-01 12:38:05 +00:00
2009-07-23 06:55:39 +00:00
function show_message ( $message , $type = '' )
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
$emessage = & eMessage :: getInstance ();
$emessage -> add ( $message , E_MESSAGE_SUCCESS );
2006-12-02 04:36:16 +00:00
}
2008-01-01 12:38:05 +00:00
2008-12-22 03:15:04 +00:00
function show_prune ()
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
global $ns , $sql ;
$unactive = $sql -> db_Count ( " user " , " (*) " , " WHERE user_ban=2 " );
$bounced = $sql -> db_Count ( " user " , " (*) " , " WHERE user_ban=3 " );
$older30 = $sql -> db_Count ( " user " , " (*) " , " WHERE user_ban=2 AND (user_join < " . strtotime ( " -30 days " ) . " ) " );
2006-12-02 04:36:16 +00:00
$text = " <div style='text-align:center'><br /><br />
2008-12-22 03:15:04 +00:00
< form method = 'post' action = '".e_SELF."' >
< table style = '".ADMIN_WIDTH."' class = 'fborder' >
< tr >
< td class = 'forumheader3' style = 'text-align:center' >< br /> " .LAN_DELETE. " :& nbsp ;
< select class = 'tbox' name = 'prune_type' > " ;
2009-07-23 06:55:39 +00:00
$prune_type = array ( 2 => USRLAN_138 . " [ " . $unactive . " ] " , '30' => USRLAN_138 . " ( " . USRLAN_219 . " ) [ " . $older30 . " ] " , 3 => USRLAN_145 . " [ " . $bounced . " ] " );
foreach ( $prune_type as $key => $val )
{
2008-12-22 03:15:04 +00:00
$text .= " <option value=' $key '> { $val } </option> \n " ;
}
2006-12-02 04:36:16 +00:00
$text .= " </select><br /><br /></td>
2008-12-22 03:15:04 +00:00
</ tr >
< tr >
< td class = 'forumheader' style = 'text-align:center' >
< input class = 'button' type = 'submit' name = 'prune' value = \ " " . USRLAN_55 . " \" />
</ td >
</ tr >
</ table >
</ form >
</ div > " ;
2009-07-23 06:55:39 +00:00
$emessage = & eMessage :: getInstance ();
2009-07-22 17:04:59 +00:00
$ns -> tablerender ( USRLAN_55 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-01-01 12:38:05 +00:00
2009-11-12 01:53:16 +00:00
// Quick Add a new user - may be passed existing data if there was an entry error on first pass
2009-07-22 17:04:59 +00:00
function user_add ( $user_data )
2008-01-01 12:38:05 +00:00
{
2009-11-12 02:09:03 +00:00
global $rs , $pref , $e_userclass ;
2010-03-13 18:59:28 +00:00
2009-11-12 05:11:47 +00:00
$prm = e107 :: getUserPerms ();
2009-11-12 01:53:16 +00:00
$list = $prm -> getPermList ();
2009-11-12 02:09:03 +00:00
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2010-03-13 18:59:28 +00:00
//TODO Better Password generation.
// ie. a "Generate" button, which will place the text into the text field automatically.
2009-07-23 06:55:39 +00:00
if ( ! is_object ( $e_userclass ))
$e_userclass = new user_class ;
$text = " <div> " . $rs -> form_open ( " post " , e_SELF . ( e_QUERY ? '?' . e_QUERY : '' ), " adduserform " ) . "
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-22 17:04:59 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2008-12-22 03:15:04 +00:00
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_61. " </ td >
< td >
" . $rs->form_text ('username',40,varset( $user_data['user_name'] , " " ),varset( $pref['displayname_maxlength'] ,15)). "
</ td >
2008-12-22 03:15:04 +00:00
</ tr >
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_128. " </ td >
< td >
" . $rs->form_text ('loginname',40,varset( $user_data['user_loginname'] , " " ),varset( $pref['loginname_maxlength'] ,30)). " & nbsp ; & nbsp ;
2009-11-12 02:09:03 +00:00
" . $frm->checkbox_label (USRLAN_170,'generateloginname', 1,varset( $pref['predefinedLoginName'] ,false)). "
2009-11-12 01:53:16 +00:00
</ td >
2008-12-22 03:15:04 +00:00
</ tr >
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_129. " </ td >
< td >
" . $rs->form_text ( " realname " ,40,varset( $user_data['user_login'] , " " ),30). "
</ td >
2008-12-22 03:15:04 +00:00
</ tr >
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_62. " </ td >
2012-05-31 06:07:33 +00:00
< td > " . $frm->password ('password','',20,array('size'=>40,'class'=>'tbox e-password-admin')). " </ td >
2012-05-23 11:38:49 +00:00
</ tr > " ;
2012-06-04 09:08:54 +00:00
2012-05-23 11:38:49 +00:00
$text .= "
2008-12-22 03:15:04 +00:00
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_63. " </ td >
< td >
" . $rs->form_password ( " password2 " ,40, " " ,20). "
</ td >
2012-05-23 11:38:49 +00:00
</ tr > " ;
2012-06-04 09:08:54 +00:00
2010-03-13 18:59:28 +00:00
2012-05-23 11:38:49 +00:00
$text .= "
2008-12-22 03:15:04 +00:00
< tr >
2009-11-12 01:53:16 +00:00
< td > " .USRLAN_64. " </ td >
< td >
" . $rs->form_text ( " email " ,60,varset( $user_data['user_email'] , " " ),100). "
</ td >
2009-11-12 02:09:03 +00:00
</ tr >
< tr style = 'vertical-align:top' >
< td > Require Confirmation </ td >
< td class = 'center' > " . $frm->checkbox_label (USRLAN_181,'sendconfemail', 1). " </ td >
</ tr > " ;
2010-03-13 18:59:28 +00:00
2009-11-12 02:09:03 +00:00
//FIXME check what this is doing exactly.. is it a confirmation email (activation link) or just a notification?
// Give drop-down option to: 1) Notify User and Activate. 2) Notify User and require activation. 3) Don't Notify
2010-03-13 18:59:28 +00:00
2009-07-23 06:55:39 +00:00
if ( ! isset ( $user_data [ 'user_class' ]))
$user_data [ 'user_class' ] = varset ( $pref [ 'initial_user_classes' ], '' );
$temp = $e_userclass -> vetted_tree ( 'class' , array ( $e_userclass , 'checkbox_desc' ), $user_data [ 'user_class' ], 'classes' );
2010-03-13 18:59:28 +00:00
2008-12-22 03:15:04 +00:00
if ( $temp )
2008-01-01 12:38:05 +00:00
{
2008-12-22 03:15:04 +00:00
$text .= " <tr style='vertical-align:top'>
2009-07-08 06:58:00 +00:00
< td >
2008-12-22 03:15:04 +00:00
" .USRLAN_120. "
2009-11-12 01:53:16 +00:00
</ td >< td >
< a href = '#set_class' class = 'e-expandit' > " .USRLAN_120. " </ a >
< div class = 'e-hideme' id = 'set_class' >
{ $temp }
</ div ></ td >
2008-12-22 03:15:04 +00:00
</ tr > \n " ;
2006-12-02 04:36:16 +00:00
}
2010-03-13 18:59:28 +00:00
// Make Admin.
2009-11-12 01:53:16 +00:00
$text .= " <tr>
< td > " .USRLAN_35. " </ td >
< td >
< a href = '#set_perms' class = 'e-expandit' > Set Permissions </ a >
< div class = 'e-hideme' id = 'set_perms' > \n " ;
2011-05-11 11:56:42 +00:00
$text .= $prm -> renderPermTable ( 'grouped' );
2009-11-12 01:53:16 +00:00
$text .= " </div></td>
</ tr > \n " ;
2010-03-13 18:59:28 +00:00
2006-12-02 04:36:16 +00:00
$text .= "
2010-03-13 18:59:28 +00:00
2009-07-22 17:04:59 +00:00
</ table >
< div class = 'buttons-bar center' >
2009-07-08 06:58:00 +00:00
< input class = 'button' type = 'submit' name = 'adduser' value = '".USRLAN_60."' />
< input type = 'hidden' name = 'ac' value = '".md5(ADMINPWCHANGE)."' />
2009-07-22 17:04:59 +00:00
</ div >
2008-12-22 03:15:04 +00:00
</ form >
</ div >
" ;
2009-07-23 06:55:39 +00:00
$emessage = & eMessage :: getInstance ();
2009-11-12 02:09:03 +00:00
$ns -> tablerender ( USRLAN_59 , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2012-06-04 09:08:54 +00:00
*/
2009-07-23 06:55:39 +00:00
function resend ( $id , $key , $name , $email , $lfile = '' )
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
global $sql , $mailheader_e107id , $admin_log ;
$id = ( int ) $id ;
2008-12-22 03:15:04 +00:00
// Check for a Language field, and if present, send the email in the user's language.
2009-07-23 06:55:39 +00:00
if ( $lfile == " " )
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Select ( 'user_extended' , 'user_language' , 'user_extended_id = ' . $id ))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
$row = $sql -> db_Fetch ();
2008-12-22 03:15:04 +00:00
$lfile = e_LANGUAGEDIR . $row [ 'user_language' ] . '/lan_signup.php' ;
}
}
2009-07-23 06:55:39 +00:00
if ( is_readable ( $lfile ))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
require_once ( $lfile );
2008-12-22 03:15:04 +00:00
}
else
{
$row [ 'user_language' ] = e_LANGUAGE ;
2009-07-18 15:14:38 +00:00
//@FIXME use array
2009-07-23 06:55:39 +00:00
require_once ( e_LANGUAGEDIR . e_LANGUAGE . " /lan_signup.php " );
2008-12-22 03:15:04 +00:00
}
2009-07-23 06:55:39 +00:00
$return_address = ( substr ( SITEURL , - 1 ) == " / " ) ? SITEURL . " signup.php?activate. " . $id . " . " . $key : SITEURL . " /signup.php?activate. " . $id . " . " . $key ;
2009-07-06 07:50:44 +00:00
$message = LAN_EMAIL_01 . " " . $name . " \n \n " . LAN_SIGNUP_24 . " " . SITENAME . " . \n " . LAN_SIGNUP_21 . " \n \n " ;
2009-07-23 06:55:39 +00:00
$message .= $return_address . " \n \n " . SITENAME . " \n " . SITEURL ;
2008-12-22 03:15:04 +00:00
$mailheader_e107id = $id ;
2009-07-23 06:55:39 +00:00
require_once ( e_HANDLER . " mail.php " );
if ( sendemail ( $email , LAN_404 . " " . SITENAME , $message ))
2008-01-01 12:38:05 +00:00
{
2009-07-23 06:55:39 +00:00
// echo str_replace("\n","<br>",$message);
2008-12-22 03:15:04 +00:00
$admin_log -> log_event ( 'USET_11' , str_replace ( array ( '--ID--' , '--NAME--' , '--EMAIL--' ), array ( $id , $name , $email ), USRLAN_167 ), E_LOG_INFORMATIVE );
$this -> show_message ( USRLAN_140 . " : <a href='mailto: " . $email . " ?body= " . $return_address . " ' title= \" " . LAN_USER_08 . " \" > " . $name . " </a> ( " . $row [ 'user_language' ] . " ) " );
}
else
{
$this -> show_message ( USRLAN_141 . " : " . $name );
}
2006-12-02 04:36:16 +00:00
}
2009-07-23 06:55:39 +00:00
// ------- Ban User. --------------
2012-06-04 09:08:54 +00:00
/*
2009-07-22 17:04:59 +00:00
function user_ban ( $user_id )
{
global $sql , $user , $admin_log ;
2009-07-23 06:55:39 +00:00
// $sub_action = $user_id;
$sql -> db_Select ( " user " , " * " , " user_id=' " . $user_id . " ' " );
$row = $sql -> db_Fetch ();
if (( $row [ 'user_perms' ] == " 0 " ) || ( $row [ 'user_perms' ] == " 0. " ))
{
$this -> show_message ( USRLAN_7 );
}
else
{
if ( $sql -> db_Update ( " user " , " user_ban='1' WHERE user_id=' " . $user_id . " ' " ))
{
$admin_log -> log_event ( 'USET_05' , str_replace ( array ( '--UID--' , '--NAME--' ), array ( $row [ 'user_id' ], $row [ 'user_name' ]), USRLAN_161 ), E_LOG_INFORMATIVE );
$this -> show_message ( USRLAN_8 );
}
if ( trim ( $row [ 'user_ip' ]) == " " )
2009-07-22 17:04:59 +00:00
{
2009-07-23 06:55:39 +00:00
$this -> show_message ( USRLAN_135 );
2009-07-22 17:04:59 +00:00
}
else
{
2011-01-13 20:57:18 +00:00
if ( $sql -> db_Count ( 'user' , '(*)' , " WHERE user_ip = ' { $row [ 'user_ip' ] } ' AND user_ban=0 AND user_id <> { $user_id } " ) > 0 )
2009-07-22 17:04:59 +00:00
{
2011-01-13 14:48:58 +00:00
// Other unbanned users have same IP address
2009-07-23 06:55:39 +00:00
$this -> show_message ( str_replace ( " { IP} " , $row [ 'user_ip' ], USRLAN_136 ));
2009-07-22 17:04:59 +00:00
}
else
{
2012-01-02 22:06:22 +00:00
if ( e107 :: getIPHandler () -> add_ban ( 6 , USRLAN_149 . $row [ 'user_name' ] . '/' . $row [ 'user_loginname' ], $row [ 'user_ip' ], USERID ))
2009-07-23 06:55:39 +00:00
{
// Successful IP ban
$this -> show_message ( str_replace ( " { IP} " , $row [ 'user_ip' ], USRLAN_137 ));
2009-07-22 17:04:59 +00:00
}
else
{
2009-07-23 06:55:39 +00:00
// IP address on whitelist
$this -> show_message ( str_replace ( " { IP} " , $row [ 'user_ip' ], USRLAN_150 ));
2009-07-22 17:04:59 +00:00
}
}
}
2009-07-23 06:55:39 +00:00
}
$action = " main " ;
if ( ! $sub_action )
{
$sub_action = " user_id " ;
}
2009-07-22 17:04:59 +00:00
}
2012-06-04 09:08:54 +00:00
*/
2009-07-23 06:55:39 +00:00
2008-01-01 12:38:05 +00:00
function resend_to_all ()
{
2009-07-23 06:55:39 +00:00
global $sql , $pref , $sql3 , $admin_log ;
2008-12-22 03:15:04 +00:00
$count = 0 ;
$pause_count = 1 ;
$pause_amount = ( $pref [ 'mail_pause' ]) ? $pref [ 'mail_pause' ] : 10 ;
$pause_time = ( $pref [ 'mail_pausetime' ]) ? $pref [ 'mail_pausetime' ] : 1 ;
2009-07-23 06:55:39 +00:00
if ( $sql -> db_Select_gen ( 'SELECT user_language FROM `#user_extended` LIMIT 1' ))
2008-12-22 03:15:04 +00:00
{
$query = " SELECT u.*, ue.* FROM `#user` AS u LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id WHERE u.user_ban = 2 ORDER BY u.user_id DESC " ;
}
else
2008-01-01 12:38:05 +00:00
{
2008-12-22 03:15:04 +00:00
$query = 'SELECT * FROM `#user` WHERE user_ban=2' ;
}
2009-07-23 15:21:41 +00:00
$sql3 = e107 :: getDb ( 'sql3' );
2009-07-23 06:55:39 +00:00
$sql3 -> db_Select_gen ( $query );
while ( $row = $sql3 -> db_Fetch ())
2008-12-22 03:15:04 +00:00
{
echo $row [ 'user_id' ] . " " . $row [ 'user_sess' ] . " " . $row [ 'user_name' ] . " " . $row [ 'user_email' ] . " <br /> " ;
$this -> resend ( $row [ 'user_id' ], $row [ 'user_sess' ], $row [ 'user_name' ], $row [ 'user_email' ], $row [ 'user_language' ]);
2009-07-23 06:55:39 +00:00
if ( $pause_count > $pause_amount )
2008-12-22 03:15:04 +00:00
{
sleep ( $pause_time );
$pause_count = 1 ;
}
sleep ( 1 );
$pause_count ++ ;
$count ++ ;
}
if ( $count )
{
$admin_log -> log_event ( 'USET_12' , str_replace ( '--COUNT--' , $count , USRLAN_168 ), E_LOG_INFORMATIVE );
}
2006-12-02 04:36:16 +00:00
}
2007-08-06 19:35:17 +00:00
2008-12-22 03:15:04 +00:00
// ---------------------------------------------------------------------
// Bounce handling
// ---------------------------------------------------------------------
// $bounce_act has the task to perform:
// 'first_check' - initial read of list of bounces
// 'delnonbounce' - delete any emails that aren't bounces
// 'clearemailbounce' - delete email address for any user whose emails bounced
// 'delchecked' - delete the emails whose comma-separated IDs are in $bounce_arr
// 'delall' - delete all bounced emails
2009-07-23 06:55:39 +00:00
function check_bounces ( $bounce_act = 'first_check' , $bounce_arr = '' )
2007-08-06 19:35:17 +00:00
{
2008-12-22 03:15:04 +00:00
global $sql , $pref ;
2009-07-23 06:55:39 +00:00
include ( e_HANDLER . 'pop3_class.php' );
if ( ! trim ( $bounce_act ))
{
$bounce_act = 'first_check' ;
}
2008-12-22 03:15:04 +00:00
// echo "Check bounces. Action: {$bounce_act}; Entries: {$bounce_arr}<br />";
2009-07-23 06:55:39 +00:00
$obj = new receiveMail ( $pref [ 'mail_bounce_user' ], $pref [ 'mail_bounce_pass' ], $pref [ 'mail_bounce_email' ], $pref [ 'mail_bounce_pop3' ], varset ( $pref [ 'mail_bounce_type' ], 'pop3' ));
2008-12-22 03:15:04 +00:00
$del_count = 0 ;
2009-07-23 06:55:39 +00:00
if ( $bounce_act != 'first_check' )
{
// Must do some deleting
2008-12-22 03:15:04 +00:00
$obj -> connect ();
2009-07-23 06:55:39 +00:00
$tot = $obj -> getTotalMails ();
2008-12-22 03:15:04 +00:00
$del_array = explode ( ',' , $bounce_arr );
2009-07-23 06:55:39 +00:00
for ( $i = 1 ; $i <= $tot ; $i ++ )
{
// Scan all emails; delete current one if meets the criteria
$dodel = false ;
2008-12-22 03:15:04 +00:00
switch ( $bounce_act )
2007-09-28 20:50:23 +00:00
{
2008-12-22 03:15:04 +00:00
case 'delnonbounce' :
2009-07-23 06:55:39 +00:00
$head = $obj -> getHeaders ( $i );
$dodel = ( ! $head [ 'bounce' ]);
break ;
2008-12-22 03:15:04 +00:00
case 'clearemailbounce' :
2009-07-23 06:55:39 +00:00
if ( ! in_array ( $i , $del_array ))
break ;
$head = $obj -> getHeaders ( $i );
if ( $head [ 'bounce' ])
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
if ( preg_match ( " /[ \ ._a-zA-Z0-9-]+@[ \ ._a-zA-Z0-9-]+/i " , $obj -> getBody ( $i ), $result ))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
$usr_email = trim ( $result [ 0 ]);
}
if ( $sql -> db_Select ( 'user' , 'user_id, user_name, user_email' , " user_email=' " . $usr_email . " ' " ))
{
$row = $sql -> db_Fetch ();
if ( $sql -> db_Update ( 'user' , " `user_email`='' WHERE `user_id` = ' " . $row [ 'user_id' ] . " ' " ) !== false )
{
2008-12-22 03:15:04 +00:00
// echo "Deleting user email {$row['user_email']} for user {$row['user_name']}, id={$row['user_id']}<br />";
2009-07-23 06:55:39 +00:00
$dodel = true ;
}
2008-12-22 03:15:04 +00:00
}
}
2009-07-23 06:55:39 +00:00
break ;
2008-12-22 03:15:04 +00:00
case 'delall' :
2009-07-23 06:55:39 +00:00
$dodel = true ;
break ;
2008-12-22 03:15:04 +00:00
case 'delchecked' :
2009-07-23 06:55:39 +00:00
$dodel = in_array ( $i , $del_array );
break ;
2007-09-28 20:50:23 +00:00
}
2008-12-22 03:15:04 +00:00
if ( $dodel )
{
2009-07-23 06:55:39 +00:00
// echo "Delete email ID {$i}<br />";
2008-12-22 03:15:04 +00:00
$obj -> deleteMails ( $i );
2009-07-23 06:55:39 +00:00
$del_count ++ ;
// Keep track of number of emails deleted
2008-12-22 03:15:04 +00:00
}
2009-07-23 06:55:39 +00:00
}
// End - Delete one email
$obj -> close_mailbox ();
// This actually deletes the emails
}
// End of email deletion
2008-12-22 03:15:04 +00:00
// Now list the emails that are left
$obj -> connect ();
2009-07-23 06:55:39 +00:00
$tot = $obj -> getTotalMails ();
$found = false ;
$DEL = ( $pref [ 'mail_bounce_delete' ]) ? true : false ;
2008-12-22 03:15:04 +00:00
$text = " <br /><div><form method='post' action=' " . e_SELF . $qry . " '><table class='fborder' style=' " . ADMIN_WIDTH . " '>
2006-12-02 04:36:16 +00:00
< tr >< td class = 'fcaption' style = 'width:5%' > #</td><td class='fcaption'>e107-id</td><td class='fcaption'>email</td><td class='fcaption'>Subject</td><td class='fcaption'>Bounce</td></tr>\n";
2009-07-23 06:55:39 +00:00
for ( $i = 1 ; $i <= $tot ; $i ++ )
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
$head = $obj -> getHeaders ( $i );
if ( $head [ 'bounce' ])
{
// Its a 'bounce' email
2010-10-28 10:54:33 +00:00
if ( preg_match ( '/.*X-e107-id:(.*)MIME/' , $obj -> getBody ( $i ), $result ))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
if ( $result [ 1 ])
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
$id [ $i ] = intval ( $result [ 1 ]);
// This should be a user ID - but not on special mailers!
2008-12-22 03:15:04 +00:00
// Try and pull out an email address from body - should be the one that failed
2009-07-23 06:55:39 +00:00
if ( preg_match ( " /[ \ ._a-zA-Z0-9-]+@[ \ ._a-zA-Z0-9-]+/i " , $obj -> getBody ( $i ), $result ))
2007-12-09 16:42:23 +00:00
{
2008-12-22 03:15:04 +00:00
$emails [ $i ] = " ' " . $result [ 0 ] . " ' " ;
2007-12-09 16:42:23 +00:00
}
2009-07-23 06:55:39 +00:00
$found = true ;
2008-12-22 03:15:04 +00:00
}
}
2009-07-23 06:55:39 +00:00
elseif ( preg_match ( " /[ \ ._a-zA-Z0-9-]+@[ \ ._a-zA-Z0-9-]+/i " , $obj -> getBody ( $i ), $result ))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
if ( $result [ 0 ] && $result [ 0 ] != $pref [ 'mail_bounce_email' ])
2008-12-22 03:15:04 +00:00
{
$emails [ $i ] = " ' " . $result [ 0 ] . " ' " ;
2009-07-23 06:55:39 +00:00
$found = true ;
2008-12-22 03:15:04 +00:00
}
2009-07-23 06:55:39 +00:00
elseif ( $result [ 1 ] && $result [ 1 ] != $pref [ 'mail_bounce_email' ])
2008-12-22 03:15:04 +00:00
{
$emails [ $i ] = " ' " . $result [ 1 ] . " ' " ;
2009-07-23 06:55:39 +00:00
$found = true ;
2008-12-22 03:15:04 +00:00
}
}
if ( $DEL && $found )
2009-07-23 06:55:39 +00:00
{
// Auto-delete bounced emails once noticed (if option set)
2008-12-22 03:15:04 +00:00
$obj -> deleteMails ( $i );
$del_count ++ ;
}
2008-01-01 12:38:05 +00:00
}
2008-12-22 03:15:04 +00:00
else
2009-07-23 06:55:39 +00:00
{
// Its a warning message or similar
// $id[$i] = ''; // Don't worry about an ID for now
// Try and pull out an email address from body - should be the one that failed
if ( preg_match ( " /[ \ ._a-zA-Z0-9-]+@[ \ ._a-zA-Z0-9-]+/i " , $obj -> getBody ( $i ), $result ))
2008-12-22 03:15:04 +00:00
{
$wmails [ $i ] = " ' " . $result [ 0 ] . " ' " ;
}
2008-01-01 12:38:05 +00:00
}
2009-07-23 06:55:39 +00:00
$text .= " <tr><td class='forumheader3'> " . $i . " </td><td class='forumheader3'> " . $id [ $i ] . " </td><td class='forumheader3'> " . ( isset ( $emails [ $i ]) ? $emails [ $i ] : $wmails [ $i ]) . " </td><td class='forumheader3'> " . $head [ 'subject' ] . " </td><td class='forumheader3'> " . ( $head [ 'bounce' ] ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON );
2008-12-22 03:15:04 +00:00
$text .= " <input type='checkbox' name='delete_email[]' value=' { $i } ' /></td></tr> \n " ;
2007-12-09 16:42:23 +00:00
}
2008-12-22 03:15:04 +00:00
if ( $del_count )
{
$admin_log -> log_event ( 'USET_13' , str_replace ( '--COUNT--' , $del_count , USRLAN_169 ), E_LOG_INFORMATIVE );
}
if ( $tot )
2009-07-23 06:55:39 +00:00
{
// Option to delete emails - only if there are some in the list
2008-12-22 03:15:04 +00:00
$text .= " </table><table style=' " . ADMIN_WIDTH . " '><tr>
2008-07-03 21:23:47 +00:00
< td class = 'forumheader3' style = 'text-align: center;' >< input class = 'button' type = 'submit' name = 'delnonbouncesubmit' value = '".USRLAN_183."' /></ td > \n
< td class = 'forumheader3' style = 'text-align: center;' >< input class = 'button' type = 'submit' name = 'clearemailbouncesubmit' value = '".USRLAN_184."' /></ td > \n
< td class = 'forumheader3' style = 'text-align: center;' >< input class = 'button' type = 'submit' name = 'delcheckedsubmit' value = '".USRLAN_179."' /></ td > \n
< td class = 'forumheader3' style = 'text-align: center;' >< input class = 'button' type = 'submit' name = 'delallsubmit' value = '".USRLAN_180."' /></ td > \n
2007-08-06 19:35:17 +00:00
</ td ></ tr > " ;
2008-12-22 03:15:04 +00:00
}
$text .= " </table></form></div> " ;
array_unique ( $id );
array_unique ( $emails );
$all_ids = implode ( ',' , $id );
$all_emails = implode ( ',' , $emails );
2009-07-23 06:55:39 +00:00
$obj -> close_mailbox ();
// This will actually delete emails
2008-12-22 03:15:04 +00:00
// $tot has total number of emails in the mailbox
2009-07-23 06:55:39 +00:00
$found = count ( $emails );
// $found - Number of bounce emails found
2008-12-22 03:15:04 +00:00
// $del_count has number of emails deleted
2009-07-23 06:55:39 +00:00
// Update bounce status for users
$ed = $sql -> db_Update ( 'user' , " user_ban=3 WHERE (`user_id` IN ( " . $all_ids . " ) OR `user_email` IN ( " . $all_emails . " )) AND user_sess !='' " );
if ( ! $ed )
$ed = '0' ;
$this -> show_message ( str_replace ( array ( '{TOTAL}' , '{DELCOUNT}' , '{DELUSER}' , '{FOUND}' ), array ( $tot , $del_count , $ed , $found ), USRLAN_155 ) . $text );
}
2007-09-28 20:50:23 +00:00
2009-07-23 06:55:39 +00:00
function check_allowed ( $class_id ) // check userclass change is permitted.
{
global $e_userclass ;
if ( ! isset ( $e_userclass -> class_tree [ $class_id ]))
{
header ( " location: " . SITEURL );
exit ;
}
if ( ! getperms ( " 0 " ) && ! check_class ( $e_userclass -> class_tree [ $class_id ][ 'userclass_editclass' ]))
{
header ( " location: " . SITEURL );
exit ;
}
return true ;
2006-12-02 04:36:16 +00:00
}
2007-08-06 19:35:17 +00:00
2009-07-23 06:55:39 +00:00
// ------------------------------------------------------------------------
2012-06-04 09:08:54 +00:00
/*
2009-07-23 06:55:39 +00:00
function show_userclass ( $userid )
{
global $sql , $ns , $e_userclass ;
$sql -> db_Select ( " user " , " * " , " user_id= { $userid } " );
$row = $sql -> db_Fetch ();
$caption = UCSLAN_6 . " <b> " . $row [ 'user_name' ] . " </b> ( " . $row [ 'user_class' ] . " ) " ;
$text = " <div>
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-23 06:55:39 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > " ;
$text .= $e_userclass -> vetted_tree ( 'userclass' , array ( $e_userclass , 'checkbox_desc' ), $row [ 'user_class' ], 'classes' );
$text .= ' </ td ></ tr >
</ table > ' ;
$text .= " <div class='buttons-bar center'>
< input type = 'hidden' name = 'userid' value = '{$userid}' />
< input type = 'checkbox' name = 'notifyuser' value = '1' /> " .UCSLAN_8. " & nbsp ; & nbsp ;
< input class = 'button' type = 'submit' name = 'updateclass' value = '".UCSLAN_7."' />
</ div >
</ form >
</ div > " ;
$ns -> tablerender ( $caption , $text );
}
2012-06-04 09:08:54 +00:00
*/
2009-08-10 15:34:28 +00:00
2009-08-22 21:27:34 +00:00
/*
Appears to be unused function
2009-08-10 15:34:28 +00:00
function user_remuserclass ( $userid , $uclass )
{
global $sql , $sql2 ;
2009-08-22 21:27:34 +00:00
$emessage = & eMessage :: getInstance ();
2009-08-14 23:22:38 +00:00
if ( $uclass [ 0 ] == 0 )
2009-08-10 15:34:28 +00:00
{
2009-08-22 21:27:34 +00:00
if ( $sql -> db_Update ( " user " , " user_class='' WHERE user_id= { $userid } " ) === TRUE )
{
$emessage -> add ( UCSLAN_9 , E_MESSAGE_SUCCESS ); // classes updated;
}
else
{
$emessage -> add ( UCSLAN_9 , E_MESSAGE_SUCCESS ); // classes updated;
}
2009-08-14 23:22:38 +00:00
}
else
{
2009-08-22 21:27:34 +00:00
$eu = new e_userclass ;
if ( $sql -> db_Select ( " user " , " user_id,user_class " , " user_id= { $userid } LIMIT 1 " ))
{
$row = $sql -> db_Fetch ();
$eu -> class_remove ( $uclass [ 0 ], array ( $row [ 'user_id' ] => $row [ 'user_class' ]));
}
$emessage -> add ( UCSLAN_9 , E_MESSAGE_SUCCESS ); // classes updated;
2009-08-10 15:34:28 +00:00
}
}
2009-08-22 21:27:34 +00:00
*/
2009-08-10 15:34:28 +00:00
2009-08-03 16:40:09 +00:00
// Set userclass for user(s).
2012-06-04 09:08:54 +00:00
/*
2009-09-22 19:43:34 +00:00
function user_userclass ( $userid , $uclass , $mode = FALSE )
2009-07-23 06:55:39 +00:00
{
2009-09-22 19:43:34 +00:00
global $admin_log , $e_userclass ;
$sql = e107 :: getDb ();
2010-03-13 18:59:28 +00:00
2009-07-23 06:55:39 +00:00
$remuser = true ;
$emessage = & eMessage :: getInstance ();
2007-08-06 19:35:17 +00:00
2009-09-22 19:43:34 +00:00
if ( $_POST [ 'notifyuser' ] || $mode !== 'clear' )
2009-07-23 06:55:39 +00:00
{
$sql -> db_Select ( " user " , " * " , " user_id= { $userid } " );
$row = $sql -> db_Fetch ();
2010-03-13 18:59:28 +00:00
$curClass = varset ( $row [ 'user_class' ]) ? explode ( " , " , $row [ 'user_class' ]) : array ();
2009-07-23 06:55:39 +00:00
}
foreach ( $uclass as $a )
{
$a = intval ( $a );
$this -> check_allowed ( $a );
2010-03-13 18:59:28 +00:00
if ( $a != 0 ) // if 0 - then do not add.
2009-07-23 06:55:39 +00:00
{
$curClass [] = $a ;
}
}
2009-09-22 19:43:34 +00:00
if ( $mode == " remove " ) // remove selected classes
{
2010-03-13 18:59:28 +00:00
$curClass = array_diff ( $curClass , $uclass );
2009-09-22 19:43:34 +00:00
}
2010-03-13 18:59:28 +00:00
2009-09-22 19:43:34 +00:00
if ( $mode == " clear " ) // clear all classes
{
2010-03-13 18:59:28 +00:00
// $curClass = array();
2009-09-22 19:43:34 +00:00
}
2009-08-10 15:34:28 +00:00
$curClass = array_unique ( $curClass );
2009-07-23 06:55:39 +00:00
$svar = is_array ( $curClass ) ? implode ( " , " , $curClass ) : " " ;
2009-08-10 15:34:28 +00:00
if ( $sql -> db_Update ( " user " , " user_class=' " . $svar . " ' WHERE user_id= { $userid } " ) === TRUE )
2009-07-23 06:55:39 +00:00
{
$message = UCSLAN_9 ;
if ( $_POST [ 'notifyuser' ])
{
$message .= " <br /> " . UCSLAN_1 . " :</b> " . $row [ 'user_name' ] . " <br /> " ;
require_once ( e_HANDLER . " mail.php " );
$messaccess = '' ;
foreach ( $curClass as $a )
{
if ( ! isset ( $e_userclass -> fixed_classes [ $a ]))
{
$messaccess .= $e_userclass -> class_tree [ $a ][ 'userclass_name' ] . " - " . $e_userclass -> class_tree [ $a ][ 'userclass_description' ] . " \n " ;
}
}
if ( $messaccess == '' )
$messaccess = UCSLAN_12 . " \n " ;
$send_to = $row [ 'user_email' ];
$subject = UCSLAN_2 ;
$message = UCSLAN_3 . " " . $row [ 'user_name' ] . " , \n \n " . UCSLAN_4 . " " . SITENAME . " \n ( " . SITEURL . " ) \n \n " . UCSLAN_5 . " : \n \n " . $messaccess . " \n " . UCSLAN_10 . " \n " . SITEADMIN . " \n ( " . SITENAME . " ) " ;
// $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","User class change",str_replace("\n","<br />",$message),FALSE,LOG_TO_ROLLING);
sendemail ( $send_to , $subject , $message );
}
$admin_log -> log_event ( 'USET_14' , str_replace ( array ( '--UID--' , '--CLASSES--' ), array ( $id , $svar ), UCSLAN_11 ), E_LOG_INFORMATIVE );
$emessage -> add ( $message , E_MESSAGE_SUCCESS );
}
else
{
2009-08-10 15:34:28 +00:00
// $emessage->add("Update Failed", E_MESSAGE_ERROR);
2009-07-23 06:55:39 +00:00
}
}
2012-06-04 09:08:54 +00:00
*/
2009-07-23 06:55:39 +00:00
}
// End class users
2008-12-22 03:15:04 +00:00
function users_adminmenu ()
2007-08-06 19:35:17 +00:00
{
2006-12-02 04:36:16 +00:00
global $user ;
global $action ;
2012-05-23 13:59:12 +00:00
$user -> show_options ( $action ); // FIXME
2006-12-02 04:36:16 +00:00
}
2008-12-22 03:15:04 +00:00
2009-07-23 06:55:39 +00:00
2009-01-18 01:39:20 +00:00
function deleteRank ( $rankId )
{
global $emessage ;
2009-07-23 06:55:39 +00:00
$e107 = e107 :: getInstance ();
$rankId = ( int ) $rankId ;
2009-01-18 16:47:41 +00:00
$e107 -> ecache -> clear_sys ( 'nomd5_user_ranks' );
2009-07-23 06:55:39 +00:00
if ( $e107 -> sql -> db_Delete ( 'generic' , " gen_id=' { $rankId } ' " ))
2009-01-18 01:39:20 +00:00
{
2009-07-23 06:55:39 +00:00
$emessage -> add ( USRLAN_218 , E_MESSAGE_SUCCESS );
2009-01-18 01:39:20 +00:00
}
else
{
2009-07-23 06:55:39 +00:00
$emessage -> add ( USRLAN_218 , E_MESSAGE_FAIL );
2009-01-18 01:39:20 +00:00
}
}
2009-07-23 06:55:39 +00:00
2009-01-11 04:13:01 +00:00
function updateRanks ()
{
2009-07-23 06:55:39 +00:00
global $pref , $emessage ;
$e107 = e107 :: getInstance ();
2009-01-11 04:13:01 +00:00
$config = array ();
2009-01-17 03:27:17 +00:00
$ranks_calc = '' ;
$ranks_flist = '' ;
2009-07-23 06:55:39 +00:00
foreach ( $_POST [ 'op' ] as $f => $o )
2009-01-11 04:13:01 +00:00
{
2009-01-17 03:27:17 +00:00
$config [ $f ][ 'op' ] = $o ;
2009-07-23 06:55:39 +00:00
$config [ $f ][ 'val' ] = varset ( $_POST [ 'val' ][ $f ], '' );
if ( $_POST [ 'val' ][ $f ])
2009-01-11 04:13:01 +00:00
{
2009-01-17 03:27:17 +00:00
$ranks_calc .= ( $ranks_calc ? ' + ' : '' ) . '({' . $f . '} ' . " $o { $_POST [ 'val' ][ $f ] } " . ' )' ;
$ranks_flist .= ( $ranks_flist ? ',' : '' ) . $f ;
2009-01-11 04:13:01 +00:00
}
}
2009-07-23 06:55:39 +00:00
$e107 -> sql -> db_Delete ( 'generic' , " gen_type = 'user_rank_config' " );
2009-01-17 03:27:17 +00:00
$tmp = array ();
$tmp [ 'data' ][ 'gen_type' ] = 'user_rank_config' ;
$tmp [ 'data' ][ 'gen_chardata' ] = serialize ( $config );
$tmp [ '_FIELD_TYPES' ][ 'gen_type' ] = 'string' ;
$tmp [ '_FIELD_TYPES' ][ 'gen_chardata' ] = 'escape' ;
2009-07-23 06:55:39 +00:00
$e107 -> sql -> db_Insert ( 'generic' , $tmp );
2009-01-18 01:39:20 +00:00
$pref [ 'ranks_calc' ] = $ranks_calc ;
2009-01-17 03:27:17 +00:00
$pref [ 'ranks_flist' ] = $ranks_flist ;
save_prefs ();
//Delete existing rank data
2009-07-23 06:55:39 +00:00
$e107 -> sql -> db_Delete ( 'generic' , " gen_type = 'user_rank_data' " );
2009-01-17 03:27:17 +00:00
//Add main site admin info
$tmp = array ();
$tmp [ '_FIELD_TYPES' ][ 'gen_datestamp' ] = 'int' ;
$tmp [ '_FIELD_TYPES' ][ 'gen_ip' ] = 'todb' ;
$tmp [ '_FIELD_TYPES' ][ 'gen_user_id' ] = 'int' ;
$tmp [ '_FIELD_TYPES' ][ 'gen_chardata' ] = 'todb' ;
$tmp [ '_FIELD_TYPES' ][ 'gen_intdata' ] = 'int' ;
$tmp [ 'data' ][ 'gen_datestamp' ] = 1 ;
$tmp [ 'data' ][ 'gen_type' ] = 'user_rank_data' ;
2009-07-23 06:55:39 +00:00
$tmp [ 'data' ][ 'gen_ip' ] = $_POST [ 'calc_name' ][ 'main_admin' ];
$tmp [ 'data' ][ 'gen_user_id' ] = varset ( $_POST [ 'calc_pfx' ][ 'main_admin' ], 0 );
$tmp [ 'data' ][ 'gen_chardata' ] = $_POST [ 'calc_img' ][ 'main_admin' ];
$e107 -> sql -> db_Insert ( 'generic' , $tmp );
2009-01-17 03:27:17 +00:00
//Add site admin info
2009-07-23 06:55:39 +00:00
unset ( $tmp [ 'data' ]);
2009-01-17 03:27:17 +00:00
$tmp [ 'data' ][ 'gen_type' ] = 'user_rank_data' ;
$tmp [ 'data' ][ 'gen_datestamp' ] = 2 ;
2009-07-23 06:55:39 +00:00
$tmp [ 'data' ][ 'gen_ip' ] = $_POST [ 'calc_name' ][ 'admin' ];
$tmp [ 'data' ][ 'gen_user_id' ] = varset ( $_POST [ 'calc_pfx' ][ 'admin' ], 0 );
$tmp [ 'data' ][ 'gen_chardata' ] = $_POST [ 'calc_img' ][ 'admin' ];
$e107 -> sql -> db_Insert ( 'generic' , $tmp );
2009-01-18 01:39:20 +00:00
//Add all current site defined ranks
2009-07-23 06:55:39 +00:00
if ( isset ( $_POST [ 'field_id' ]))
2009-01-18 01:39:20 +00:00
{
2009-07-23 06:55:39 +00:00
foreach ( $_POST [ 'field_id' ] as $fid => $x )
2009-01-18 01:39:20 +00:00
{
2009-07-23 06:55:39 +00:00
unset ( $tmp [ 'data' ]);
2009-01-18 01:39:20 +00:00
$tmp [ 'data' ][ 'gen_type' ] = 'user_rank_data' ;
2009-07-23 06:55:39 +00:00
$tmp [ 'data' ][ 'gen_ip' ] = varset ( $_POST [ 'calc_name' ][ $fid ], '' );
$tmp [ 'data' ][ 'gen_user_id' ] = varset ( $_POST [ 'calc_pfx' ][ $fid ], 0 );
$tmp [ 'data' ][ 'gen_chardata' ] = varset ( $_POST [ 'calc_img' ][ $fid ], '' );
$tmp [ 'data' ][ 'gen_intdata' ] = varset ( $_POST [ 'calc_lower' ][ $fid ], '_NULL_' );
$e107 -> sql -> db_Insert ( 'generic' , $tmp );
2009-01-18 01:39:20 +00:00
}
}
//Add new rank, if posted
2009-07-23 06:55:39 +00:00
if ( varset ( $_POST [ 'new_calc_lower' ]))
2009-01-17 03:27:17 +00:00
{
2009-07-23 06:55:39 +00:00
unset ( $tmp [ 'data' ]);
2009-01-17 03:27:17 +00:00
$tmp [ 'data' ][ 'gen_type' ] = 'user_rank_data' ;
$tmp [ 'data' ][ 'gen_datestamp' ] = 0 ;
2009-07-23 06:55:39 +00:00
$tmp [ 'data' ][ 'gen_ip' ] = varset ( $_POST [ 'new_calc_name' ]);
$tmp [ 'data' ][ 'gen_user_id' ] = varset ( $_POST [ 'new_calc_pfx' ], 0 );
$tmp [ 'data' ][ 'gen_chardata' ] = varset ( $_POST [ 'new_calc_img' ]);
$tmp [ 'data' ][ 'gen_intdata' ] = varset ( $_POST [ 'new_calc_lower' ]);
$e107 -> sql -> db_Insert ( 'generic' , $tmp );
2009-01-17 03:27:17 +00:00
}
2009-01-18 16:47:41 +00:00
$e107 -> ecache -> clear_sys ( 'nomd5_user_ranks' );
2009-07-23 06:55:39 +00:00
$emessage -> add ( USRLAN_217 , E_MESSAGE_SUCCESS );
2009-01-11 04:13:01 +00:00
}
2009-07-23 06:55:39 +00:00
2010-03-13 18:59:28 +00:00
function showRanks ()
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
global $pref , $emessage ;
2011-05-11 11:56:42 +00:00
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
2010-03-13 18:59:28 +00:00
$e107 = e107 :: getInstance ();
2011-05-11 11:56:42 +00:00
2009-07-23 06:55:39 +00:00
require_once ( e_HANDLER . 'message_handler.php' );
2010-03-13 18:59:28 +00:00
/*
$daysregged = max ( 1 , round (( time () - $user_join ) / 86400 )) . " days " ;
$level = ceil ((( $user_forums * 5 ) + ( $user_comments * 5 ) + ( $user_chats * 2 ) + $user_visits ) / 4 );
*/
$ranks = e107 :: getRank () -> getRankData ();
$tmp = e107 :: getFile () -> get_files ( e_IMAGE . 'ranks' , '.*?\.(png|gif|jpg)' );
foreach ( $tmp as $k => $v ){
$imageList [] = $v [ 'fname' ];
}
unset ( $tmp );
natsort ( $imageList );
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
" ;
/*
2009-01-17 03:27:17 +00:00
$config = array ();
2010-03-13 18:59:28 +00:00
if ( $e107 -> sql -> db_Select ( 'generic' , 'gen_chardata' , " gen_type='user_rank_config' " , 'default' ))
2009-01-17 03:27:17 +00:00
{
$row = $e107 -> sql -> db_Fetch ( MYSQL_ASSOC );
$config = unserialize ( $row [ 'gen_chardata' ]);
}
2009-07-23 06:55:39 +00:00
$fieldList = array ( 'core' => array (), 'extended' => array ());
$fieldList [ 'core' ] = array ( 'comments' => USRLAN_201 , 'visits' => USRLAN_202 , 'daysregged' => USRLAN_203 );
foreach ( $e107 -> extended_struct as $field )
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
if ( strpos ( $field [ 'Type' ], 'int' ) !== false && $field [ 'Field' ] != 'user_extended_id' )
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
$fieldList [ 'extended' ][] = substr ( $field [ 'Field' ], 5 );
2008-12-22 03:15:04 +00:00
}
}
2010-03-13 18:59:28 +00:00
$fields = array (
'source' => array ( 'title' => USRLAN_197 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'fieldName' => array ( 'title' => USRLAN_198 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'operation' => array ( 'title' => USRLAN_199 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'value' => array ( 'title' => USRLAN_200 , 'type' => 'int' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
);
2009-07-23 06:55:39 +00:00
$opArray = array ( '*' , '+' , '-' );
2008-12-22 03:15:04 +00:00
$text .= "
2009-07-19 14:59:06 +00:00
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
2010-03-13 18:59:28 +00:00
< fieldset id = 'core-userranks-list' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' > " .
2010-03-13 18:59:28 +00:00
$frm -> colGroup ( $fields , array_keys ( $fields )) .
$frm -> thead ( $fields , array_keys ( $fields ));
2009-07-23 06:55:39 +00:00
foreach ( $fieldList [ 'core' ] as $k => $f )
2008-12-22 03:15:04 +00:00
{
$text .= "
< tr >
2009-01-18 01:39:20 +00:00
< td class = 'label' > " .USRLAN_204. " </ td >
2008-12-22 03:15:04 +00:00
< td class = 'label' > { $f } </ td >
2012-11-26 14:41:32 -08:00
< td >
2009-01-11 04:13:01 +00:00
< select name = 'op[{$k}]' class = 'tbox' >
2009-01-17 03:27:17 +00:00
" ;
2009-07-23 06:55:39 +00:00
foreach ( $opArray as $op )
2009-01-17 03:27:17 +00:00
{
$sel = ( varset ( $config [ $k ][ 'op' ]) == $op ? " selected='selected' " : '' );
$text .= " <option value=' { $op } ' { $sel } > { $op } </option> " ;
}
$text .= "
2008-12-22 14:06:17 +00:00
</ select >
</ td >
2012-11-26 14:41:32 -08:00
< td >< input type = 'text' class = 'tbox' name = 'val[{$k}]' value = '".varset($config[$k][' val '])."' size = '3' maxlength = '3' /></ td >
2008-12-22 03:15:04 +00:00
</ tr >
" ;
}
2009-07-23 06:55:39 +00:00
if ( count ( $fieldList [ 'extended' ]))
2008-12-22 03:15:04 +00:00
{
2009-07-23 06:55:39 +00:00
foreach ( $fieldList [ 'extended' ] as $f )
2008-12-22 03:15:04 +00:00
{
$text .= "
< tr >
2008-12-22 14:06:17 +00:00
< td colspan = '4' >& nbsp ; </ td >
</ tr >
< tr >
2009-01-18 01:39:20 +00:00
< td class = 'label' > " .USRLAN_205. " </ td >
2008-12-22 03:15:04 +00:00
< td class = 'label' > { $f } </ td >
2012-11-26 14:41:32 -08:00
< td >
2009-01-11 04:13:01 +00:00
< select name = 'op[{$f}]' class = 'tbox' >
2009-01-17 03:27:17 +00:00
" ;
2009-07-23 06:55:39 +00:00
foreach ( $opArray as $op )
2009-01-17 03:27:17 +00:00
{
$sel = ( varset ( $config [ $f ][ 'op' ]) == $op ? " selected='selected' " : '' );
$text .= " <option value=' { $op } ' { $sel } > { $op } </option> " ;
}
$text .= "
2008-12-22 14:06:17 +00:00
</ select >
2009-01-17 03:27:17 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >
2009-07-19 14:59:06 +00:00
< input type = 'text' class = 'tbox' name = 'val[{$f}]' value = '".varset($config[$f][' val '])."' size = '3' maxlength = '3' value = '' />
</ td >
2008-12-22 03:15:04 +00:00
</ tr >
" ;
}
}
2009-07-23 06:55:39 +00:00
if ( isset ( $pref [ 'ranks_calc' ]))
2009-01-18 01:39:20 +00:00
{
$text .= " <tr>
< td class = 'label' colspan = '4' >< br /> " .USRLAN_206. " : { $pref [ 'ranks_calc' ]} </ td >
</ tr >
" ;
}
2008-12-22 03:15:04 +00:00
$text .= '</table>' ;
2010-03-13 18:59:28 +00:00
*/
2011-05-11 11:56:42 +00:00
2010-03-13 18:59:28 +00:00
// $e107->ns->tablerender('Rank Calculation fields',$text);
$fields = array (
'type' => array ( 'title' => USRLAN_207 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'rankName' => array ( 'title' => USRLAN_208 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'lowThresh' => array ( 'title' => USRLAN_209 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'langPrefix' => array ( 'title' => USRLAN_210 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
'rankImage' => array ( 'title' => USRLAN_210 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' ),
);
$text .= "
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' > " .
2010-03-13 18:59:28 +00:00
$frm -> colGroup ( $fields , array_keys ( $fields )) .
$frm -> thead ( $fields , array_keys ( $fields ));
$info = $ranks [ 'special' ][ 1 ];
2009-01-17 03:27:17 +00:00
$val = $e107 -> tp -> toForm ( $info [ 'name' ]);
$pfx = ( $info [ 'lan_pfx' ] ? " checked='checked' " : '' );
$text .= "
2008-12-22 14:06:17 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_MAINADMIN. " </ td >
< td >
2009-07-19 14:59:06 +00:00
< input class = 'tbox' type = 'text' name = 'calc_name[main_admin]' value = '{$val}' />
2009-01-17 03:27:17 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td > N / A </ td >
< td >< input type = 'checkbox' name = 'calc_pfx[main_admin]' { $pfx } value = '1' /></ td >
< td > " .RankImageDropdown( $imageList ,'calc_img[main_admin]', $info['image'] ). " </ td >
2008-12-22 14:06:17 +00:00
</ tr >
2009-01-17 03:27:17 +00:00
" ;
2010-03-13 18:59:28 +00:00
$info = $ranks [ 'special' ][ 2 ];
2009-01-17 03:27:17 +00:00
$val = $e107 -> tp -> toForm ( $info [ 'name' ]);
$pfx = ( $info [ 'lan_pfx' ] ? " checked='checked' " : '' );
2009-07-23 06:55:39 +00:00
$text .= "
2008-12-22 14:06:17 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_ADMIN. " </ td >
< td >
2009-07-19 14:59:06 +00:00
< input class = 'tbox' type = 'text' name = 'calc_name[admin]' value = '{$val}' />
2009-01-17 03:27:17 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td > N / A </ td >
< td >< input type = 'checkbox' name = 'calc_pfx[admin]' { $pfx } value = '1' /></ td >
< td > " .RankImageDropdown( $imageList ,'calc_img[admin]', $info['image'] ). " </ td >
2008-12-22 14:06:17 +00:00
</ tr >
< tr >
< td colspan = '5' >& nbsp ; </ td >
2008-12-22 03:15:04 +00:00
</ tr >
" ;
2010-03-13 18:59:28 +00:00
foreach ( $ranks [ 'data' ] as $k => $r )
2009-01-11 04:13:01 +00:00
{
2009-01-18 01:39:20 +00:00
$pfx_checked = ( $r [ 'lan_pfx' ] ? " checked='checked' " : '' );
2009-01-11 04:13:01 +00:00
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td > " .USRLAN_212. " </ td >
< td >
2009-01-17 03:27:17 +00:00
< input type = 'hidden' name = 'field_id[{$k}]' value = '1' />
2009-07-19 14:59:06 +00:00
< input class = 'tbox' type = 'text' name = 'calc_name[$k]' value = '{$r[' name ']}' />
2009-01-17 03:27:17 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >< input class = 'tbox e-spinner' type = 'text' size = '5' name = 'calc_lower[$k]' value = '{$r[' thresh ']}' /></ td >
< td >< input type = 'checkbox' name = 'calc_pfx[$k]' value = '1' { $pfx_checked } /></ td >
< td > " .RankImageDropdown( $imageList , " calc_img [ $k ] " , $r['image'] ). " & nbsp ; " .
2011-05-11 11:56:42 +00:00
$frm -> submit_image ( " delete_rank[ { $r [ 'id' ] } ] " , LAN_DELETE , 'delete' , LAN_CONFIRMDEL . " : [ { $r [ 'name' ] } ]? " ) . "
2009-01-18 01:39:20 +00:00
</ td >
2009-01-11 04:13:01 +00:00
</ tr >
" ;
}
2008-12-22 14:06:17 +00:00
$text .= "
2009-01-18 01:39:20 +00:00
2008-12-22 14:06:17 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td colspan = '5' >& nbsp ; </ td >
2009-01-18 01:39:20 +00:00
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .USRLAN_214. " </ td >
< td >< input class = 'tbox' type = 'text' name = 'new_calc_name' value = '' /></ td >
< td >< input class = 'tbox e-spinner' type = 'text' size = '5' name = 'new_calc_lower' value = '' /></ td >
< td >< input type = 'checkbox' name = 'new_calc_pfx' value = '1' /></ td >
< td > " .RankImageDropdown( $imageList ,'new_calc_img'). " </ td >
2012-11-26 18:42:11 -08:00
</ tr > " ;
$text .= ' </ table >
< div class = " buttons-bar center " >
'.$frm->admin_button(' updateRanks ',' no - value ',' submit ',USRLAN_215).'
</ div >
</ form > ' ;
2011-05-11 11:56:42 +00:00
2012-06-04 09:08:54 +00:00
echo $emessage -> render () . $text ;
// $ns->tablerender(LAN_USER_RANKS,$emessage->render().$text);
//include (e_ADMIN.'footer.php');
//exit;
2008-12-22 03:15:04 +00:00
}
2009-07-23 06:55:39 +00:00
2010-03-13 18:59:28 +00:00
function RankImageDropdown ( & $imgList , $field , $curVal = '' )
2008-12-22 14:06:17 +00:00
{
2009-01-11 04:13:01 +00:00
$ret = "
< select class = 'tbox' name = '{$field}' >
2009-01-18 01:39:20 +00:00
< option value = '' > " .USRLAN_216. " </ option >
2009-01-11 04:13:01 +00:00
" ;
2009-07-23 06:55:39 +00:00
foreach ( $imgList as $img )
2008-12-22 14:06:17 +00:00
{
2010-03-13 18:59:28 +00:00
$sel = ( $img == $curVal ? " selected='selected' " : '' );
$ret .= " \n <option { $sel } > { $img } </option> " ;
2008-12-22 14:06:17 +00:00
}
2009-01-18 01:39:20 +00:00
$ret .= '</select>' ;
2008-12-22 14:06:17 +00:00
return $ret ;
}
2009-07-23 06:55:39 +00:00
2011-01-13 20:57:18 +00:00
?>