1
Peekay
I accept your terms and conditions - login hack
  • 2008/2/22 16:18

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


This presents an 'I accept your terms' checkbox in the login block and on the user page (along with the terms if you want). If you insist on the terms being visible on login, omit the login block from the homepage and just add a 'Login' button-link to 'user.php'.

The version I messed with is XOOPS 2.0.13.2. It will probably work for later versions too, but don't rely too much on the line numbers. If anyone spots any errors, or wants to update it for other XOOPS versions, please do.

My usual disclaimer applies... backup the files and if it ruins your day, don't blame me!

language/english/user.php

(add anywhere)
define('_US_MUSTACCEPTMYTERMS','Sorry. You must accept our terms.');

language/english/global.php

Add (anywhere):
define('_MYTERMS','I agree to your terms ');

user.php

Around line 51, add:
$xoopsTpl->assign('lang_myterms'_MYTERMS);

modules/system/blocks/system_blocks.php

Around line 94, add:
$block['lang_myterms'] = _MYTERMS;

modules/system/templates/system_userform.html

About line 6, add:


    <
br /><b>Terms of Useb><br />
    
You must be over 18 to use this site.
    <
br /><br />
    <{
$lang_myterms}> <input type="checkbox" name="termsaccepted" />
    <
br /><br />


modules/system/blocks/system_block_login.html

About line 6, add:


    <
br />
    <
input type="checkbox" name="termsaccepted" /> <{$block.lang_myterms}>
    <
br /><br />


include/checklogin.php

Around line 43, add:
// Peekays Terms Hack ------------------------------------------ //

if(!isset($_POST['termsaccepted'])) {
    
redirect_header(XOOPS_URL.'/user.php'1_US_MUSTACCEPTMYTERMS);
    exit();
 }

// End pk mod -------------------------------------------------- //
A thread is for life. Not just for Christmas.

2
Peekay
Re: I accept your terms and conditions - login hack
  • 2008/2/25 17:56

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


There was a report of a blank page on log-out. I haven't altered the logout routine at all, but to clarify the PHP file code alterations:

include/checklogin.php

Quote:

include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
$uname = !isset($_POST['uname']) ? '' : trim($_POST['uname']);
$pass = !isset($_POST['pass']) ? '' : trim($_POST['pass']);
if ($uname == '' || $pass == '') {
redirect_header(XOOPS_URL.'/user.php', 1, _US_INCORRECTLOGIN);
exit();
}

// Peekays terms hack -------------------------------- //

if(!isset($_POST['termsaccepted'])) {
redirect_header(XOOPS_URL.'/user.php', 1, _US_MUSTACCEPTMYTERMS);
exit();
}

// End pk mod ---------------------------------------- //


$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();
$user =& $member_handler->loginUser($myts->addSlashes($uname), $myts->addSlashes($pass));
if (false != $user) {
if (0 == $user->getVar('level')) {
redirect_header(XOOPS_URL.'/index.php', 5, _US_NOACTTPADM);
exit();
}


user.php

Quote:

if ($op == 'main') {
if ( !$xoopsUser ) {
$xoopsOption['template_main'] = 'system_userform.html';
include 'header.php';
$xoopsTpl->assign('lang_login', _LOGIN);
$xoopsTpl->assign('lang_username', _USERNAME);
if (isset($_COOKIE[$xoopsConfig['usercookie']])) {
$xoopsTpl->assign('usercookie', $_COOKIE[$xoopsConfig['usercookie']]);
}
if (isset($_GET['xoops_redirect'])) {
$xoopsTpl->assign('redirect_page', htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES));
}
$xoopsTpl->assign('lang_password', _PASSWORD);

// Peekays Terms Hack
$xoopsTpl->assign('lang_myterms', _MYTERMS);
// End pk mod


$xoopsTpl->assign('lang_notregister', _US_NOTREGISTERED);
$xoopsTpl->assign('lang_lostpassword', _US_LOSTPASSWORD);
$xoopsTpl->assign('lang_noproblem', _US_NOPROBLEM);
$xoopsTpl->assign('lang_youremail', _US_YOUREMAIL);
$xoopsTpl->assign('lang_sendpassword', _US_SENDPASSWORD);
$xoopsTpl->assign('mailpasswd_token', $GLOBALS['xoopsSecurity']->createToken());
include 'footer.php';
} elseif ( $xoopsUser ) {
header('Location: '.XOOPS_URL.'/userinfo.php?uid='.$xoopsUser->getVar('uid'));
}
exit();
}


The logout redirect (to index.php) is also dealt with in user.php, around line 73, but that should be unaltered:

Quote:

if ($op == 'logout') {
$message = '';
$_SESSION = array();
session_destroy();
if ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '') {
setcookie($xoopsConfig['session_name'], '', time()- 3600, '/', '', 0);
}
// clear entry from online users table
if (is_object($xoopsUser)) {
$online_handler =& xoops_gethandler('online');
$online_handler->destroy($xoopsUser->getVar('uid'));
}
$message = _US_LOGGEDOUT.'
'._US_THANKYOUFORVISIT;
redirect_header('index.php', 1, $message);
exit();

}


The usual precautions about editing PHP files apply. Make sure your text editor has not allowed any spaces or line breaks after the closing PHP tag. Always FTP PHP files in text/ascii mode.

If anyone can confirm that this works it would be nice to know!
A thread is for life. Not just for Christmas.

Login

Who's Online

237 user(s) are online (135 user(s) are browsing Support Forums)


Members: 0


Guests: 237


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits