20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
40 if (empty($xoopsConfigUser)) {
44 if (empty($xoopsConfigUser[
'welcome_type'])) {
52 if (!is_object(
$user)) {
58 if ($xoopsConfigUser[
'welcome_type'] == 1 || $xoopsConfigUser[
'welcome_type'] == 3) {
59 $xoopsMailer->useMail();
61 if ($xoopsConfigUser[
'welcome_type'] == 2 || $xoopsConfigUser[
'welcome_type'] == 3) {
62 $xoopsMailer->usePM();
64 $xoopsMailer->setTemplate(
'welcome.tpl');
66 $xoopsMailer->setToUsers(
$user);
67 if ($xoopsConfigUser[
'reg_dispdsclmr'] && $xoopsConfigUser[
'reg_disclaimer']) {
68 $xoopsMailer->assign(
'TERMSOFUSE', $xoopsConfigUser[
'reg_disclaimer']);
70 $xoopsMailer->assign(
'TERMSOFUSE',
'');
72 return $xoopsMailer->send();
86 $args = func_get_args();
87 $args_num = func_num_args();
111 if (is_object(
$user)) {
122 $xoopsUser_isAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin();
128 if (strrpos(
$email,
' ') > 0) {
132 if (!$xoopsUser_isAdmin) {
134 if (!empty($be) && preg_match(
'/' . $be .
'/i',
$email)) {
144 $restriction =
'/[^a-zA-Z0-9\_\-]/';
148 $restriction =
'/[^a-zA-Z0-9\_\-<>\,\.\$\%\#\@\!\\\'\']/';
152 $restriction =
'/[\000-\040]/';
155 if (empty(
$uname) || preg_match($restriction,
$uname)) {
159 if (!$xoopsUser_isAdmin) {
167 if (!empty($bu) && preg_match(
'/' . $bu .
'/i',
$uname)) {
181 $sql =
'SELECT COUNT(*) FROM `' .
$xoopsDB->prefix(
'users') .
'` WHERE `uname` = ' .
$xoopsDB->quote(addslashes(
$uname)) . ((
$uid > 0) ?
" AND `uid` <> {$uid}" :
'');
187 $sql =
'SELECT COUNT(*) FROM `' .
$xoopsDB->prefix(
'users') .
'` WHERE `email` = ' .
$xoopsDB->quote(addslashes(
$email)) . ((
$uid > 0) ?
" AND `uid` <> {$uid}" :
'');
217 function getIP($asString =
false)
221 if (!empty(
$_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
222 $proxy_ip =
$_SERVER[
'HTTP_X_FORWARDED_FOR'];
224 if (!empty(
$_SERVER[
'HTTP_X_FORWARDED'])) {
225 $proxy_ip =
$_SERVER[
'HTTP_X_FORWARDED'];
227 if (! empty(
$_SERVER[
'HTTP_FORWARDED_FOR'])) {
228 $proxy_ip =
$_SERVER[
'HTTP_FORWARDED_FOR'];
230 if (!empty(
$_SERVER[
'HTTP_FORWARDED'])) {
231 $proxy_ip =
$_SERVER[
'HTTP_FORWARDED'];
236 if (!empty(
$_SERVER[
'HTTP_X_COMING_FROM'])) {
237 $proxy_ip =
$_SERVER[
'HTTP_X_COMING_FROM'];
239 if (!empty(
$_SERVER[
'HTTP_COMING_FROM'])) {
240 $proxy_ip =
$_SERVER[
'HTTP_COMING_FROM'];
242 if (!empty($proxy_ip) && $is_ip = preg_match(
'/^([0-9]{1,3}.){3,3}[0-9]{1,3}/', $proxy_ip, $regs) && count($regs) > 0) {
248 $the_IP = ($asString) ? $the_IP : ip2long($the_IP);
261 function getUnameFromIds(
$uid, $usereal =
false, $linked =
false)
263 if (!is_array(
$uid)) {
266 $userid = array_map(
'intval', array_filter(
$uid));
270 if (count($userid) > 0) {
272 $sql =
'SELECT uid, uname, name FROM ' .
$xoopsDB->prefix(
'users') .
' WHERE level > 0 AND uid IN(' . implode(
',', array_unique($userid)) .
')';
278 if ($usereal && $row[
'name']) {
279 $users[
$uid] =
$myts->htmlSpecialChars($row[
'name']);
281 $users[
$uid] =
$myts->htmlSpecialChars($row[
'uname']);
284 $users[
$uid] =
'<a href="' . XOOPS_URL .
'/userinfo.php?uid=' .
$uid .
'" title="' . $users[
$uid] .
'">' . $users[
$uid] .
'</a>';
288 if (in_array(0, $users,
true)) {
289 $users[0] =
$myts->htmlSpecialChars(
$GLOBALS[
'xoopsConfig'][
'anonymous']);
302 function getUnameFromId($userid, $usereal =
false, $linked =
false)
305 $userid = intval($userid);
310 if (is_object(
$user)) {
311 if ($usereal &&
$user->getVar(
'name')) {
312 $username =
$user->getVar(
'name');
314 $username =
$user->getVar(
'uname');
316 if (!empty($linked)) {
317 $username =
'<a href="' . XOOPS_URL .
'/userinfo.php?uid=' . $userid .
'" title="' . $username .
'">' . $username .
'</a>';
321 if (empty($username)) {
322 $username =
$myts->htmlSpecialChars(
$GLOBALS[
'xoopsConfig'][
'anonymous']);