Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class purgeInactive extends JApplicationCli
- {
- public function doExecute()
- {
- $file = '../tmp/purge_user.csv';
- $contents = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- $csvRows = array_map('str_getcsv', $contents);
- $log = ('../log/purged_users.txt');
- $today = date('F j, Y, g:ia');
- $row = 1;
- if (($handle = fopen("../tmp/purge_user.csv", "r")) !== FALSE) {
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
- $num = count($data);
- $row++;
- for ($c=0; $c < $num; $c++) {
- file_put_contents($log, PHP_EOL . 'Removed Disabled User(s): ' . $data[$c] . PHP_EOL . '-' . $today . PHP_EOL, FILE_APPEND);
- $disUsers = implode(',', $data);
- echo ', ' . $disUsers ; // to test $disUsers output
- } // end for statement
- } // end while statment
- } // end if statement
- fclose($handle);
- $db = JFactory::getDbo();
- $user = JFactory::getUser();
- $query = $db->getQuery(true);
- $userArray = var_export($disUsers,true);
- echo PHP_EOL.'This is to test the output of $userArray'.$userArray;
- $query
- ->select($db->quoteName(array('id')))
- ->from($db->quoteName('#__users'))
- //->delete ($db->quoteName('#__users'))
- //->where(array($db->quoteName('username') . ' IN(' . $userArray) . ')');
- ->where(array($db->quoteName('username') . ' = ' . $userArray));
- //->where($deleteReq);
- $db->setQuery($query);
- //$result = $db->execute();
- $result = $db->query();
- }
- }
- JApplicationCli::getInstance('purgeInactive')->execute();
- ->where(array($db->quoteName('username') . ' = ' . $userArray));
- ->where(array($db->quoteName('username') . ' IN(' . $userArray) . ')');
- $userArray = array_map('mysql_real_escape_string', $userArray);
Add Comment
Please, Sign In to add comment