1
xsell
ban user from Certin Page
  • 2009/9/12 23:12

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Hello
I'm trying to ban a user from a certin page not from the whole site this wht i have done to do so .

1- Created MySQL table that will include the user id .
CREATE TABLE `userid` (
`
us_idINT11 NOT NULL AUTO_INCREMENT ,
`
userVARCHAR255 NOT NULL ,
PRIMARY KEY ( `us_id` )
);


2- Make the file that will insert the user id
<?php
if (isset($_POST['submit'])){
 
//userid variable from form
 
$userid $_POST['userid'];
 
//inset userid
 
mysql_query("INSERT INTO userid (user) VALUES('$userid') ")
 or die(
mysql_error());

 echo 
"$userid Added";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add userid</title>
</head>

<body>
<form action="" method="post" name="userid">
<input name="userid" type="text" /><input name="submit" type="submit" value="Add userid" />
</form>
</body>
</html>


3- I need someone to Show me now How to add code in the Top of the Forbbiden page that i need to keep the user away from Viewing it ..

Code to check if the user id matchs the id inserted in the table to print message for him says he was banned from this page .

2
ghia
Re: ban user from Certin Page
  • 2009/9/13 0:14

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


How about simply adding these users to a group?

3
trabis
Re: ban user from Certin Page
  • 2009/9/13 0:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You can create a new group for that user and use defacer module. Defacer allows you to set group access permissions on any page of your site.

4
xsell
Re: ban user from Certin Page
  • 2009/9/13 1:28

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Thx , Ghia and you trabis .. Regards of Ya both answer . Can you Help with the Exact thing i need to do , just Need the Function that checks the tabel if the user id there if not the allow him see the page ..

For Some reasons i want it the same way i asked above .
I know the easy way is to put him in new Group i just do not want this way for some personal reasons.

Thx For your Time Guys .. I appreciate all wht u have done for XOOPS Community

5
trabis
Re: ban user from Certin Page
  • 2009/9/13 1:42

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Supposing you page includes mainfile.php then you can add this just after it:
if (is_object($xoopsUser)) {
    
$table $xoopsDB->prefix('userid');
    
//$table = 'userid'; //Use this if your table is not using prefix
    
$sql "SELECT * FROM " $table " WHERE us_id=" $xoopsUser->getVar('uid');
    
$result $xoopsDB->query($sql);
    if (
$result && $xoopsDB->getRowsNum($result) > 0) { 
        
redirect_header(XOOPS_URL5_NOPERM);
        exit();
    }
}

6
xsell
Re: ban user from Certin Page
  • 2009/9/13 3:10

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


100% Man Just 100% thats wht i needed .. Thank you Trabis

7
xsell
Re: ban user from Certin Page
  • 2009/9/13 4:31

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Trabis . How the Code looks if we going to replace the user id with his username

8
ghia
Re: ban user from Certin Page
  • 2009/9/13 8:47

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


" WHERE user=" $xoopsUser->getVar('uname');

9
xsell
Re: ban user from Certin Page
  • 2009/9/14 2:00

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


thx Ghia , it did not work . i dont know why it seem it should have worked. as this i use to ban user by his id and it works Fine.

" WHERE user=" $xoopsUser->getVar('uid');


but to ban user with his user name i thought this should work but it did not.
" WHERE user=" $xoopsUser->getVar('uname');

Login

Who's Online

175 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 175


more...

Donat-O-Meter

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

Latest GitHub Commits