diff --git a/README.md b/README.md index 52c7e0a..c79ad2e 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,14 @@ > LiteOTP is a Simpe OTP API Client, - Simple to use - - Support PHP5 + - Multi providers + - Asyncronous + - Reusable + - Colorfull ## Installation -requires [php](https://php.net ) to run. +requires [php7](https://php.net ) to run. ### Install the dependencies and software. @@ -42,7 +45,6 @@ try { - Add more API - Support international phone number - - get status code License ---- diff --git a/box.json b/box.json index a635c92..af2906d 100644 --- a/box.json +++ b/box.json @@ -11,6 +11,6 @@ "main": "main.php", "output": "build/lite", "stub": true, - "algorithm" :"SHA512", - "compression" :"BZ2" + "algorithm": "SHA512", + "compression": "GZ" } diff --git a/build/lite b/build/lite index 6e70369..41e0f2b 100755 Binary files a/build/lite and b/build/lite differ diff --git a/composer.json b/composer.json index 2ecca7f..8eb8384 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "ext-curl": "*", - "ext-bz2": "*", + "ext-zlib": "*", "campo/random-user-agent": "^1.3", "amphp/parallel": "^1.4" }, diff --git a/main.php b/main.php index 5940fc3..5d4e87b 100644 --- a/main.php +++ b/main.php @@ -6,7 +6,7 @@ use Amp\Parallel\Worker; use Amp\Promise; -$app = new Otp; +$app = new Otp(); if ($app->os != 'Linux') { $R = ''; @@ -50,70 +50,66 @@ BANNER; try { - if ($argc < 2) { - throw new \RuntimeException('Please input number phone'); - } + if ($argc < 2) throw new \InvalidArgumentException('Read README.md'); - if (is_numeric($argv[1])) { - $no = $argv[1]; - while (1) { - printf('%sSend OTP to %s[%s]%s%s', $G, $Y, $no, $X, PHP_EOL); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::tokopedia', - $no - ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::jdid', - $no - ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::phd', - $no - ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::pedulisehat', - $no - ); - $responses = Promise\wait(Promise\all($promises)); - - /* foreach($responses as $key => $value) */ - /* { */ - /* echo $value; */ - /* } */ - } - } elseif (is_file($argv[1])) { - $no = $argv[1]; - $no = file_get_contents($no); - $no = trim($no, " \t\n\r\0\x0B"); //remove whitespace - $no = explode(PHP_EOL, $no); - $count = sizeof($no); + $providers = ['tokopedia', 'jdid', 'phd', 'pedulisehat']; + if (is_numeric($argv[1])) { + $number = $argv[1]; while (1) { - for ($x = 0; $x < $count; $x++) { - printf('%sSend OTP to %s[%s]%s%s', $G, $Y, $no[$x], $X, PHP_EOL); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::tokopedia', - $no[$x] + foreach ($providers as $provider) { + printf( + '%sSend OTP to %s[%s]%s%s', + $G, + $Y, + $number, + $X, + PHP_EOL ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::jdid', - $no[$x] + printf('%sProvider %s[%s]%s%s', $G, $Y, $provider, $X, PHP_EOL); + $promises[$provider] = Worker\enqueueCallable( + '\Cvar1984\\LiteOtp\\Otp::' . $provider, + $number ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::phd', - $no[$x] + $responses = Promise\wait(Promise\all($promises)); + /* foreach($responses as $key => $value) */ + /* { */ + /* echo $value; */ + /* } */ + } + } + } + + $fileName = $argv[1]; + + if (!is_file($fileName)) throw new \Exception($fileName . ' Is not a file'); + if (!is_readable($fileName)) throw new \Exception('Permission denied'); + + $content = file_get_contents($fileName); + $content = trim($content, " \t\n\r\0\x0B"); //remove whitespace + $numbers = explode(PHP_EOL, $content); + + while (1) { + foreach ($providers as $provider) { + foreach ($numbers as $index => $number) { + printf( + '%sSend OTP to %s[%s]%s%s', + $G, + $Y, + $number, + $X, + PHP_EOL ); - $promises[] = Worker\enqueueCallable( - '\\Cvar1984\\LiteOtp\\Otp::pedulisehat', - $no[$x] + printf('%sProvider %s[%s]%s%s', $G, $Y, $provider, $X, PHP_EOL); + $promises[$index] = Worker\enqueueCallable( + '\Cvar1984\\LiteOtp\\Otp::' . $provider, + $number ); $responses = Promise\wait(Promise\all($promises)); } } - } else { - throw new \RuntimeException($argv[1] . ' Is not a file'); } -} catch (\Exception | \RuntimeException $e) { +} catch (\Exception | \InvalidArgumentException $e) { fprintf(STDERR, "%s%s%s\n", $RR, $e->getMessage(), $X); exit(1); } diff --git a/src/Otp.php b/src/Otp.php index 06b6627..c8d5c4e 100644 --- a/src/Otp.php +++ b/src/Otp.php @@ -4,7 +4,7 @@ final class Otp extends Request { - public $version = '2.1.0'; + public $version = '2.1.1'; public $os = PHP_OS; public $author = 'Cvar1984'; public $team = 'BlackHole Security';