chore: code styling via pint
This commit is contained in:
@@ -8,14 +8,17 @@ use Session;
|
||||
class Bulk extends Component
|
||||
{
|
||||
public $bulkEmails = [];
|
||||
|
||||
public $bulkCount = 1;
|
||||
|
||||
private $isSubscribed = false;
|
||||
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
}
|
||||
|
||||
public function generateBulk()
|
||||
{
|
||||
$this->validate([
|
||||
@@ -34,11 +37,11 @@ class Bulk extends Component
|
||||
public function downloadBulk()
|
||||
{
|
||||
// Ensure there's something to download
|
||||
if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) {
|
||||
if (empty($this->bulkEmails) || ! is_array($this->bulkEmails)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = 'bulk_emails_' . now()->format('Ymd_His') . '.txt';
|
||||
$filename = 'bulk_emails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
@@ -49,40 +52,42 @@ class Bulk extends Component
|
||||
private function randomEmail(): string
|
||||
{
|
||||
$domain = $this->getRandomDomain();
|
||||
if ($domain == "gmail.com" || $domain == "googlemail.com") {
|
||||
if ($domain == 'gmail.com' || $domain == 'googlemail.com') {
|
||||
$uname = $this->getRandomGmailUser();
|
||||
$uname_len = strlen($uname);
|
||||
$len_power = $uname_len - 1;
|
||||
$combination = pow(2,$len_power);
|
||||
$rand_comb = mt_rand(1,$combination);
|
||||
$formatted = implode(' ',str_split($uname));
|
||||
$combination = pow(2, $len_power);
|
||||
$rand_comb = mt_rand(1, $combination);
|
||||
$formatted = implode(' ', str_split($uname));
|
||||
$uname_exp = explode(' ', $formatted);
|
||||
|
||||
$bin = intval("");
|
||||
for($i=0; $i<$len_power; $i++) {
|
||||
$bin .= mt_rand(0,1);
|
||||
$bin = intval('');
|
||||
for ($i = 0; $i < $len_power; $i++) {
|
||||
$bin .= mt_rand(0, 1);
|
||||
}
|
||||
$bin = explode(' ', implode(' ',str_split(strval($bin))));
|
||||
$bin = explode(' ', implode(' ', str_split(strval($bin))));
|
||||
|
||||
$email = "";
|
||||
for($i=0; $i<$len_power; $i++) {
|
||||
$email = '';
|
||||
for ($i = 0; $i < $len_power; $i++) {
|
||||
$email .= $uname_exp[$i];
|
||||
if($bin[$i]) {
|
||||
$email .= ".";
|
||||
if ($bin[$i]) {
|
||||
$email .= '.';
|
||||
}
|
||||
}
|
||||
$email .= $uname_exp[$i];
|
||||
$gmail_rand = mt_rand(1,10);
|
||||
if($gmail_rand > 5) {
|
||||
$email .= "@gmail.com";
|
||||
$gmail_rand = mt_rand(1, 10);
|
||||
if ($gmail_rand > 5) {
|
||||
$email .= '@gmail.com';
|
||||
} else {
|
||||
$email .= "@googlemail.com";
|
||||
$email .= '@googlemail.com';
|
||||
}
|
||||
|
||||
return $email;
|
||||
} else {
|
||||
return $this->generateRandomUsername().'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
private function generateRandomUsername(): string
|
||||
{
|
||||
$start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0;
|
||||
@@ -90,36 +95,48 @@ class Bulk extends Component
|
||||
if ($start == 0 && $end == 0) {
|
||||
return $this->generatePronounceableWord();
|
||||
}
|
||||
|
||||
return $this->generatedRandomBetweenLength($start, $end);
|
||||
}
|
||||
|
||||
private function generatedRandomBetweenLength($start, $end): string
|
||||
{
|
||||
$length = rand($start, $end);
|
||||
|
||||
return $this->generateRandomString($length);
|
||||
}
|
||||
private function getRandomDomain() {
|
||||
|
||||
private function getRandomDomain()
|
||||
{
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$count = count($domains);
|
||||
|
||||
return $count > 0 ? $domains[rand(1, $count) - 1] : '';
|
||||
}
|
||||
private function getRandomGmailUser() {
|
||||
|
||||
private function getRandomGmailUser()
|
||||
{
|
||||
$gmailusername = json_decode(config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
||||
$count = count($gmailusername);
|
||||
|
||||
return $count > 0 ? $gmailusername[rand(1, $count) - 1] : '';
|
||||
}
|
||||
|
||||
private function generatePronounceableWord(): string
|
||||
{
|
||||
$c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
|
||||
$v = 'aeiou'; //vowels
|
||||
$a = $c . $v; //both
|
||||
$c = 'bcdfghjklmnprstvwz'; // consonants except hard to speak ones
|
||||
$v = 'aeiou'; // vowels
|
||||
$a = $c.$v; // both
|
||||
$random = '';
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$random .= $c[rand(0, strlen($c) - 1)];
|
||||
$random .= $v[rand(0, strlen($v) - 1)];
|
||||
$random .= $a[rand(0, strlen($a) - 1)];
|
||||
}
|
||||
|
||||
return $random;
|
||||
}
|
||||
|
||||
private function generateRandomString($length = 10): string
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
@@ -128,6 +145,7 @@ class Bulk extends Component
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user