Automatic Signup for ACRCloud Trial
 Page :   [ 1 ]    [ 2 ]    [ 3 ]    [ 4 ]    [ 5 ]  

The ACRCloud class (for ACR Cloud service):

This instantiates another class called "httpBrowser" which is just a wrapper for some basic HTTP requests (GETs and POSTs).

It returns an array with the headers and content.

NOTE this line :

$email = $firstname . rand(1970,1985) . ".acr@YOURDOMAIN.com";

This specifies the email address you'll be signing up with.  In my case I made sure the name ended with the suffix ".acr" @ MYDOMAIN.com

The first and last names are pulled from firstname.txt and lastname.txt which are files I populated with common first and last names.

 

<?php 

class ACRCloud{

	private $account;
	
	public function __construct(){
		
		
		
	}
	
	public function sendVerification($verifyLink){
		
		$http = new httpBrowser();
		
		$ret = $http->get($verifyLink, '', false, true);
		
		$content = $ret['content'];
		
	}
	
	
	
	public function finish(){
		
		$accounts = array();
		
		$db = DB::getInstance();
		
		$query = " select * from  " . DB_DATABASE . ".account ";
		$query .= " where didSignUp = 1 "; 
		$query .= " and gotEmail = 1 ";
		$query .= " and finished = 0 ";
		$query .= " and serviceId = " . intval(SERVICEID_ACRCLOUD) . " ";
		$query .= " order by accountId asc ";
		
		if ($result = $db->query($query)) {
			if ($result->num_rows > 0){
				while ($row = $result->fetch_assoc()){
					$accounts[] = $row;
				}
			}
		}
		
		foreach ($accounts as $akey => $account){
		
			$success = false;
		
			$this->sendVerification($account['verifyLink']);
		
			$http = new httpBrowser();
		
			$ret = $http->get('https://console.acrcloud.com/signin',  '', false, true);
		
			$content = $ret['content'];
		
			$token = '';
		
			$dom = new DomDocument();
			$dom->loadHTML($content);
		
			$forms = $dom->getElementsByTagName('form');
		
		
			foreach ($forms as $fkey => $form){
		
				if ($form->hasAttributes()){
		
					if ($form->getAttribute('action') == 'https://console.acrcloud.com/auth/login'){
		
						$dom2 = new DOMDocument();
						$dom2->appendChild($dom2->importNode($form, true));
		
						$blob = $dom2->saveHTML();
		
						$dom = new DomDocument();
						$dom->loadHTML($blob);
							
						$inputs = $dom->getElementsByTagName('input');
							
						foreach ($inputs as $ikey => $input){
		
							if ($input->hasAttributes()){
		
								if ($input->hasAttribute('type') && $input->hasAttribute('name')){
		
									if (($input->getAttribute('type') == 'hidden') && ($input->getAttribute('name') == '_token')){
											
										$token = $input->getAttribute('value');
											
									}
		
								}
		
							}
		
						}
							
					}
		
				}
		
			}
		
			if (strlen($token)){
		
				$inputData = $account['inputData'];
		
				$inputData = unserialize($inputData);
		
				if (is_array($inputData)){
						
					$params = array();
					$params['email'] = $inputData['email'];
					$params['password'] = $inputData['password'];
					$params['_token'] = $token;
		
					$ret = $http->post('https://console.acrcloud.com/auth/login', $params, 'https://console.acrcloud.com/signin', false, true);
						
					$content = $ret['content'];
		
					$pos = strpos($content, "Complete contact and go to your dashboard");
						
					if ($pos !== false){
		
						$token = '';
		
						$dom = new DomDocument();
						$dom->loadHTML($content);
		
						$forms = $dom->getElementsByTagName('form');
		
						foreach ($forms as $fkey => $form){
		
							if ($form->hasAttributes()){
		
								if ($form->getAttribute('action') == 'https://console.acrcloud.com/contact'){
		
		
									$dom2 = new DOMDocument();
									$dom2->appendChild($dom2->importNode($form, true));
										
									$blob = $dom2->saveHTML();
										
									$dom = new DomDocument();
									$dom->loadHTML($blob);
		
									$inputs = $dom->getElementsByTagName('input');
		
									foreach ($inputs as $ikey => $input){
											
										if ($input->hasAttributes()){
												
											if ($input->hasAttribute('type') && $input->hasAttribute('name')){
													
												if (($input->getAttribute('type') == 'hidden') && ($input->getAttribute('name') == '_token')){
		
													$token = $input->getAttribute('value');
		
												}
													
											}
												
										}
											
									}
										
										
								}
		
							}
								
						}
		
						if (strlen($token)){
								
							$params = array();
							$params['_token'] = $token;
							$params['city'] = $inputData['city'];
							$params['country'] = $inputData['country'];
							$params['phone_number'] = $inputData['phone'];
							$params['company'] = $inputData['company'];
							$params['website'] = $inputData['url'];
							$params['address'] = $inputData['address'];
								
							$ret = $http->post('https://console.acrcloud.com/contact', $params, 'https://console.acrcloud.com/', false, true);
								
							$content = $ret['content'];
								
						}
		
					}
						
					//////////////////////
					//////////////////////
		
					$pos = strpos($content, "Your Product Type");
						
						
					if ($pos !== false){
							
						$ret = $http->get('https://us-console.acrcloud.com/?region=us-west-2',  'https://eu-console.acrcloud.com/', false, true);
							
						// https://eu-console.acrcloud.com/?region=eu-west-1
						// https://ap-console.acrcloud.com/?region=ap-southeast-1
							
						$ret = $http->get('https://us-console.acrcloud.com/service/avr',  'https://us-console.acrcloud.com/', false, true);
							
						$content = $ret['content'];
		
							
						$token = '';
		
						$dom = new DomDocument();
						$dom->loadHTML($content);
		
						$forms = $dom->getElementsByTagName('form');
		
		
		
						$token = '';
						$type = '';
						$region = '';
		
						foreach ($forms as $fkey => $form){
		
							if ($form->hasAttributes()){
		
								if ($form->getAttribute('id') == 'form-create'){
		
		
									$dom2 = new DOMDocument();
									$dom2->appendChild($dom2->importNode($form, true));
		
									$blob = $dom2->saveHTML();
		
									$dom = new DomDocument();
									$dom->loadHTML($blob);
		
									$inputs = $dom->getElementsByTagName('input');
		
									foreach ($inputs as $ikey => $input){
											
										if ($input->hasAttributes()){
		
											if ($input->hasAttribute('type') && $input->hasAttribute('name')){
													
												if (($input->getAttribute('type') == 'hidden') && ($input->getAttribute('name') == '_token')){
													$token = $input->getAttribute('value');
												}
												if ($input->getAttribute('name') == 'type'){
													$type = $input->getAttribute('value');
												}
												if ($input->getAttribute('name') == 'region'){
													$region = $input->getAttribute('value');
												}
		
											}
		
										}
											
									}
		
								}
		
							}
		
						}
		
						/// CREATE PROJECT
		
						$prefixes = explode(",", "test,app,testapp,demo,trial");
						shuffle($prefixes);
		
						$name = $prefixes[0] . rand(100,200); // project name
						$audiotype = '1';
						$buckets = '23';
		
						if (strlen($token) && strlen($type) && strlen($region)){
								
							$params = array();
							$params['_token'] = $token;
							$params['type'] = $type;
							$params['region'] = $region;
							$params['name'] = $name;
							$params['audio_type'] = $audiotype;
							$params['buckets[]'] = $buckets;
								
							$ret = $http->post('https://us-console.acrcloud.com/service', $params, 'https://us-console.acrcloud.com/service/avr', false, true);
		
							$content = $ret['content'];
		
							$json = json_decode($content, 1);
								
							if (is_array($json)){
		
								if (array_key_exists('access_key', $json) && array_key_exists('access_secret', $json)){
										
									$results = array();
									$results['region'] = $json['region'];
									$results['access_key'] = $json['access_key'];
									$results['access_secret'] = $json['access_secret'];
									$results['name'] = $json['name'];
		
										
									$query = " update  " . DB_DATABASE . ".account set ";
									$query .= " success = 1 ";
									$query .= " ,results = '" . $db->real_escape_string(serialize($results)) . "' ";
									$query .= " where accountId = " . intval($account['accountId']);
										
									$db->query($query);
										
								}
		
							}
		
						}
							
					}
						
				}
		
			}
		
			$query = " update  " . DB_DATABASE . ".account ";
			$query .= " set finished = 1 ";
			$query .= " where accountId = " . intval($account['accountId']);
		
			$db->query($query);
		
		}
		
	}
	
	
	
	public function start(){

		$account = false;
		
		$db = DB::getInstance();
		
		$query = " select * from  " . DB_DATABASE . ".account ";
		$query .= " where didSignUp = 0 ";
		$query .= " and serviceId = " . intval(SERVICEID_ACRCLOUD) . " ";
		$query .= " order by accountId asc ";

		$found = false;
		
		if ($result = $db->query($query)) {
			if ($result->num_rows > 0){
				$found = true;
			}
		}
		
		if (!$found){
			
			$this->addAccount();
			
		}
		
		$query = " select * from  " . DB_DATABASE . ".account ";
		$query .= " where didSignUp = 0 ";
		$query .= "  and serviceId = " . intval(SERVICEID_ACRCLOUD) . " ";
		$query .= " order by accountId asc ";

		if ($result = $db->query($query)) {
			if ($result->num_rows > 0){
				while ($row = $result->fetch_assoc()){
					$this->account = $row;
					return true;
				}
			}
		}
		
		return false;
		
	}
	
	
	
	public function addAccount(){
		
		$firstnames = file(__DIR__ . '/../../resource/firstname.txt');
		$lastnames = file(__DIR__ . '/../../resource/lastname.txt');
		
		$ok = false;
		$firstname = '';
		$lastname = '';
		$email = '';
		
		$db = DB::getInstance();
		
		$count = 0;
		
		while (!$ok){
		
			$ok = true;
		
			shuffle($firstnames);
			shuffle($lastnames);
		
			$firstname = trim($firstnames[0]);
			$lastname = trim($lastnames[0]);
		
			$email = $firstname . rand(1970,1985) . ".acr@YOURDOMAIN.com";
		
			$email = strtolower($email);
		
			$query = " select * from " . DB_DATABASE . ".account ";
			$query .= " where serviceId = " . intval(SERVICEID_ACRCLOUD) . " ";
			$query .= " and email = '" . $db->real_escape_string($email) . "' "	;
		
			if ($result = $db->query($query)) {
				if ($result->num_rows > 0){
					$ok = false;
				}
			}
		
			if (++$count > 20){
				break;
			}
		
		}
		
		if ($ok){
		
			$row = false;
		
			$query = " select * from " . DB_DATABASE . ".meta ";
			$query .= " where used != 1 ";
			$query .= " order by metaId limit 1 ";
		
			if ($result = $db->query($query)) {
				if ($result->num_rows > 0){
					$row = $result->fetch_assoc();
				}
			}
		
			if ($row){
		
				$query = " update " . DB_DATABASE . ".meta set ";
				$query .= " used = 1 ";
				$query .= " where metaId = " .intval($row['metaId']);
		
				$db->query($query);
		
				$parts = explode(',', $row['dat']);
		
				$data = array();
		
				$data['name'] = $firstname;
				$data['lastname'] = $lastname;
				$data['email'] = $email;
				$data['password'] = $parts[6];
				$data['city'] = $parts[0];
				$data['country'] = $parts[1];
				$data['phone'] = $parts[2];
				$data['company'] = $parts[3];
				$data['url'] = strtolower($parts[3]) . '.com';
				$data['address'] = $parts[5];
		
				$data['phone'] = str_replace("1-","",$data['phone']);
				$data['phone'] = preg_replace("/[^0-9]/", "", $data['phone']);
		
				$query = " insert into " . DB_DATABASE . ".account (serviceId, email, inputData) values (";
				$query .= " " . intval(SERVICEID_ACRCLOUD) . " ";
				$query .= " ,'" . $db->real_escape_string($data['email']) . "' ";
				$query .= " ,'" . $db->real_escape_string(serialize($data)) . "') ";
		
				$db->query($query);

			}
		
		
		}
		
	}
	
	
	
	public function processMail($mailObj){
		
		$href = '';
		
		$dom = new DomDocument();
		$dom->loadHTML($mailObj->getMessage());
		
		$anchors = $dom->getElementsByTagName('a');
	
		foreach ($anchors as $akey => $anchor){
		
			if ($anchor->hasAttributes()){
				if ($anchor->hasAttribute('href')){
		
					$href = $anchor->textContent;
		
				}
			}
		
		}
		
		if (strlen($href)){
		
			$href = str_replace("=", "", $href);
			$href = str_replace("\n\r", "", $href);
			$href = str_replace("\r\n", "", $href);
			$href = str_replace("\n", "", $href);
			$href = str_replace("\r", "", $href);
		
			$recipient = $mailObj->getTo();
			$recipient = trim($recipient);
			$verifyLink = $href;
			$verifyLink = trim($verifyLink);
			$message = trim($mailObj->getMessage());
		
			$db = DB::getInstance();
		
			if (strlen($verifyLink)){
				
				$query  = " update ";
				$query .= " " . DB_DATABASE . ".account ";
				$query .= " set verifyLink = '" . $db->real_escape_string($verifyLink) . "' ";
				$query .= " ,emailMessage = '" . $db->real_escape_string($message) . "' ";
				$query .= " ,gotEmail = 1 where serviceId = " . SERVICEID_ACRCLOUD . " ";
				$query .= " and email = '" . $db->real_escape_string($recipient) . "' ";
				
				$db->query($query);

				return true;
				
			}
		
		}
		
		return false;
		
	}
	
	
	
	public function signUp(){
		
		$account = $this->account;
		
		$http = new httpBrowser();
		
		$ret = $http->get('https://console.acrcloud.com/signup',  'https://www.acrcloud.com/', false, true);
		
		$content = $ret['content'];
		
		$token = '';
		
		$dom = new DomDocument();
		$dom->loadHTML($content);
		
		$forms = $dom->getElementsByTagName('form');
		
		foreach ($forms as $fkey => $form){
		
			if ($form->hasAttributes()){
		
				if ($form->getAttribute('action') == 'https://console.acrcloud.com/auth/register'){
		
					$dom2 = new DOMDocument();
					$dom2->appendChild($dom2->importNode($form, true));
		
					$blob = $dom2->saveHTML();
		
					$dom = new DomDocument();
					$dom->loadHTML($blob);
						
					$inputs = $dom->getElementsByTagName('input');
						
					foreach ($inputs as $ikey => $input){
							
						if ($input->hasAttributes()){
		
							if ($input->hasAttribute('type') && $input->hasAttribute('name')){
		
								if (($input->getAttribute('type') == 'hidden') && ($input->getAttribute('name') == '_token')){
										
									$token = $input->getAttribute('value');
										
								}
		
							}
		
						}
		
					}
						
				}
		
			}
		
		}
		
		if (strlen($token)){
		
			$meta = unserialize($account['inputData']);
			
			$params = array();
			
			$params['_token'] = $token;
			$params['name'] = $meta['name'];
			$params['lastname'] = $meta['lastname'];
			$params['email'] = $meta['email'];
			$params['password'] = $meta['password'];
			$params['password_confirmation'] = $meta['password'];
		
			$ret = $http->post('https://console.acrcloud.com/auth/register', $params, 'https://console.acrcloud.com/auth/register', false, true);

			$db = DB::getInstance();
			
			$query = " update " . DB_DATABASE . ".account ";
			$query .= " set htmlAfter = '" . $db->real_escape_string($ret['content']) . "' ";
			$query .= " ,signUpForm = '" . $db->real_escape_string(serialize($params)) . "' ";
			$query .= " ,didSignUp = 1 ";
			$query .= " where accountId = " . intval($account['accountId']);
			
			$db->query($query);
			
		}
		
		
	}
	
}


?>

 

The next page talks about process.php which is called from .forward to handle the incoming confirmation email.

 

 

(Page 3 of 5)