[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/ -> user.php (source)

   1  <?php
   2  // $Id: user.php 1023 2007-09-08 02:55:26Z phppp $

   3  //  ------------------------------------------------------------------------ //

   4  //                XOOPS - PHP Content Management System                      //

   5  //                    Copyright (c) 2000 XOOPS.org                           //

   6  //                       <http://www.xoops.org/>                             //

   7  //  ------------------------------------------------------------------------ //

   8  //  This program is free software; you can redistribute it and/or modify     //

   9  //  it under the terms of the GNU General Public License as published by     //

  10  //  the Free Software Foundation; either version 2 of the License, or        //

  11  //  (at your option) any later version.                                      //

  12  //                                                                           //

  13  //  You may not change or alter any portion of this comment or credits       //

  14  //  of supporting developers from this source code or any supporting         //

  15  //  source code which is considered copyrighted (c) material of the          //

  16  //  original comment or credit authors.                                      //

  17  //                                                                           //

  18  //  This program is distributed in the hope that it will be useful,          //

  19  //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //

  20  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //

  21  //  GNU General Public License for more details.                             //

  22  //                                                                           //

  23  //  You should have received a copy of the GNU General Public License        //

  24  //  along with this program; if not, write to the Free Software              //

  25  //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //

  26  //  ------------------------------------------------------------------------ //

  27  
  28  $xoopsOption['pagetype'] = 'user';
  29  include  'mainfile.php';
  30  
  31  $op = 'main';
  32  
  33  if ( isset($_POST['op']) ) {
  34      $op = trim($_POST['op']);
  35  } elseif ( isset($_GET['op']) ) {
  36      $op = trim($_GET['op']);
  37  }
  38  
  39  if ($op == 'main') {
  40      if ( !$xoopsUser ) {
  41          $xoopsOption['template_main'] = 'system_userform.html';
  42          include  'header.php';
  43          $xoopsTpl->assign('lang_login', _LOGIN);
  44          $xoopsTpl->assign('lang_username', _USERNAME);
  45          if (isset($_COOKIE[$xoopsConfig['usercookie']])) {
  46              $xoopsTpl->assign('usercookie', $_COOKIE[$xoopsConfig['usercookie']]);
  47          }
  48          if (isset($_GET['xoops_redirect'])) {
  49              $xoopsTpl->assign('redirect_page', htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES));
  50          }
  51          $xoopsTpl->assign('lang_password', _PASSWORD);
  52          $xoopsTpl->assign('lang_notregister', _US_NOTREGISTERED);
  53          $xoopsTpl->assign('lang_lostpassword', _US_LOSTPASSWORD);
  54          $xoopsTpl->assign('lang_noproblem', _US_NOPROBLEM);
  55          $xoopsTpl->assign('lang_youremail', _US_YOUREMAIL);
  56          $xoopsTpl->assign('lang_sendpassword', _US_SENDPASSWORD);
  57          $xoopsTpl->assign('mailpasswd_token', $GLOBALS['xoopsSecurity']->createToken());
  58          include  'footer.php';
  59      } elseif ( !empty($_GET['xoops_redirect']) ) {
  60          header('Location: '.$_GET['xoops_redirect']);
  61      } else {
  62          header('Location: '.XOOPS_URL.'/userinfo.php?uid='.$xoopsUser->getVar('uid'));
  63      }
  64      exit();
  65  }
  66  
  67  if ($op == 'login') {
  68      include_once  XOOPS_ROOT_PATH.'/include/checklogin.php';
  69      exit();
  70  }
  71  
  72  if ($op == 'logout') {
  73      $message = '';
  74      $_SESSION = array();
  75      session_destroy();
  76      // clear entry from online users table

  77      if (is_object($xoopsUser)) {
  78          $online_handler =& xoops_gethandler('online');
  79          $online_handler->destroy($xoopsUser->getVar('uid'));
  80      }
  81      $message = _US_LOGGEDOUT.'<br />'._US_THANKYOUFORVISIT;
  82      redirect_header('index.php', 1, $message);
  83      exit();
  84  }
  85  
  86  if ($op == 'actv') {
  87      $id = intval($_GET['id']);
  88      $actkey = trim($_GET['actkey']);
  89      if (empty($id)) {
  90          redirect_header('index.php',1,'');
  91          exit();
  92      }
  93      $member_handler =& xoops_gethandler('member');
  94      $thisuser =& $member_handler->getUser($id);
  95      if (!is_object($thisuser)) {
  96          exit();
  97      }
  98      if ($thisuser->getVar('actkey') != $actkey) {
  99          redirect_header('index.php',5,_US_ACTKEYNOT);
 100      } else {
 101          if ($thisuser->getVar('level') > 0 ) {
 102              redirect_header( 'user.php', 5, _US_ACONTACT, false );
 103          } else {
 104              if (false != $member_handler->activateUser($thisuser)) {
 105                  $config_handler =& xoops_gethandler('config');
 106                  $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
 107                  if ($xoopsConfigUser['activation_type'] == 2) {
 108                      $myts =& MyTextSanitizer::getInstance();
 109                      $xoopsMailer =& getMailer();
 110                      $xoopsMailer->useMail();
 111                      $xoopsMailer->setTemplate('activated.tpl');
 112                      $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
 113                      $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
 114                      $xoopsMailer->assign('SITEURL', XOOPS_URL."/");
 115                      $xoopsMailer->setToUsers($thisuser);
 116                      $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
 117                      $xoopsMailer->setFromName($xoopsConfig['sitename']);
 118                      $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT,$xoopsConfig['sitename']));
 119                      include  'header.php';
 120                      if ( !$xoopsMailer->send() ) {
 121                          printf(_US_ACTVMAILNG, $thisuser->getVar('uname'));
 122                      } else {
 123                          printf(_US_ACTVMAILOK, $thisuser->getVar('uname'));
 124                      }
 125                      include  'footer.php';
 126                  } else {
 127                      redirect_header( 'user.php', 5, _US_ACTLOGIN, false );
 128                  }
 129              } else {
 130                  redirect_header('index.php',5,'Activation failed!');
 131              }
 132          }
 133      }
 134      exit();
 135  }
 136  
 137  if ($op == 'delete') {
 138      $config_handler =& xoops_gethandler('config');
 139      $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
 140      if (!$xoopsUser || $xoopsConfigUser['self_delete'] != 1) {
 141          redirect_header('index.php',5,_US_NOPERMISS);
 142          exit();
 143      } else {
 144          $groups = $xoopsUser->getGroups();
 145          if (in_array(XOOPS_GROUP_ADMIN, $groups)){
 146              // users in the webmasters group may not be deleted

 147              redirect_header('user.php', 5, _US_ADMINNO);
 148              exit();
 149          }
 150          $ok = !isset($_POST['ok']) ? 0 : intval($_POST['ok']);
 151          if ($ok != 1) {
 152              include  'header.php';
 153              xoops_confirm(array('op' => 'delete', 'ok' => 1), 'user.php', _US_SURETODEL.'<br/>'._US_REMOVEINFO);
 154              include  'footer.php';
 155          } else {
 156              $del_uid = $xoopsUser->getVar("uid");
 157              $member_handler =& xoops_gethandler('member');
 158              if (false != $member_handler->deleteUser($xoopsUser)) {
 159                  $online_handler =& xoops_gethandler('online');
 160                  $online_handler->destroy($del_uid);
 161                  xoops_notification_deletebyuser($del_uid);
 162                  redirect_header('index.php', 5, _US_BEENDELED);
 163              }
 164              redirect_header('index.php',5,_US_NOPERMISS);
 165          }
 166          exit();
 167      }
 168  }
 169  ?>


Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics