Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- echo 'Setting all ACL privileges do admin user (by Henrique Moody)';
- echo PHP_EOL;
- echo PHP_EOL;
- try {
- /** Cli_Autoload **/
- require_once 'Cli/Autoload.php';
- Cli_Autoload::run();
- echo "DB User: ";
- $user = str_replace(PHP_EOL, '', shell_exec('
- read DB_USER;
- echo $DB_USER
- '));
- echo "DB Password: ";
- $password = str_replace(PHP_EOL, '', shell_exec('
- stty -echo;
- read DB_PASSWORD;
- stty echo;
- echo $DB_PASSWORD
- '));
- echo PHP_EOL.PHP_EOL; // return carriage and jump a line
- $db = Cli_Db::getLocalAdapter($user, $password);
- $userIds = array(1,2,3,4,5);
- foreach($userIds as $userId) {
- $db->query("DELETE FROM rule WHERE userId = {$userId}");
- echo "All privileges of user of ID '{$userId}' was removed from database", PHP_EOL;
- $privileges = $db->select()->from("privilege");
- $privileges = $db->fetchAll($privileges);
- foreach($privileges as $privilege) {
- $bind = array(
- 'userId' => $userId,
- 'privilegeId' => $privilege['privilegeId']
- );
- $db->insert('rule', $bind);
- echo "Privilege '{$privilege['privilegeId']}' setted to user of ID '{$userId}'", PHP_EOL;
- }
- echo PHP_EOL;
- }
- echo PHP_EOL;
- echo 'Done!';
- } catch (Exception $exc) {
- echo $exc->getMessage();
- echo PHP_EOL;
- echo $exc->getTraceAsString();
- }
- echo PHP_EOL;
- echo PHP_EOL;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement