1
onasre
Mass Delete inactive User permission
  • 2008/5/13 4:24

  • onasre

  • Not too shy to talk

  • Posts: 150

  • Since: 2006/8/12


I have the Hack for Mass delete inactive users , But the only one can run the Hack is the webmaster , How i give another user from another Group the permission to Run the Hack too .. this the Hack code

<?php include "mainfile.php"; include "header.php"; if ( (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) { redirect_header(XOOPS_URL, 2, _NOPERM); exit(); } include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; if (isset($_POST['submit'])) { if ( file_exists(XOOPS_ROOT_PATH."/language/".$GLOBALS['xoopsConfig']['language']."/user.php") ) { include_once XOOPS_ROOT_PATH."/language/".$GLOBALS['xoopsConfig']['language']."/user.php"; } else { include_once XOOPS_ROOT_PATH."/language/english/user.php"; } $days= trim($_REQUEST['days']); $member_handler = xoops_gethandler('member'); $criteria = new Criteria("level", 0); //target inactive users $users = $member_handler->getUsers($criteria); $delete_regdate= time() - ( $days * 24 * 60 * 60 ); // X days/month * 24 hrs/day if (empty($users)){ echo _US_SORRYNOTFOUND; } foreach (array_keys($users) as $i) { if ($users[$i]->getVar('user_regdate') < $delete_regdate){ //all users whose register more than X days ago if ($member_handler->deleteUser($users[$i]) ) { echo $users[$i]->getVar('uname')." "._US_BEENDELED."<br />"; } else { echo "Could not delete ".$users[$i]->getVar('uname')."<br />"; } } else { echo $users[$i]->getVar('uname')." is inactived but registered Less than ".$days." days ago"."<br />"; } } $form = new XoopsThemeForm('', 'form', 'delete_users.php'); $form->addElement(new XoopsFormButton('', '', _BACK, 'submit')); $form->display(); } elseif( trim($_REQUEST['days']) == "") { $form = new XoopsThemeForm('Warning !!!:All inactive users whose registered more than X days ago WILL BE DELETED FROM DATABASE', 'form', 'delete_users.php'); $form ->addElement(new XoopsFormText('Input number of days (leave it blank if you want delete all inactive users):','days',25,255)); $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); $form->display(); } include "footer.php" ?>
Whatever Hits You , Never was to Mess you , and Whatever Messed U , Never Was to Hit You.

2
zyspec
Re: Mass Delete inactive User permission
  • 2008/5/13 18:28

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


The "easiest" way to hack this code is to change:
le="color: #000000"><?php if ( (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) {
to
le="color: #000000"><?php if ( !is_object($xoopsUser) || (!$xoopsUser->isAdmin() && ('editor_name' != $xoopsUser->name())) ) {


Where editor_name should be replaced by your new editor's name.

The 'best' way to do this is to create a group of editors with a unique name, change the code to allow this new group to execute the script and then add your editors to the group.

3
onasre
Re: Mass Delete inactive User permission
  • 2008/5/13 19:16

  • onasre

  • Not too shy to talk

  • Posts: 150

  • Since: 2006/8/12


Thx , But i found that i forgot to give the access permission for the module to the user that i wanted him to run the Hack . this why he could t do it . looooool sorry for been dump
Whatever Hits You , Never was to Mess you , and Whatever Messed U , Never Was to Hit You.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits