Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Console\Commands;
- use Carbon\Carbon;
- use Dapphp\TorUtils\ControlClient;
- use Dapphp\TorUtils\TorCurlWrapper;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- class TorUrls extends Command
- {
- protected $name = 'command:tor_urls';
- private $offers = [];
- public function handle()
- {
- $this->offers = $this->getIntlOffers();
- foreach($this->offers as $o) {
- $tracking_url = $o->tracking_url;
- $target_system = $o->target_system;
- $camp_id = $o->id;
- $country = $o->country;
- $testURL = $this->resolveIntlURL($tracking_url, $target_system, $country);
- $end_url = sql_quote($testURL);
- }
- $this->testIntlOffers();
- }
- public function testIntlOffers()
- {
- $urlData = [];
- //resolve tracking_url. Use to update test_url and compare with ending_url which was inital resolved URL
- foreach ($testQuery as $t) {
- $url = $t->tracking_url;
- $camp_id = $t->camp_id;
- $target_system = $t->target_system;
- $ending_url = $t->ending_url;
- $country = $t->country;
- $testURL = $this->resolveIntlURL($url, $target_system, $country);
- }
- }
- public function getIntlOffers()
- {
- echo "getting all Intl offers";
- return DB::table('campaigns AS c')
- ->select('c.url',)
- ->where('o.country', '<>', 'US')
- ->get();
- }
- public static function resolveIntlURL($tracking, $target, $country)
- {
- echo " ------------";
- echo "I am about to connect to Control Client";
- $tc = new ControlClient();
- $tc->connect();
- $tc->authenticate('');
- $country = '{' . $country . '}';
- $tc->setConf(['ExitNodes' => $country]); //set Tor config to use exit node from whichever country
- //curl wrapped through Tor SOCK5 proxy
- $curl = new TorCurlWrapper();
- $windows_os = [10, 11, 12, 13, 18, 19];
- if (in_array($target, $windows_os)) { //Windows
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1');
- } else if ($target == 20) { //Mac
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36');
- } else if ($target == 30 || $target == 40) { //Android or any mobile
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19');
- } else if ($target == 50 || $target == 51) { //iPhone
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3');
- } else if ($target == 52) { //ipad
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25');
- } else {
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36');
- }
- if($curl->httpGet($tracking)) {
- $resolvedURL = $curl->getInfo()['url'];
- }
- else {
- $resolvedURL = "broken";
- }
- return $resolvedURL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement