Advertisement
Guest User

Untitled

a guest
May 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. function sxLogin($username, $password) {
  2.         global $url;
  3.         global $proxyaddr;
  4.         $extra = '';
  5.         if (!isset($url)) { die("\r\nConfiguration variables not set\r\n"); }
  6.         $request = $url . 'api.php?action=login&lgname=' . $username . '&lgpassword=' . $password . '&format=php';
  7.         while (true) {
  8.         $ch = curl_init();
  9.         curl_setopt($ch, CURLOPT_URL, $request);
  10.         if ($proxyaddr != "") { curl_setopt($ch, CURLOPT_PROXY, $proxyaddr); }
  11.         curl_setopt($ch, CURLOPT_HEADER, false);
  12.         curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiejar.txt");
  13.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  14.         curl_setopt($ch, CURLOPT_POST, 1);
  15.         curl_setopt($ch, CURLOPT_POSTFIELDS, "wpName=".$username."&wpPassword=".$password."&wpLoginattempt=true$extra");
  16.         $sxLgInput = curl_exec($ch);
  17.         curl_close($ch);
  18.         $sxLgI = unserialize($sxLgInput);
  19.         $result = $sxLgI['login']['result'];
  20.         if ($result=='NeedToken') {
  21.             $extra = "&lgtoken=".$sxLgI['login']['token'];
  22.         } elseif ($result != "Success") {
  23.                 $failed = "Login failed: $result\r\n";
  24.                 die($failed);
  25.         } else {
  26.                 echo "\r\nLogged in as $username \r\n";
  27.         }
  28.         }
  29.         $sxLgIA = array("token" => $sxLgI['login']['lgtoken'], "uid" => $sxLgI['login']['lguserid']);
  30.         return($sxLgIA);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement