2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-20 20:19:05 +00:00
* e107 website system
*
2010-08-23 07:28:46 +00:00
* Copyright ( C ) 2008 - 2010 e107 Inc ( e107 . org )
2008-12-20 20:19:05 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* User information
*
2010-08-23 07:28:46 +00:00
* $URL $
* $Id $
2008-12-20 20:19:05 +00:00
*
2010-08-23 07:28:46 +00:00
*/
2009-08-28 15:30:25 +00:00
//HCL define('PAGE_NAME', 'Members');
2008-12-20 20:19:05 +00:00
2006-12-02 04:36:16 +00:00
require_once ( " class2.php " );
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE );
2007-07-21 09:57:33 +00:00
// Next bit is to fool PM plugin into doing things
global $user ;
$user [ 'user_id' ] = USERID ;
2015-08-29 15:56:18 -07:00
// BC for v1.x template
$bcList = array (
'LAN_112' => 'LAN_USER_60' , // Email Address
'LAN_138' => 'LAN_USER_52' , // Registered members
'LAN_139' => 'LAN_USER_57' , // Order
" LAN_142 " => " LAN_USER_58 " , // Member
" LAN_145 " => " LAN_USER_59 " , // Joined
" LAN_146 " => " LAN_USER_66 " , // Visits since...
" LAN_147 " => " LAN_USER_67 " , // Chatbox posts
" LAN_148 " => " LAN_USER_68 " , // Comments posted
" LAN_149 " => " LAN_USER_69 " , // Forum posts
" LAN_308 " => " LAN_USER_63 " , // Real Name
" LAN_403 " => " LAN_USER_64 " , // Site Stats
" LAN_404 " => " LAN_USER_65 " , // Last visit
2016-02-24 15:46:23 +00:00
" LAN_419 " => " LAN_SHOW " , // Show
2015-08-29 15:56:18 -07:00
" LAN_425 " => " LAN_USER_62 " // Send Private Message
);
e107 :: getLanguage () -> bcDefs ( $bcList );
2013-01-31 19:11:41 -08:00
if ( e_AJAX_REQUEST )
{
2015-05-23 14:49:44 +02:00
if ( vartrue ( $_POST [ 'q' ]))
2013-01-31 19:11:41 -08:00
{
2015-05-23 14:49:44 +02:00
$db = e107 :: getDb ();
2016-03-31 10:15:07 +02:00
$tp = e107 :: getParser ();
$q = $tp -> filter ( $_POST [ 'q' ]);
$l = vartrue ( $_POST [ 'l' ]) ? intval ( $_POST [ 'l' ]) : 10 ;
2015-05-23 14:49:44 +02:00
2016-04-03 14:37:37 -07:00
$where = " user_name LIKE ' " . $q . " %' " ;
//TODO FIXME Filter by userclass. - see $frm->userlist().
if ( $db -> select ( " user " , " user_id,user_name " , $where . " ORDER BY user_name LIMIT " . $l ))
2013-01-31 19:11:41 -08:00
{
2015-05-23 14:49:44 +02:00
$data = array ();
while ( $row = $db -> fetch ())
2013-01-31 19:11:41 -08:00
{
2015-05-23 14:49:44 +02:00
$data [] = array (
'value' => $row [ 'user_id' ],
'label' => $row [ 'user_name' ],
);
2013-01-31 19:11:41 -08:00
}
2015-05-23 14:49:44 +02:00
2013-01-31 19:11:41 -08:00
if ( count ( $data ))
{
2016-03-31 10:15:07 +02:00
$ajax = e107 :: getAjax ();
$ajax -> response ( $data );
2013-01-31 19:11:41 -08:00
}
2015-05-23 14:49:44 +02:00
}
2013-01-31 19:11:41 -08:00
}
exit ;
}
2012-06-19 12:53:48 +00:00
// require_once(e_CORE."shortcodes/batch/user_shortcodes.php");
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . " form_handler.php " );
if ( isset ( $_POST [ 'delp' ]))
{
$tmp = explode ( " . " , e_QUERY );
if ( $tmp [ 0 ] == " self " )
{
$tmp [ 1 ] = USERID ;
}
if ( USERID == $tmp [ 1 ] || ( ADMIN && getperms ( " 4 " )))
{
2013-04-19 22:50:41 -07:00
$sql -> select ( " user " , " user_sess " , " user_id=' " . USERID . " ' " );
2016-02-15 01:07:34 -08:00
$row = $sql -> fetch ();
2013-04-19 22:50:41 -07:00
@ unlink ( e_AVATAR_UPLOAD . $row [ 'user_sess' ]);
$sql -> update ( " user " , " user_sess='' WHERE user_id= " . intval ( $tmp [ 1 ]));
2020-12-22 14:48:28 -08:00
e107 :: redirect ( e_SELF . " ?id. " . $tmp [ 1 ]);
2006-12-02 04:36:16 +00:00
exit ;
}
}
$qs = explode ( " . " , e_QUERY );
$self_page = ( $qs [ 0 ] == 'id' && intval ( $qs [ 1 ]) == USERID );
2020-11-27 17:00:32 +01:00
if ( ! defined ( " USER_WIDTH " )){ define ( " USER_WIDTH " , " width:95% " ); }
2014-10-14 02:09:53 -07:00
2020-05-08 14:34:34 -07:00
if ( THEME_LEGACY === true ) // v1.x BC Fix for loading old templates.
2014-10-14 02:09:53 -07:00
{
2020-05-08 14:34:34 -07:00
$sc_style = array ();
e107 :: getMessage () -> addDebug ( " Loading v1.x user template " );
2016-01-21 16:22:07 -08:00
include ( e107 :: coreTemplatePath ( 'user' )); //correct way to load a core template. (don't use 'include_once' in case it has already been loaded).
2020-05-08 14:34:34 -07:00
e107 :: scStyle ( $sc_style );
2014-10-14 02:09:53 -07:00
}
2020-05-08 14:34:34 -07:00
else // v2.x
2015-03-21 20:18:06 -07:00
{
2020-05-08 14:34:34 -07:00
e107 :: getMessage () -> addDebug ( " Loading v2.x user template " );
$USER_TEMPLATE = e107 :: getCoreTemplate ( 'user' );
2015-03-21 20:18:06 -07:00
$USER_FULL_TEMPLATE = $USER_TEMPLATE [ 'view' ];
$USER_SHORT_TEMPLATE_START = $USER_TEMPLATE [ 'list' ][ 'start' ] ;
$USER_SHORT_TEMPLATE = $USER_TEMPLATE [ 'list' ][ 'item' ] ;
$USER_SHORT_TEMPLATE_END = $USER_TEMPLATE [ 'list' ][ 'end' ];
2020-05-08 14:34:34 -07:00
2015-03-21 20:18:06 -07:00
}
2012-06-19 12:53:48 +00:00
2016-05-05 09:52:22 -07:00
$USER_FULL_TEMPLATE = str_replace ( '{USER_EMBED_USERPROFILE}' , '{USER_ADDONS}' , $USER_FULL_TEMPLATE ); // BC Fix
2014-10-14 02:09:53 -07:00
$user_shortcodes = e107 :: getScBatch ( 'user' );
$user_shortcodes -> wrapper ( 'user/view' );
2012-06-19 12:53:48 +00:00
2006-12-02 04:36:16 +00:00
$user_frm = new form ;
require_once ( HEADERF );
2007-12-19 20:34:47 +00:00
$full_perms = getperms ( " 0 " ) || check_class ( varset ( $pref [ 'memberlist_access' ], 253 )); // Controls display of info from other users
if ( ! $full_perms && ! $self_page )
2006-12-02 04:36:16 +00:00
{
2015-08-29 15:56:18 -07:00
$ns -> tablerender ( LAN_ERROR , " <div style='text-align:center'> " . LAN_USER_55 . " </div> " );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
if ( isset ( $_POST [ 'records' ]))
{
$records = intval ( $_POST [ 'records' ]);
$order = ( $_POST [ 'order' ] == 'ASC' ? 'ASC' : 'DESC' );
$from = 0 ;
}
else if ( ! e_QUERY )
{
$records = 20 ;
$from = 0 ;
$order = " DESC " ;
}
else
{
if ( $qs [ 0 ] == " self " )
{
$id = USERID ;
}
else
{
if ( $qs [ 0 ] == " id " )
{
2008-06-05 19:57:52 +00:00
$id = intval ( $qs [ 1 ]);
2006-12-02 04:36:16 +00:00
}
else
{
$qs = explode ( " . " , e_QUERY );
$from = intval ( $qs [ 0 ]);
$records = intval ( $qs [ 1 ]);
$order = ( $qs [ 2 ] == 'ASC' ? 'ASC' : 'DESC' );
}
}
}
2020-11-02 11:00:48 -08:00
if ( vartrue ( $records ) > 50 )
2006-12-02 04:36:16 +00:00
{
2020-11-02 11:00:48 -08:00
$records = 50 ;
2006-12-02 04:36:16 +00:00
}
if ( isset ( $id ))
{
2016-03-10 11:53:05 +01:00
$user_exists = $sql -> count ( " user " , " (*) " , " WHERE user_id = " . $id . " " );
if ( $id == 0 || $user_exists == false )
2006-12-02 04:36:16 +00:00
{
2008-12-20 20:19:05 +00:00
$text = " <div style='text-align:center'> " . LAN_USER_49 . " " . SITENAME . " </div> " ;
2015-08-29 15:56:18 -07:00
$ns -> tablerender ( LAN_ERROR , $text );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
$loop_uid = $id ;
2015-02-15 16:07:27 -08:00
$ret = e107 :: getEvent () -> trigger ( " showuser " , $id );
$ret2 = e107 :: getEvent () -> trigger ( 'user_profile_display' , $id );
if ( ! empty ( $ret ) || ! empty ( $ret2 ))
2006-12-02 04:36:16 +00:00
{
$text = " <div style='text-align:center'> " . $ret . " </div> " ;
2015-08-29 15:56:18 -07:00
$ns -> tablerender ( LAN_ERROR , $text );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
}
2012-12-16 12:28:28 +01:00
if ( vartrue ( $pref [ 'profile_comments' ]))
2006-12-02 04:36:16 +00:00
{
require_once ( e_HANDLER . " comment_class.php " );
2010-08-23 07:28:46 +00:00
$comment_edit_query = 'comment.user.' . $id ;
2006-12-02 04:36:16 +00:00
}
2010-08-23 07:28:46 +00:00
if ( isset ( $_POST [ 'commentsubmit' ]) && $pref [ 'profile_comments' ])
2006-12-02 04:36:16 +00:00
{
2010-08-23 07:28:46 +00:00
$cobj = new comment ;
2020-05-08 14:34:34 -07:00
$cobj -> enter_comment ( $_POST [ 'author_name' ], $_POST [ 'comment' ], 'profile' , $id , null , $_POST [ 'subject' ]);
2006-12-02 04:36:16 +00:00
}
if ( $text = renderuser ( $id ))
{
2021-05-05 22:37:56 +02:00
$ns -> tablerender ( LAN_USER_50 , e107 :: getMessage () -> render () . $text , 'user' );
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-20 20:19:05 +00:00
$text = " <div style='text-align:center'> " . LAN_USER_51 . " </div> " ;
2020-05-08 14:34:34 -07:00
$ns -> tablerender ( LAN_ERROR , e107 :: getMessage () -> render () . $text );
2006-12-02 04:36:16 +00:00
}
unset ( $text );
require_once ( FOOTERF );
exit ;
}
2016-03-22 16:52:54 -07:00
// $users_total = $sql->count("user","(*)", "WHERE user_ban = 0");
2006-12-02 04:36:16 +00:00
2016-03-22 16:52:54 -07:00
// --------------------- List Users ------------------------ //TODO Put all of this into a class.
2016-03-24 13:43:00 -07:00
$users_total = $sql -> count ( " user " , " (*) " , " WHERE user_ban = 0 " );
2016-03-22 16:52:54 -07:00
$query = " SELECT u.*, ue.* FROM `#user` AS u LEFT JOIN `#user_extended` AS ue ON u.user_id = ue.user_extended_id WHERE u.user_ban = 0 ORDER BY u.user_id " . $order . " LIMIT " . intval ( $from ) . " , " . intval ( $records );
if ( ! $data = $sql -> retrieve ( $query , true ))
// if (!$sql->select("user", "*", "user_ban = 0 ORDER BY user_id $order LIMIT $from,$records"))
2006-12-02 04:36:16 +00:00
{
2016-03-22 16:52:54 -07:00
echo " <div style='text-align:center'><b> " . LAN_USER_53 . " </b></div> " ;
2006-12-02 04:36:16 +00:00
}
2016-03-22 16:52:54 -07:00
else
{
// $userList = $sql->db_getList();
2016-04-24 16:13:05 -07:00
$sc = e107 :: getScBatch ( 'user' );
2016-05-24 11:08:22 -07:00
$text = $tp -> parseTemplate ( $USER_SHORT_TEMPLATE_START , TRUE , $sc );
2016-03-22 16:52:54 -07:00
foreach ( $data as $row )
{
$loop_uid = $row [ 'user_id' ];
// $text .= renderuser($row, "short");
2016-04-24 16:13:05 -07:00
$sc -> setVars ( $row );
$sc -> wrapper ( 'user/list' );
2016-03-22 16:52:54 -07:00
2016-05-24 11:08:22 -07:00
$text .= $tp -> parseTemplate ( $USER_SHORT_TEMPLATE , TRUE , $sc );
2016-03-22 16:52:54 -07:00
}
2016-05-24 11:08:22 -07:00
$text .= $tp -> parseTemplate ( $USER_SHORT_TEMPLATE_END , TRUE , $sc );
2016-03-22 16:52:54 -07:00
}
2019-02-21 18:20:19 +01:00
$ns -> tablerender ( LAN_USER_52 , $text , 'user-list' );
2016-03-22 16:52:54 -07:00
$parms = $users_total . " , " . $records . " , " . $from . " , " . e_SELF . '?[FROM].' . $records . " . " . $order ;
echo " <div class='nextprev form-inline'> " . $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " ) . " </div> " ;
2006-12-02 04:36:16 +00:00
function renderuser ( $uid , $mode = " verbose " )
{
2015-03-21 20:18:06 -07:00
global $pref , $sc_style , $user_shortcodes ;
2014-10-14 02:09:53 -07:00
global $EXTENDED_START , $EXTENDED_TABLE , $EXTENDED_END , $USER_SHORT_TEMPLATE , $USER_FULL_TEMPLATE , $USER_TEMPLATE ;
2006-12-02 04:36:16 +00:00
global $user ;
2015-03-21 20:18:06 -07:00
$tp = e107 :: getParser ();
2006-12-02 04:36:16 +00:00
if ( is_array ( $uid ))
{
$user = $uid ;
}
else
{
2015-01-26 18:03:14 -08:00
if ( ! $user = e107 :: user ( $uid ))
2006-12-02 04:36:16 +00:00
{
return FALSE ;
}
}
2017-11-05 11:31:11 -08:00
2016-03-23 19:34:17 -07:00
$user_shortcodes -> setVars ( $user );
2019-05-09 11:45:54 +02:00
$user_shortcodes -> setScVar ( 'userProfile' , $user );
2016-03-22 16:52:54 -07:00
2017-11-05 11:31:11 -08:00
e107 :: setRegistry ( 'core/user/profile' , $user );
2006-12-02 04:36:16 +00:00
if ( $mode == 'verbose' )
{
2015-03-21 20:18:06 -07:00
return $tp -> parseTemplate ( $USER_FULL_TEMPLATE , TRUE , $user_shortcodes );
2006-12-02 04:36:16 +00:00
}
else
{
return $tp -> parseTemplate ( $USER_SHORT_TEMPLATE , TRUE , $user_shortcodes );
}
}
require_once ( FOOTERF );
2020-05-08 14:34:34 -07:00