home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / user.php < prev    next >
Encoding:
PHP Script  |  2008-01-29  |  7.9 KB  |  181 lines

  1. <?php
  2. // $Id: user.php 1282 2008-01-29 04:26:44Z 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.         exit();
  60.     }
  61.     if ( !empty($_GET['xoops_redirect']) ) {
  62.         $redirect = trim($_GET['xoops_redirect']);
  63.         $isExternal = false;
  64.         if ($pos = strpos( $redirect, '://' )) {
  65.             $xoopsLocation = substr( XOOPS_URL, strpos( XOOPS_URL, '://' ) + 3 );
  66.             if ( strcasecmp(substr($redirect, $pos + 3, strlen($xoopsLocation)), $xoopsLocation) ) {
  67.                 $isExternal = true;
  68.             }
  69.         }
  70.         if (!$isExternal) {
  71.             header('Location: ' . $redirect);
  72.             exit();
  73.         }
  74.     }
  75.     header('Location: '.XOOPS_URL.'/userinfo.php?uid='.$xoopsUser->getVar('uid'));
  76.     exit();
  77. }
  78.  
  79. if ($op == 'login') {
  80.     include_once XOOPS_ROOT_PATH.'/include/checklogin.php';
  81.     exit();
  82. }
  83.  
  84. if ($op == 'logout') {
  85.     $message = '';
  86.     $_SESSION = array();
  87.     session_destroy();
  88.     // clear entry from online users table
  89.     if (is_object($xoopsUser)) {
  90.         $online_handler =& xoops_gethandler('online');
  91.         $online_handler->destroy($xoopsUser->getVar('uid'));
  92.     }
  93.     $message = _US_LOGGEDOUT.'<br />'._US_THANKYOUFORVISIT;
  94.     redirect_header('index.php', 1, $message);
  95.     exit();
  96. }
  97.  
  98. if ($op == 'actv') {
  99.     $id = intval($_GET['id']);
  100.     $actkey = trim($_GET['actkey']);
  101.     if (empty($id)) {
  102.         redirect_header('index.php',1,'');
  103.         exit();
  104.     }
  105.     $member_handler =& xoops_gethandler('member');
  106.     $thisuser =& $member_handler->getUser($id);
  107.     if (!is_object($thisuser)) {
  108.         exit();
  109.     }
  110.     if ($thisuser->getVar('actkey') != $actkey) {
  111.         redirect_header('index.php',5,_US_ACTKEYNOT);
  112.     } else {
  113.         if ($thisuser->getVar('level') > 0 ) {
  114.             redirect_header( 'user.php', 5, _US_ACONTACT, false );
  115.         } else {
  116.             if (false != $member_handler->activateUser($thisuser)) {
  117.                 $config_handler =& xoops_gethandler('config');
  118.                 $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
  119.                 if ($xoopsConfigUser['activation_type'] == 2) {
  120.                     $myts =& MyTextSanitizer::getInstance();
  121.                     $xoopsMailer =& getMailer();
  122.                     $xoopsMailer->useMail();
  123.                     $xoopsMailer->setTemplate('activated.tpl');
  124.                     $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
  125.                     $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
  126.                     $xoopsMailer->assign('SITEURL', XOOPS_URL."/");
  127.                     $xoopsMailer->setToUsers($thisuser);
  128.                     $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
  129.                     $xoopsMailer->setFromName($xoopsConfig['sitename']);
  130.                     $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT,$xoopsConfig['sitename']));
  131.                     include 'header.php';
  132.                     if ( !$xoopsMailer->send() ) {
  133.                         printf(_US_ACTVMAILNG, $thisuser->getVar('uname'));
  134.                     } else {
  135.                         printf(_US_ACTVMAILOK, $thisuser->getVar('uname'));
  136.                     }
  137.                     include 'footer.php';
  138.                 } else {
  139.                     redirect_header( 'user.php', 5, _US_ACTLOGIN, false );
  140.                 }
  141.             } else {
  142.                 redirect_header('index.php',5,'Activation failed!');
  143.             }
  144.         }
  145.     }
  146.     exit();
  147. }
  148.  
  149. if ($op == 'delete') {
  150.     $config_handler =& xoops_gethandler('config');
  151.     $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
  152.     if (!$xoopsUser || $xoopsConfigUser['self_delete'] != 1) {
  153.         redirect_header('index.php',5,_US_NOPERMISS);
  154.         exit();
  155.     } else {
  156.         $groups = $xoopsUser->getGroups();
  157.         if (in_array(XOOPS_GROUP_ADMIN, $groups)){
  158.             // users in the webmasters group may not be deleted
  159.             redirect_header('user.php', 5, _US_ADMINNO);
  160.             exit();
  161.         }
  162.         $ok = !isset($_POST['ok']) ? 0 : intval($_POST['ok']);
  163.         if ($ok != 1) {
  164.             include 'header.php';
  165.             xoops_confirm(array('op' => 'delete', 'ok' => 1), 'user.php', _US_SURETODEL.'<br/>'._US_REMOVEINFO);
  166.             include 'footer.php';
  167.         } else {
  168.             $del_uid = $xoopsUser->getVar("uid");
  169.             $member_handler =& xoops_gethandler('member');
  170.             if (false != $member_handler->deleteUser($xoopsUser)) {
  171.                 $online_handler =& xoops_gethandler('online');
  172.                 $online_handler->destroy($del_uid);
  173.                 xoops_notification_deletebyuser($del_uid);
  174.                 redirect_header('index.php', 5, _US_BEENDELED);
  175.             }
  176.             redirect_header('index.php',5,_US_NOPERMISS);
  177.         }
  178.         exit();
  179.     }
  180. }
  181. ?>