Skip to content

Instantly share code, notes, and snippets.

@jdevera
Created February 20, 2010 22:56
Show Gist options
  • Save jdevera/309975 to your computer and use it in GitHub Desktop.
Save jdevera/309975 to your computer and use it in GitHub Desktop.
Delete a user from InDefero
#!/usr/bin/env php
<?php
#
# Delete a user from InDefero.
# Run from the command line and pass a user ID as a parameter.
#
require '/home/www/indefero/src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start('/home/www/indefero/src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
if (($argc < 2) || !ctype_digit($argv[1]))
{
echo "USAGE: " . $argv[0] . " USERID\n";
exit();
}
$userid = $argv[1];
$user = new Pluf_User($userid);
if (strlen($user->login) == 0)
{
exit(sprintf("No user with ID %d was found.\n", $userid));
}
printf("User with ID %d was found in the DB:\n", $userid);
printf("- First Name: %s\n", $user->first_name);
printf("- Last Name: %s\n", $user->last_name);
printf("- User Name: %s\n", $user->login);
printf("- E-mail: %s\n", $user->email);
printf("\nDo you want to delete this user? [y/n] (default=n): ");
$handle = fopen ("php://stdin","r");
$user_input = trim(fgets($handle));
if ($user_input != "y")
{
exit("Not deleting.");
}
$user->delete();
print "User deleted\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment