/** * @param InputInterface $input * @param OutputInterface $output * @return null|void */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); $connection = $this->getConnection($input); $username = $input->getArgument('username'); $password = $input->getArgument('password'); $us = "SELECT * FROM user WHERE username = '******'"; $uq = mysql_query($us); $un = mysql_num_rows($uq); if ($un >= 1) { $enc = $_configuration['password_encryption']; switch ($enc) { case 'sha1': $password = sha1($password); break; case 'md5': $password = md5($password); break; default: $password = mysql_real_escape_string($password); break; } $user = mysql_fetch_assoc($uq); $ups = "UPDATE user SET password = '******' WHERE user_id = " . $user['user_id']; $upq = mysql_query($ups); $output->writeln('User ' . $username . ' has new password.'); } else { $output->writeln('Could not find user ' . $username); } return null; }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); $connection = $this->getConnection($input); $username = $input->getArgument('username'); $us = "SELECT * FROM user WHERE username = '******'"; $uq = mysql_query($us); $un = mysql_num_rows($uq); if ($un >= 1) { $user = mysql_fetch_assoc($uq); $as = "SELECT * FROM admin WHERE user_id = " . $user['user_id']; $aq = mysql_query($as); $an = mysql_num_rows($aq); if ($an < 1) { //$output->writeln('User '.$username.' is not an admin. Making him one.'); $ms = "INSERT INTO admin (user_id) VALUES (" . $user['user_id'] . ")"; $mq = mysql_query($ms); if ($mq === false) { $output->writeln('Error making ' . $username . ' an admin.'); } else { $output->writeln('User ' . $username . ' is now an admin.'); } } else { $output->writeln('User ' . $username . ' is alreay an admin.'); } } else { $output->writeln('Could not find user ' . $username); } return null; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); $dbh = $this->getHelper('configuration')->getConnection(); $lang = mysql_real_escape_string($input->getArgument('language')); if (empty($lang)) { $ls = "SELECT DISTINCT language, count(*) as num FROM user GROUP BY 1 ORDER BY language"; $lq = mysql_query($ls); if ($lq === false) { $output->writeln('Error in query: ' . mysql_error()); return null; } else { $output->writeln("Language\t| Number of users"); while ($lr = mysql_fetch_assoc($lq)) { $output->writeln($lr['language'] . "\t\t| " . $lr['num']); } } } else { // Check available languages $ls = "SELECT english_name FROM language ORDER BY english_name"; $lq = mysql_query($ls); if ($lq === false) { $output->writeln('Error in query: ' . mysql_error()); return null; } else { $languages = array(); while ($lr = mysql_fetch_assoc($lq)) { $languages[] = $lr['english_name']; } if (!in_array($lang, $languages)) { $output->writeln($lang . ' must be available on your platform before you can use it'); return null; } $lu = "UPDATE user SET language = '{$lang}'"; $lq = mysql_query($lu); if ($lq === false) { $output->writeln('Error in query: ' . mysql_error()); } else { $output->writeln('Language set to ' . $lang . ' for all users'); } } } return null; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); $connection = $this->getConnection($input); $dialog = $this->getHelperSet()->get('dialog'); if (!$dialog->askConfirmation($output, '<question>This action will make all admins normal teachers. Are you sure? (y/N)</question>', false)) { return; } $us = "DELETE FROM admin"; $uq = mysql_query($us); if ($uq === false) { $output->writeln('Could not delete admins.'); } else { $output->writeln('All admins disabled.'); } return null; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); $dbh = $this->getHelper('configuration')->getConnection(); $username = $input->getArgument('username'); $us = "SELECT * FROM user WHERE username = '******'"; $uq = mysql_query($us); $un = mysql_num_rows($uq); if ($un >= 1) { $user = mysql_fetch_assoc($uq); $link = $_configuration['root_web'] . 'main/auth/lostPassword.php?reset=' . md5($_configuration['security_key'] . $user['email']) . '&id=' . $user['user_id']; $output->writeln('Follow this link to login as ' . $username); $output->writeln($link); } else { $output->writeln('Could not find user ' . $username); } return null; }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $connection = $this->getConnection($input); if (!empty($dbh)) { $ls = "SELECT url, count(user_id) as users FROM access_url a\n INNER JOIN access_url_rel_user r ON a.id = r.access_url_id\n order by url"; $lq = mysql_query($ls); if ($lq === false) { $output->writeln('Error in query: ' . mysql_error()); return null; } else { $output->writeln("Url\t\t\t\t| Number of users"); while ($lr = mysql_fetch_assoc($lq)) { $output->writeln($lr['url'] . "\t\t| " . $lr['users']); } } } return null; }