Guest User

Untitled

a guest
Dec 16th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. class purgeInactive extends JApplicationCli
  2. {
  3. public function doExecute()
  4. {
  5. $file = '../tmp/purge_user.csv';
  6. $contents = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  7. $csvRows = array_map('str_getcsv', $contents);
  8. $log = ('../log/purged_users.txt');
  9. $today = date('F j, Y, g:ia');
  10. $row = 1;
  11.  
  12. if (($handle = fopen("../tmp/purge_user.csv", "r")) !== FALSE) {
  13. while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
  14. $num = count($data);
  15. $row++;
  16. for ($c=0; $c < $num; $c++) {
  17. file_put_contents($log, PHP_EOL . 'Removed Disabled User(s): ' . $data[$c] . PHP_EOL . '-' . $today . PHP_EOL, FILE_APPEND);
  18.  
  19. $disUsers = implode(',', $data);
  20. echo ', ' . $disUsers ; // to test $disUsers output
  21. } // end for statement
  22. } // end while statment
  23. } // end if statement
  24. fclose($handle);
  25.  
  26. $db = JFactory::getDbo();
  27. $user = JFactory::getUser();
  28. $query = $db->getQuery(true);
  29. $userArray = var_export($disUsers,true);
  30.  
  31. echo PHP_EOL.'This is to test the output of $userArray'.$userArray;
  32.  
  33. $query
  34. ->select($db->quoteName(array('id')))
  35. ->from($db->quoteName('#__users'))
  36. //->delete ($db->quoteName('#__users'))
  37. //->where(array($db->quoteName('username') . ' IN(' . $userArray) . ')');
  38. ->where(array($db->quoteName('username') . ' = ' . $userArray));
  39. //->where($deleteReq);
  40. $db->setQuery($query);
  41. //$result = $db->execute();
  42. $result = $db->query();
  43.  
  44. }
  45. }
  46.  
  47. JApplicationCli::getInstance('purgeInactive')->execute();
  48.  
  49. ->where(array($db->quoteName('username') . ' = ' . $userArray));
  50.  
  51. ->where(array($db->quoteName('username') . ' IN(' . $userArray) . ')');
  52.  
  53. $userArray = array_map('mysql_real_escape_string', $userArray);
Add Comment
Please, Sign In to add comment