XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
activate.php
Go to the documentation of this file.
1 <?php
21 $xoopsOption['pagetype'] = "user";
22 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
23 
24 include $GLOBALS['xoops']->path('header.php');
25 if (!empty($_GET['id']) && !empty($_GET['actkey'])) {
26  $id = intval($_GET['id']);
27  $actkey = trim($_GET['actkey']);
28  if (empty($id)) {
29  redirect_header(XOOPS_URL, 1, '');
30  exit();
31  }
32  $member_handler =& xoops_gethandler('member');
33  $thisuser =& $member_handler->getUser($id);
34  if (!is_object($thisuser)) {
35  redirect_header(XOOPS_URL, 1, '');
36  exit();
37  }
38  if ($thisuser->getVar('actkey') != $actkey) {
39  redirect_header(XOOPS_URL . '/', 5, _US_ACTKEYNOT);
40  } else {
41  if ($thisuser->getVar('level') > 0) {
42  redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'). '/index.php', 5, _US_ACONTACT, false);
43  } else {
44  if (false != $member_handler->activateUser($thisuser)) {
45  $config_handler =& xoops_gethandler('config');
46  $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
47  if ($GLOBALS['xoopsConfigUser']['activation_type'] == 2) {
49  $xoopsMailer = xoops_getMailer();
50  $xoopsMailer->useMail();
51  $xoopsMailer->setTemplate('activated.tpl');
52  $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
53  $xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
54  $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
55  $xoopsMailer->setToUsers($thisuser);
56  $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
57  $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
58  $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT, $GLOBALS['xoopsConfig']['sitename']) );
59  include $GLOBALS['xoops']->path('header.php');
60  if (!$xoopsMailer->send()) {
61  printf(_US_ACTVMAILNG, $thisuser->getVar('uname') );
62  } else {
63  printf(_US_ACTVMAILOK, $thisuser->getVar('uname') );
64  }
65  include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
66  } else {
67  redirect_header(XOOPS_URL . '/user.php', 5, _US_ACTLOGIN, false);
68  }
69  } else {
70  redirect_header(XOOPS_URL . '/index.php', 5, 'Activation failed!');
71  }
72  }
73  }
74 // Not implemented yet: re-send activiation code
75 } else if (!empty($_REQUEST['email']) && $xoopsConfigUser['activation_type'] != 0) {
77  $member_handler =& xoops_gethandler('member');
78  $getuser =& $member_handler->getUsers(new Criteria('email', $myts->addSlashes(trim($_REQUEST['email']))));
79  if (count($getuser) == 0) {
80  redirect_header(XOOPS_URL, 2, _US_SORRYNOTFOUND);
81  }
82  if ($getuser[0]->isActive()) {
83  redirect_header(XOOPS_URL, 2, sprintf(_US_USERALREADYACTIVE, $getuser[0]->getVar('email')));
84  }
85  $xoopsMailer =& xoops_getMailer();
86  $xoopsMailer->useMail();
87  $xoopsMailer->setTemplate('register.tpl');
88  $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
89  $xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
90  $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
91  $xoopsMailer->setToUsers($getuser[0]);
92  $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
93  $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
94  $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $getuser[0]->getVar('uname') ));
95  if (!$xoopsMailer->send()) {
96  echo _US_YOURREGMAILNG;
97  } else {
98  echo _US_YOURREGISTERED;
99  }
100 } else {
101  include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
102  $form = new XoopsThemeForm('', 'form', 'activate.php');
103  $form->addElement(new XoopsFormText(_US_EMAIL, 'email', 25, 255) );
104  $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit') );
105  $form->display();
106 }
107 
108 $xoBreadcrumbs[] = array('title' => _PROFILE_MA_REGISTER);
109 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
110 ?>