Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1.     case "token":
  2.         if(empty($args[1])){
  3.             return $dAmn->say("$from: Usage:{$tr}token <i>username [password]</i>. If the username is on the list, it'll try using the password. Otherwise, it'll ask for the password.",$c);
  4.         }
  5.         if($user->has($from, 99)){
  6.             $tuser = strtolower($args[1]);
  7.             //Is our username on the list? Let's check.
  8.             if(isset($config['logins']['login'][strtolower($args[1])])){
  9.                 //The passwords are encoded.. let's decode the one we'll be using.
  10.                 $tpass = base64_decode($config['logins']['login'][strtolower($args[1])]);
  11.             //Perhaps our username isn't on that list. Let's check the secondary one.  
  12.             }elseif(isset($config['invisilogins']['login'][strtolower($args[1])])){
  13.                 //Found? Declaring password.
  14.                 $tpass = $config['invisilogins']['login'][strtolower($args[1])];
  15.             //Perhaps it's not on either list. If a second argument was included, we'll be using that as the password.
  16.             }elseif(!empty($args[2])){
  17.                 $tpass = $args[2];
  18.             //If no password was included either, let's see who sent the command.
  19.             }elseif(empty($args[2])){
  20.                 //If the owner sent the command, they have the option of putting the password in the bot window.
  21.                 if($from == $config['bot']['owner']){
  22.                     $dAmn->say("$from: Place password in bot window.",$c);
  23.                     print "\nPlease input {$args[1]}'s password below.\n";
  24.                     //After they've put the password in.. let's declare our pass found.
  25.                     $tpass = trim(fgets(STDIN));
  26.                 }else
  27.                     //If the owner wasn't the command sender, they can't enter the password into the window. No use killing the bot so, let's kill the command.
  28.                     return $dAmn->say("$from: $args[1] is not a stored login. Username and password required for non-stored logins.",$c);
  29.             }
  30.             //Now for the token grabber. Let's send the username and password.
  31.             $tcheck = testlogin($tuser, $tpass);
  32.             //If we got an array returned, there's no authtoken in there. Let's show the error so we know what's wrong.
  33.             if(is_array($tcheck)){
  34.                 return $dAmn->say("$from: Error returned. {$tcheck['error']}",$c);
  35.             }
  36.             //Success! We got an authtoken. Mission accomplished.
  37.             if($args[0] == "login"){
  38.                 //For the login command, we're gonna set up the config so that when it logs in, it'll be using our new login and token.
  39.                 $config['bot']['username'] = $args[1];
  40.                 $config['bot']['token'] = $tcheck;
  41.                 save_config("bot");
  42.                 $dAmn->say("$from: Login accepted. Changing logins, please wait.",$c);
  43.                 //With that all set up, we're gonna send the disconnect. The bot will use the stored info to try and login.
  44.                 $dAmn->send("disconnect\n".chr(0));
  45.             }else{
  46.                 //For token, we're just gonna send the javascript command to the requester.
  47.                 $dAmn->say("$from: javascript: dAmn_Login(\"{$args[1]}\",\"{$tcheck}\");",$c);
  48.             }
  49.         }else
  50.             return $dAmn->say("$from: This is an owner-only command.",$c);
  51.         break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement