Exemplo n.º 1
0
 /**
  * Constructor and Login
  * @param $credentials
  * @return Oara_Network_Publisher_Daisycon
  */
 public function __construct($credentials)
 {
     $this->_credentials = $credentials;
     $dir = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR;
     if (!Oara_Utilities::mkdir_recursive($dir, 0777)) {
         throw new Exception('Problem creating folder in Access');
     }
     $cookies = $dir . $credentials["cookieName"] . '_cookies.txt';
     unlink($cookies);
     $this->_options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0", CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_COOKIEJAR => $cookies, CURLOPT_COOKIEFILE => $cookies, CURLOPT_HTTPAUTH => CURLAUTH_ANY, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0'), CURLOPT_ENCODING => "gzip", CURLOPT_VERBOSE => false);
 }
Exemplo n.º 2
0
 /**
  * @param $credentials
  * @throws Exception
  */
 public function __construct($credentials)
 {
     $user = $credentials['user'];
     $password = $credentials['password'];
     $loginUrl = 'http://affiliates.shuttlefare.com/users/sign_in';
     $dir = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR;
     if (!Oara_Utilities::mkdir_recursive($dir, 0777)) {
         throw new Exception('Problem creating folder in Access');
     }
     $cookies = $dir . $credentials["cookieName"] . '_cookies.txt';
     unlink($cookies);
     $valuesLogin = array(new Oara_Curl_Parameter('user[email]', $user), new Oara_Curl_Parameter('user[password]', $password), new Oara_Curl_Parameter('user[remember_me]', '0'), new Oara_Curl_Parameter('commit', 'Sign in'));
     $this->_options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0", CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_COOKIEJAR => $cookies, CURLOPT_COOKIEFILE => $cookies, CURLOPT_HTTPAUTH => CURLAUTH_ANY, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0'), CURLOPT_ENCODING => "gzip", CURLOPT_VERBOSE => false);
     $rch = curl_init();
     $options = $this->_options;
     curl_setopt($rch, CURLOPT_URL, "http://affiliates.shuttlefare.com/users/sign_in");
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     curl_close($rch);
     $dom = new Zend_Dom_Query($html);
     $hidden = $dom->query('input[type="hidden"]');
     foreach ($hidden as $values) {
         $valuesLogin[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $rch = curl_init();
     $options = $this->_options;
     curl_setopt($rch, CURLOPT_URL, "http://affiliates.shuttlefare.com/users/sign_in");
     $options[CURLOPT_POST] = true;
     $arg = array();
     foreach ($valuesLogin as $parameter) {
         $arg[] = urlencode($parameter->getKey()) . '=' . urlencode($parameter->getValue());
     }
     $options[CURLOPT_POSTFIELDS] = implode('&', $arg);
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     curl_close($rch);
 }
Exemplo n.º 3
0
 /**
  * Constructor and Login.
  *
  * @param $url -
  *        	Url Login
  * @param $valuesLogin -
  *        	Array with the login parameters
  * @return none
  */
 public function __construct($url, array $valuesLogin, $credentials)
 {
     if (!isset($credentials["cookiesDir"])) {
         $credentials["cookiesDir"] = "Oara";
     }
     if (!isset($credentials["cookiesSubDir"])) {
         $credentials["cookiesSubDir"] = "Import";
     }
     if (!isset($credentials["cookieName"])) {
         $credentials["cookieName"] = "default";
     }
     // Setting cookies
     $isDianomi = $credentials['networkName'] == "Dianomi" ? true : false;
     $isTD = $credentials['networkName'] == "TradeDoubler" || $credentials['networkName'] == "Stream20" || $credentials['networkName'] == "Wehkamp" || $credentials['networkName'] == "Steak";
     // $isAW = $credentials['networkName'] == "AffiliateWindow";
     $dir = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR;
     if (!Oara_Utilities::mkdir_recursive($dir, 0777)) {
         throw new Exception('Problem creating folder in Access');
     }
     // Deleting the last cookie
     if ($handle = opendir($dir)) {
         /* This is the correct way to loop over the directory. */
         while (false !== ($file = readdir($handle))) {
             if ($credentials['cookieName'] == strstr($file, '_', true)) {
                 unlink($dir . $file);
                 break;
             }
         }
         closedir($handle);
     }
     $cookieName = $credentials["cookieName"];
     $cookies = $dir . $cookieName . '_cookies.txt';
     $this->_cookiePath = $cookies;
     $this->_options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:23.0) Gecko/20100101 Firefox/32.0", CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_COOKIEJAR => $cookies, CURLOPT_COOKIEFILE => $cookies, CURLOPT_HTTPAUTH => CURLAUTH_ANY, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HEADER => false, CURLOPT_VERBOSE => false);
     // Init curl
     $ch = curl_init();
     $options = $this->_options;
     $options[CURLOPT_URL] = $url;
     $options[CURLOPT_POST] = true;
     $options[CURLOPT_FOLLOWLOCATION] = true;
     // Login form fields
     $arg = self::getPostFields($valuesLogin);
     $options[CURLOPT_POSTFIELDS] = $arg;
     // problem with SMG about the redirects and headers
     if ($isTD) {
         $options[CURLOPT_HEADER] = true;
         $options[CURLOPT_FOLLOWLOCATION] = false;
     }
     curl_setopt_array($ch, $options);
     $result = curl_exec($ch);
     $err = curl_errno($ch);
     $errmsg = curl_error($ch);
     $info = curl_getinfo($ch);
     // Close curl session
     curl_close($ch);
     if ($isDianomi) {
         $result = true;
     }
     while ($isTD && ($info['http_code'] == 301 || $info['http_code'] == 302)) {
         // redirect manually, cookies must be set, which curl does not itself
         // extract new location
         preg_match_all('|Location: (.*)\\n|U', $result, $results);
         $location = implode(';', $results[1]);
         $ch = curl_init();
         $options = $this->_options;
         $options[CURLOPT_URL] = str_replace("/publisher/..", "", $location);
         $options[CURLOPT_HEADER] = true;
         $options[CURLOPT_FOLLOWLOCATION] = false;
         curl_setopt_array($ch, $options);
         $result = curl_exec($ch);
         $err = curl_errno($ch);
         $errmsg = curl_error($ch);
         $info = curl_getinfo($ch);
         curl_close($ch);
     }
     $this->_constructResult = $result;
     if ($result == false) {
         throw new Exception("Failed to connect");
     } else {
         $this->_connected = true;
     }
 }
Exemplo n.º 4
0
 /**
  * Constructor and Login
  * @param $credentials
  * @return Oara_Network_Publisher_ShareASale
  */
 public function __construct($credentials)
 {
     $this->_username = $credentials['user'];
     $this->_password = $credentials['password'];
     $postdata = http_build_query(array('class' => 'Logon', 'method' => 'logon', 'val1' => $this->_username, 'val2' => $this->_password, 'val3' => ''));
     $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
     $context = stream_context_create($opts);
     $result = unserialize(file_get_contents('http://www.tyroocentral.com/www/api/v2/xmlrpc/APICall.php', false, $context));
     $json = json_encode($result);
     //var_dump($json);
     //$this->_sessionID = substr($json, 2, 29);
     $this->_sessionID = $result[0];
     $user = $credentials['user'];
     $password = $credentials['password'];
     //webpage uses javascript hex_md5 to encode the password
     $valuesLogin = array(new Oara_Curl_Parameter('username', $user), new Oara_Curl_Parameter('password', $password), new Oara_Curl_Parameter('loginByInterface', 1), new Oara_Curl_Parameter('login', 'Login'));
     $dir = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR;
     if (!Oara_Utilities::mkdir_recursive($dir, 0777)) {
         throw new Exception('Problem creating folder in Access');
     }
     $cookies = $dir . $credentials["cookieName"] . '_cookies.txt';
     unlink($cookies);
     $this->_options = array(CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0", CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_COOKIEJAR => $cookies, CURLOPT_COOKIEFILE => $cookies, CURLOPT_HTTPAUTH => CURLAUTH_ANY, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: es,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Cache-Control: max-age=0'), CURLOPT_ENCODING => "gzip", CURLOPT_VERBOSE => false);
     $rch = curl_init();
     $options = $this->_options;
     curl_setopt($rch, CURLOPT_URL, "http://www.tyroocentral.com/www/admin/index.php");
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     curl_close($rch);
     $dom = new Zend_Dom_Query($html);
     $hidden = $dom->query('input[type="hidden"]');
     foreach ($hidden as $values) {
         $valuesLogin[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $rch = curl_init();
     $options = $this->_options;
     curl_setopt($rch, CURLOPT_URL, "http://www.tyroocentral.com/www/admin/index.php");
     $options[CURLOPT_POST] = true;
     $arg = array();
     foreach ($valuesLogin as $parameter) {
         $arg[] = $parameter->getKey() . '=' . urlencode($parameter->getValue());
     }
     $options[CURLOPT_POSTFIELDS] = implode('&', $arg);
     curl_setopt_array($rch, $options);
     $html = curl_exec($rch);
     $dom = new Zend_Dom_Query($html);
     $hidden = $dom->query('input[type="hidden"]');
     foreach ($hidden as $values) {
         if ($values->getAttribute("name") == 'affiliateid') {
             $this->_publisherID = $values->getAttribute("value");
         }
     }
     $results = $dom->query('#oaNavigationTabs li div div');
     $finished = false;
     foreach ($results as $result) {
         $linkList = $result->getElementsByTagName('a');
         if ($linkList->length > 0) {
             $attrs = $linkList->item(0)->attributes;
             foreach ($attrs as $attrName => $attrNode) {
                 if (!$finished && ($attrName = 'href')) {
                     $parseUrl = trim($attrNode->nodeValue);
                     $parts = parse_url($parseUrl);
                     parse_str($parts['query'], $query);
                     $this->_windowid = $query['windowid'];
                     $this->_sessionIDCurl = $query['sessId'];
                     $finished = true;
                 }
             }
         }
     }
     curl_close($rch);
 }