예제 #1
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $totalOverviews = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/stats', array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('input[name="form[_token]"]');
     $token = null;
     foreach ($results as $result) {
         $token = $result->getAttribute("value");
     }
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('form[year]', $dStartDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('fform[_token]', $token);
     $valuesFormExport[] = new Oara_Curl_Parameter('show', 'Show');
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/stats?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $stringToFind = $dStartDate->toString("MM-yyyy");
     /*** load the html into the object ***/
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('.frame > table');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
     $num = count($exportData);
     $transactionCounter = 0;
     $valueCounter = 0;
     $commissionCounter = 0;
     for ($i = 1; $i < $num - 1; $i++) {
         $transactionArray = str_getcsv($exportData[$i], ";");
         if ($transactionArray[0] == $stringToFind) {
             $transactionCounter = $transactionArray[12];
             $valueCounter += $transactionArray[14];
             $commissionCounter += $transactionArray[16];
         }
     }
     if ($transactionCounter > 0) {
         $dateList = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate);
         for ($i = 0; $i < count($dateList); $i++) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['date'] = $dateList[$i]->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = $valueCounter / count($dateList);
             $transaction['commission'] = $commissionCounter / count($dateList);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #2
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $paymentExport = array();
     $paymentExport[] = new Oara_Curl_Parameter('session', $this->_sessionId);
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://affiliate.paidonresults.com/cgi-bin/invoice-status.pl?', $paymentExport);
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('#tableID1 tr');
     foreach ($results as $result) {
         $childrenList = $result->childNodes;
         $numberChildren = $childrenList->length;
         if ($numberChildren == 18) {
             $value = $childrenList->item(14)->nodeValue;
             if (preg_match('/[0-9]+(,[0-9]{3})*(\\.[0-9]{2})?$/', $value, $matches)) {
                 $obj = array();
                 $obj['pid'] = $childrenList->item(4)->nodeValue;
                 $date = new Zend_Date($childrenList->item(0)->nodeValue, "dd/MMM/yyyy");
                 $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
                 $obj['value'] = Oara_Utilities::parseDouble($matches[0]);
                 $obj['method'] = 'BACS';
                 $paymentHistory[] = $obj;
             }
         }
     }
     return $paymentHistory;
 }
예제 #3
0
 /**
  *
  * It returns the transactions for a payment
  * @param int $paymentId
  */
 public function paymentTransactions($paymentId, $merchantList, $startDate)
 {
     $transactionList = array();
     $urls = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('popup', 'true');
     $valuesFormExport[] = new Oara_Curl_Parameter('payment_id', $paymentId);
     $urls[] = new Oara_Curl_Request('https://affiliates.wehkamp.nl/pan/reports/Payment.html?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('a');
     $urls = array();
     foreach ($results as $result) {
         $url = $result->getAttribute('href');
         $urls[] = new Oara_Curl_Request("https://affiliates.wehkamp.nl" . $url . "&format=CSV", array());
     }
     $exportReportList = $this->_client->get($urls);
     foreach ($exportReportList as $exportReport) {
         $exportReportData = str_getcsv($exportReport, "\r\n");
         $num = count($exportReportData);
         for ($i = 2; $i < $num - 1; $i++) {
             $transactionArray = str_getcsv($exportReportData[$i], ";");
             if ($transactionArray[8] != '') {
                 $transactionList[] = $transactionArray[8];
             } else {
                 if ($transactionArray[7] != '') {
                     $transactionList[] = $transactionArray[7];
                 } else {
                     throw new Exception("No Identifier");
                 }
             }
         }
     }
     return $transactionList;
 }
예제 #4
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
  */
 public function getPaymentHistory()
 {
     $paymentHistory = array();
     $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://member.impactradius.co.uk/secure/nositemesh/accounting/getPayStubParamsCSV.csv', array());
     $exportReport = $this->_newClient->get($urls);
     $exportData = str_getcsv($exportReport[0], "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $paymentExportArray = str_getcsv($exportData[$i], ",");
         $obj = array();
         $date = new Zend_Date($paymentExportArray[1], "dd MMM, yyyy");
         $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
         $obj['pid'] = $paymentExportArray[0];
         $obj['method'] = 'BACS';
         if (preg_match('/[-+]?[0-9]*,?[0-9]*\\.?[0-9]+/', $paymentExportArray[6], $matches)) {
             $obj['value'] = $filter->filter($matches[0]);
         } else {
             throw new Exception("Problem reading payments");
         }
         $paymentHistory[] = $obj;
     }
     return $paymentHistory;
 }
예제 #5
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $stringToFind = $dStartDate->toString("MMMM yyyy");
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/payments', array());
     $exportReport = $this->_client->get($urls);
     /*** load the html into the object ***/
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('#navigation > table');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
     $num = count($exportData);
     for ($i = 1; $i < $num - 1; $i++) {
         $transactionArray = str_getcsv($exportData[$i], ";");
         if ($transactionArray[0] == $stringToFind) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['date'] = $dEndDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionArray[2]));
             $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionArray[2]));
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #6
0
 /**
  *  It returns the transactions for a payment
  * @see Oara_Network::paymentTransactions()
  */
 public function paymentTransactions($paymentId, $merchantList, $startDate)
 {
     $paymentTransactionList = array();
     $paymentHistory = Oara_Utilities::registerBubbleSort($this->_paymentHistory);
     $paymentStartDate = new Zend_Date($startDate, "yyyy-MM-dd HH:mm:ss");
     $paymentEndDate = null;
     $enc = false;
     $i = 0;
     $payment = null;
     while (!$enc && $i < count($paymentHistory)) {
         $payment = $paymentHistory[$i];
         if ($payment['pid'] == $paymentId) {
             $enc = true;
             $paymentEndDate = new Zend_Date($payment['date'], "yyyy-MM-dd HH:mm:ss");
         }
         $i++;
     }
     if ($enc && $paymentStartDate->compare($paymentEndDate) <= 0) {
         $totalTransactions = array();
         $dateArray = Oara_Utilities::monthsOfDifference(new Zend_Date($startDate, "yyyy-MM-dd HH:mm:ss"), $paymentEndDate);
         for ($i = 0; $i < count($dateArray); $i++) {
             $monthStartDate = clone $dateArray[$i];
             $monthEndDate = null;
             if ($i != count($dateArray) - 1) {
                 $monthEndDate = clone $dateArray[$i];
                 $monthEndDate->setDay(1);
                 $monthEndDate->addMonth(1);
                 $monthEndDate->subDay(1);
             } else {
                 $monthEndDate = $paymentEndDate;
             }
             $monthEndDate->setHour(23);
             $monthEndDate->setMinute(59);
             $monthEndDate->setSecond(59);
             echo "\n importing from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n";
             $urls = array();
             $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
             $valuesFormExport[] = new Oara_Curl_Parameter('DateFrom', $monthStartDate->toString("yyyy-MM-dd"));
             $valuesFormExport[] = new Oara_Curl_Parameter('DateTo', $monthEndDate->toString("yyyy-MM-dd"));
             $urls[] = new Oara_Curl_Request('http://affiliate.paidonresults.com/api/transactions?', $valuesFormExport);
             $exportReport = $this->_client->get($urls);
             $exportData = str_getcsv($exportReport[0], "\r\n");
             $num = count($exportData);
             for ($i = 1; $i < $num; $i++) {
                 $transactionExportArray = str_getcsv($exportData[$i], ",");
                 $paid = $transactionExportArray[7] == "YES" ? true : false;
                 if (in_array($transactionExportArray[0], $merchantList) && $paid) {
                     $transactionDate = new Zend_Date($transactionExportArray[8], "dd/MM/yyyy HH:mm:ss");
                     echo $paymentEndDate->toString("yyyy-MM-dd") . "  " . $transactionDate->toString("yyyy-MM-dd") . "\n\n";
                     if ($paymentEndDate->toString("yyyy-MM-dd") == $transactionDate->toString("yyyy-MM-dd")) {
                         $paymentTransactionList[] = $transactionExportArray[2];
                     }
                 }
             }
         }
     }
     return $paymentTransactionList;
 }
예제 #7
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('periodtype', "fromtolong");
     $valuesFormExport[] = new Oara_Curl_Parameter('fromday', $dStartDate->toString("dd"));
     $valuesFormExport[] = new Oara_Curl_Parameter('frommonth', $dStartDate->toString("MM"));
     $valuesFormExport[] = new Oara_Curl_Parameter('fromyear', $dStartDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('today', $dEndDate->toString("dd"));
     $valuesFormExport[] = new Oara_Curl_Parameter('tomonth', $dEndDate->toString("MM"));
     $valuesFormExport[] = new Oara_Curl_Parameter('toyear', $dEndDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('Go', 'Go');
     $valuesFormExport[] = new Oara_Curl_Parameter('partnerId', '326');
     $valuesFormExport[] = new Oara_Curl_Parameter('action', 'partnerLeads');
     $valuesFormExport[] = new Oara_Curl_Parameter('subaction', 'RevenueOverTime');
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://my.dianomi.com/Campaign-Analysis-378_1.html?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('.tabular');
     if (count($results) > 0) {
         $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
         $num = count($exportData);
         for ($i = 1; $i < $num; $i++) {
             $overviewExportArray = str_getcsv($exportData[$i], ";");
             $transaction = array();
             $transaction['merchantId'] = 1;
             $date = new Zend_Date($overviewExportArray[0], "yyyy-MM-dd");
             $transaction['date'] = $date->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = $overviewExportArray[1];
             $transaction['commission'] = $overviewExportArray[1];
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #8
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getCreatives()
  */
 public function getCreatives()
 {
     $creativesMap = array();
     $merchantList = self::getMerchantList();
     foreach ($merchantList as $merchant) {
         $websiteFirstId = null;
         $websiteMap = array();
         if (isset($this->_websitesList[$merchant['cid']])) {
             $websiteMap = $this->_websitesList[$merchant['cid']];
         }
         foreach ($websiteMap as $websiteid => $websiteName) {
             $websiteFirstId = $websiteid;
             break;
         }
         if ($websiteFirstId != null) {
             $urls = array();
             $valuesFormExport = Oara_Utilities::cloneArray($this->_exportCreativeParameters);
             $valuesFormExport[] = new Oara_Curl_Parameter('programGEListParameterTransport.siteId', $websiteFirstId);
             $valuesFormExport[] = new Oara_Curl_Parameter('programGEListParameterTransport.programIdOrName', $merchant['cid']);
             $urls[] = new Oara_Curl_Request('http://www.tradedoubler.com/pan/aGEList.action?', $valuesFormExport);
             $exportReport = $this->_client->post($urls);
             for ($i = 0; $i < count($exportReport); $i++) {
                 if (preg_match_all("/javascript: showCode\\((.+)?\\)/", $exportReport[$i], $matches)) {
                     foreach ($matches[1] as $parameters) {
                         $paramatersArray = explode(',', $parameters);
                         $programId = $paramatersArray[1];
                         $graphicalElementId = $paramatersArray[0];
                         $affiliateId = $paramatersArray[3];
                         if (is_numeric($programId) && is_numeric($graphicalElementId) && is_numeric($affiliateId)) {
                             /**
                             			    				$creativesMap[(string)$programId][] = "<script type=\"text/javascript\">
                             																	   var uri = 'http://impgb.tradedoubler.com/imp?type(img)g($graphicalElementId)a($affiliateId)' + new String (Math.random()).substring (2, 11);
                             																	   document.write('<a href=\"http://clkuk.tradedoubler.com/click?p=$programId&a=$affiliateId&g=$graphicalElementId\" target=\"_BLANK\"><img src=\"'+uri+'\" border=0></a>');
                             																	   </script>";
                             			    				
                             								$creativesMap[(string)$programId][] = "<script type=\"text/javascript\">
                             																	   var uri = 'http://impgb.tradedoubler.com/imp?type(iframe)g($graphicalElementId)a($affiliateId)' + new String (Math.random()).substring (2, 11);
                             																	   document.write('<iframe src=\"'+uri +'\" width=\"234\" height=\"60\" frameborder=\"0\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"></iframe>');
                             																	   </script>";
                             								**/
                             $creativesMap[(string) $programId][] = "<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   var uri = 'http://impgb.tradedoubler.com/imp?type(js)g({$graphicalElementId})a({$affiliateId})' + new String (Math.random()).substring (2, 11);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   document.write('<sc'+'ript type=\"text/javascript\" src=\"'+uri+'\" charset=\"\"></sc'+'ript>');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   </script>";
                         }
                     }
                 }
             }
         }
     }
     return $creativesMap;
 }
예제 #9
0
 /**
  * Read the html table in the report
  * @param string $htmlReport
  * @param Zend_Date $startDate
  * @param Zend_Date $endDate
  * @param int $iteration
  * @return array:
  */
 public function readTransactionTable($htmlReport, Zend_Date $startDate, Zend_Date $endDate, $iteration = 0)
 {
     $transactions = array();
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($htmlReport);
     $tableList = $doc->getElementsByTagName('table');
     $tableNumber = $tableList->length;
     $registerTable = $tableList->item(14);
     if ($registerTable != null) {
         $registerLines = $registerTable->childNodes;
         for ($i = 0; $i < $registerLines->length; $i++) {
             $registerLine = $registerLines->item($i);
             $register = $registerLine->childNodes;
             if ($register->length == 30) {
                 $obj = array();
                 for ($j = 0; $j < $register->length; $j++) {
                     if ($j % 2 == 0) {
                         $attribute = $register->item($j);
                         $obj[] = str_replace('&nbsp', '', trim($attribute->nodeValue));
                     }
                 }
                 $transactions[] = $obj;
             }
         }
         if (preg_match("/<a href=\"(.*)\">\\|Next\\|<\\/a>/", $htmlReport, $matches)) {
             $iteration++;
             $urls = array();
             $parameters = array();
             $parameters[] = new Oara_Curl_Parameter('action', 'update');
             $parameters[] = new Oara_Curl_Parameter('Recid', $iteration * 100 + 1);
             $parameters[] = new Oara_Curl_Parameter('rangestart', $startDate->toString("yyyy-MM-dd"));
             $parameters[] = new Oara_Curl_Parameter('rangeend', $endDate->toString("yyyy-MM-dd"));
             $parameters[] = new Oara_Curl_Parameter('datetype', 'res');
             $parameters[] = new Oara_Curl_Parameter('strsearch', '');
             $parameters[] = new Oara_Curl_Parameter('confirm', '');
             $parameters[] = new Oara_Curl_Parameter('dated', '');
             $parameters[] = new Oara_Curl_Parameter('sort', 'resdate');
             $parameters[] = new Oara_Curl_Parameter('order', '');
             $parameters[] = new Oara_Curl_Parameter('subaccount', '');
             $urls[] = new Oara_Curl_Request('https://www.cartrawler.com/affengine/AFFxreservelist2.asp?', $parameters);
             $exportReport = $this->_client->get($urls);
             $transactions = array_merge($transactions, self::readTransactionTable($exportReport[0], $startDate, $endDate, $iteration));
         }
     }
     return $transactions;
 }
예제 #10
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('authl', $this->_credentials["user"]);
     $valuesFormExport[] = new Oara_Curl_Parameter('authv', $this->_credentials["apiPassword"]);
     $valuesFormExport[] = new Oara_Curl_Parameter('champs', 'idprogramme,date,etat,argann,montant,taux,monnaie,idsite');
     $valuesFormExport[] = new Oara_Curl_Parameter('debut', $dStartDate->toString("yyyy-MM-dd"));
     $valuesFormExport[] = new Oara_Curl_Parameter('fin', $dEndDate->toString("yyyy-MM-dd"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://stat.netaffiliation.com/requete.php?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     //sales
     $exportData = str_getcsv($exportReport[0], "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ";");
         if (in_array($transactionExportArray[0], $merchantList)) {
             $transaction = array();
             $transaction['merchantId'] = $transactionExportArray[0];
             $transactionDate = new Zend_Date($transactionExportArray[1], "dd/MM/yyyy HH:mm:ss");
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             if ($transactionExportArray[3] != null) {
                 $transaction['custom_id'] = $transactionExportArray[3];
             }
             if (strstr($transactionExportArray[2], 'v')) {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if (strstr($transactionExportArray[2], 'r')) {
                     $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                 } else {
                     if (strstr($transactionExportArray[2], 'a')) {
                         $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                     } else {
                         throw new Exception("Status not found");
                     }
                 }
             }
             $transaction['amount'] = $transactionExportArray[4];
             $transaction['commission'] = round($transactionExportArray[4] * $transactionExportArray[5] / 100, 2);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #11
0
 /**
  *
  * It returns the transactions for a payment
  * @param int $paymentId
  */
 public function paymentTransactions($paymentId, $merchantList, $startDate)
 {
     $transactionList = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('csv', 'csv');
     $valuesFormExport[] = new Oara_Curl_Parameter('ajax', 'ajax');
     $valuesFormExport[] = new Oara_Curl_Parameter('type', 'csv');
     $valuesFormExport[] = new Oara_Curl_Parameter('sortColumn', '');
     $valuesFormExport[] = new Oara_Curl_Parameter('sortType', '');
     $valuesFormExport[] = new Oara_Curl_Parameter('startdate', '');
     $valuesFormExport[] = new Oara_Curl_Parameter('enddate', '');
     $valuesFormExport[] = new Oara_Curl_Parameter('paymentid', $paymentId);
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://www.pepperjamnetwork.com/affiliate/report_payment_history_detail.php?', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $exportData = str_getcsv($exportReport[0], "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionArray = str_getcsv($exportData[$i], ",");
         $transactionList[] = $transactionArray[1];
     }
     return $transactionList;
 }
예제 #12
0
 /**
  * Read the html table in the report
  * @param string $htmlReport
  * @param Zend_Date $startDate
  * @param Zend_Date $endDate
  * @param int $iteration
  * @return array:
  */
 public function readTransactionTable($startDate, $endDate)
 {
     $transactions = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('mese', $startDate->toString("MM"));
     $valuesFormExport[] = new Oara_Curl_Parameter('anno', $endDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('vai', '  Go  ');
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://booking.terravision.eu/statsales.asp?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $tableList = $doc->getElementsByTagName('table');
     $clickNumber = substr($tableList->item(6)->childNodes->item(0)->childNodes->item(2)->nodeValue, 0, -2);
     $transactionNumber = $tableList->item(6)->childNodes->item(2)->childNodes->item(2)->nodeValue;
     if ($transactionNumber != 0) {
         $totalAmout = 0;
         $totalCommission = 0;
         if ($tableList->item(10)->childNodes->item(3) != null) {
             $totalAmout = str_replace(',', '.', str_replace('.', '', substr($tableList->item(10)->childNodes->item(3)->childNodes->item(2)->nodeValue, 5)));
             $totalCommission = str_replace(',', '.', str_replace('.', '', substr($tableList->item(10)->childNodes->item(6)->childNodes->item(2)->nodeValue, 4)));
         }
         $amountPerTransaction = $totalAmout / $transactionNumber;
         $commissionPerTransaction = $totalCommission / $transactionNumber;
         for ($i = 0; $i < $transactionNumber; $i++) {
             $obj = new stdClass();
             $obj->date = $endDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj->amount = $amountPerTransaction;
             $obj->commission = $commissionPerTransaction;
             $transactions[] = $obj;
         }
     }
     return $transactions;
 }
예제 #13
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFormExport = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://system.fashiontraffic.com/stats/lead_report', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $valuesFormExport = array();
     $hidden = $dom->query('#ConversionReportForm input[name="data[_Token][key]"][type="hidden"]');
     foreach ($hidden as $values) {
         $valuesFormExport[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $hidden = $dom->query('#ConversionReportForm input[name="data[_Token][fields]"][type="hidden"]');
     foreach ($hidden as $values) {
         $valuesFormExport[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $valuesFormExport[] = new Oara_Curl_Parameter("_method", 'POST');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][page]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.offer_id');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.datetime');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.ad_id');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.source');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info1');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info2');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info3');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info4');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info5');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.conversion_payout');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.conversion_status');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][search][field]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][search][value]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][timezone]", 'America/New_York');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][preset_date_range]", 'other');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][start_date]", $dStartDate->toString("yyyy-MM-dd"));
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][end_date]", $dEndDate->toString("yyyy-MM-dd"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://system.fashiontraffic.com/stats/lead_report', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $csvUrl = null;
     if (preg_match("/report:(.*).csv/", $exportReport[0], $match)) {
         $csvUrl = "http://system.fashiontraffic.com/stats/conversion_report/report:{$match[1]}.csv";
     }
     $valuesFormExport = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request($csvUrl, $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $exportData = str_getcsv($exportReport[0], "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (in_array((int) $transactionExportArray[0], $merchantList)) {
             $transaction = array();
             $merchantId = (int) $transactionExportArray[0];
             $transaction['merchantId'] = $merchantId;
             $transaction['date'] = $transactionExportArray[1];
             if ($transactionExportArray[5] != null) {
                 $transaction['custom_id'] = $transactionExportArray[5];
             }
             if ($transactionExportArray[10] == 'approved') {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[10] == 'rejected') {
                     $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                 } else {
                     throw new Exception("Status {$transactionExportArray[10]} unknown");
                 }
             }
             if (preg_match('/[-+]?[0-9]*\\.?[0-9]+/', $transactionExportArray[9], $match)) {
                 $transaction['amount'] = (double) $match[0];
             }
             if (preg_match('/[-+]?[0-9]*\\.?[0-9]+/', $transactionExportArray[9], $match)) {
                 $transaction['commission'] = (double) $match[0];
             }
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #14
0
 /**
  * Read the html table in the report
  *
  * @param string $htmlReport        	
  * @param Zend_Date $startDate        	
  * @param Zend_Date $endDate        	
  * @param int $iteration        	
  * @return array:
  */
 public function readTransactions($htmlReport)
 {
     $pdfContent = '';
     $dom = new Zend_Dom_Query($htmlReport);
     $links = $dom->query('.text a');
     $pdfUrl = null;
     foreach ($links as $link) {
         $pdfUrl = $link->getAttribute('href');
     }
     $urls = array();
     $urls[] = new Oara_Curl_Request($pdfUrl, array());
     $exportReport = $this->_client->get($urls);
     // writing temp pdf
     $exportReportUrl = explode('/', $pdfUrl);
     $exportReportUrl = $exportReportUrl[count($exportReportUrl) - 1];
     $dir = realpath(dirname(COOKIES_BASE_DIR)) . '/pdf/';
     $fh = fopen($dir . $exportReportUrl, 'w');
     fwrite($fh, $exportReport[0]);
     fclose($fh);
     // parsing the pdf
     $pipes = null;
     $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
     $pdfReader = proc_open("pdftohtml -xml -stdout " . $dir . $exportReportUrl, $descriptorspec, $pipes, null, null);
     if (is_resource($pdfReader)) {
         $pdfContent = '';
         $error = '';
         $stdin = $pipes[0];
         $stdout = $pipes[1];
         $stderr = $pipes[2];
         while (!feof($stdout)) {
             $pdfContent .= fgets($stdout);
         }
         while (!feof($stderr)) {
             $error .= fgets($stderr);
         }
         fclose($stdin);
         fclose($stdout);
         fclose($stderr);
         $exit_code = proc_close($pdfReader);
     }
     unlink($dir . $exportReportUrl);
     $xml = new SimpleXMLElement($pdfContent);
     $list = $xml->xpath("page");
     $numberPages = 0;
     $numberPages = count($list);
     $transationList = array();
     for ($page = 1; $page <= $numberPages; $page++) {
         $topHeader = null;
         $top = null;
         $list = $xml->xpath("page[@number={$page}]/text[@font=0 and b = \"Agent\"]");
         if (count($list) > 0) {
             $header = current($list);
             $attributes = $header->attributes();
             $top = (int) $attributes['top'];
         } else {
             throw new Exception("No Header Found");
         }
         if ($top == null) {
             throw new Exception("No Top Found");
         }
         $fromTop = $top - 3;
         $toTop = $top + 3;
         $list = $xml->xpath("page[@number={$page}]/text[@top>{$fromTop} and @top<{$toTop} and @font=0]");
         $headerList = array();
         foreach ($list as $header) {
             $xmlHeader = new stdClass();
             $attributes = $header->attributes();
             $xmlHeader->top = (int) $attributes['top'];
             $xmlHeader->left = (int) $attributes['left'];
             $xmlHeader->width = (int) $attributes['width'];
             foreach ($header->children() as $child) {
                 $xmlHeader->name = (string) $child;
             }
             if (strpos($xmlHeader->name, "commission") === false) {
                 $headerList[(int) $xmlHeader->left] = $xmlHeader;
             } else {
                 $xmlHeaderCommissionValue = new stdClass();
                 $xmlHeaderCommissionValue->top = $xmlHeader->top;
                 $xmlHeaderCommissionValue->left = $xmlHeader->left;
                 $xmlHeaderCommissionValue->width = 100;
                 $xmlHeaderCommissionValue->name = (string) "commissionValue";
                 $xmlHeaderCommission = new stdClass();
                 $xmlHeaderCommission->top = $xmlHeader->top;
                 $xmlHeaderCommission->left = $xmlHeader->left + $xmlHeaderCommissionValue->width;
                 $xmlHeaderCommission->width = 150;
                 $xmlHeaderCommission->name = (string) "commission";
                 $headerList[(int) $xmlHeaderCommissionValue->left] = $xmlHeaderCommissionValue;
                 $headerList[(int) $xmlHeaderCommission->left] = $xmlHeaderCommission;
             }
         }
         ksort($headerList);
         $list = $xml->xpath("page[@number={$page}]/text[@font=2]");
         $rowList = array();
         foreach ($list as $row) {
             $attributes = $row->attributes();
             $top = (int) $attributes['top'];
             if (!in_array($top, $rowList)) {
                 $rowList[] = $top;
             }
         }
         foreach ($rowList as $top) {
             $transaction = array();
             $list = $xml->xpath("page[@number={$page}]/text[@top={$top} and @font=2]");
             foreach ($list as $value) {
                 $attributes = $value->attributes();
                 $fromLeft = (int) $attributes['left'];
                 $toLeft = (int) ($attributes['left'] + $attributes['width']);
                 $i = 0;
                 $enc = false;
                 foreach ($headerList as $header) {
                     $headerFromLeft = $header->left;
                     $headerToLeft = $header->left + $header->width;
                     $between1 = self::between((int) $headerFromLeft, (int) $headerToLeft, (int) $fromLeft);
                     $between2 = self::between((int) $headerFromLeft, (int) $headerToLeft, (int) $toLeft);
                     $between3 = self::between((int) $fromLeft, (int) $toLeft, (int) $headerFromLeft);
                     $between4 = self::between((int) $fromLeft, (int) $toLeft, (int) $headerToLeft);
                     if ($between1 || $between2 || $between3 || $between4) {
                         $transaction[$header->name] = (string) $value;
                         break;
                     }
                 }
             }
             $transationList[] = $transaction;
         }
     }
     return $transationList;
 }
예제 #15
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $urls = array();
     $valuesFormExport = array();
     $urls[] = new Oara_Curl_Request('http://affiliate.globelink.co.uk/home/', $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $commmisionUrl = "";
     if (preg_match("/\\/profile\\/(.*)\\/sales/", $exportReport[0], $matches)) {
         $commmisionUrl = "http://affiliate.globelink.co.uk/profile/" . $matches[1] . "/sales/?";
     }
     $auxTransactionList = array();
     $page = 1;
     $exit = false;
     while (!$exit) {
         $urls = array();
         $valuesFormExport = array();
         $valuesFormExport[] = new Oara_Curl_Parameter('page', $page);
         $valuesFormExport[] = new Oara_Curl_Parameter('count', 20);
         $urls[] = new Oara_Curl_Request($commmisionUrl, $valuesFormExport);
         $exportReport = $this->_client->get($urls);
         $dom = new Zend_Dom_Query($exportReport[0]);
         $results = $dom->query('.affs-list-r');
         foreach ($results as $line) {
             $auxTransaction = array();
             foreach ($line->childNodes as $attribute) {
                 $value = trim((string) $attribute->nodeValue);
                 if (strlen($value) > 0) {
                     if ($value != "n/a") {
                         $auxTransaction[] = $value;
                     }
                 }
             }
             $auxTransactionList[] = $auxTransaction;
         }
         if (preg_match("/<li><span>&raquo;<\\/span><\\/li>/", $exportReport[0])) {
             $exit = true;
         }
         $page++;
     }
     foreach ($auxTransactionList as $auxTransaction) {
         $transactionDate = new Zend_Date($auxTransaction[0], "yyyy-MM-dd HH:mm:ss");
         if ($dStartDate->compare($transactionDate) <= 0 && $dEndDate->compare($transactionDate) >= 0) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['unique_id'] = $auxTransaction[1];
             if (strstr($auxTransaction[5], 'No')) {
                 $transaction['status'] = Oara_Utilities::STATUS_PENDING;
             } else {
                 if (strstr($auxTransaction[5], 'Yes')) {
                     $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
                 }
             }
             $transaction['amount'] = $auxTransaction[2];
             $transaction['commission'] = $auxTransaction[3];
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
예제 #16
0
 /**
  * 
  * Get the content for an url
  * @param unknown_type $websiteUrl
  */
 public function getContent($websiteUrl)
 {
     $content = null;
     if ($this->check_robot_txt($websiteUrl)) {
         $access = new Oara_Curl_Access($websiteUrl, 0);
         if ($access->_result) {
             $content = $access->_result;
         } else {
             echo "Problems accessing {$websiteUrl} \n\n";
         }
         $access->deleteCookie();
     } else {
         echo "Access forbidden by robot.txt {$websiteUrl} \n\n";
     }
     return $content;
 }
예제 #17
0
 private function readTransactionRef($csvExport, $dStartDate, $dEndDate)
 {
     $transactions = array();
     $transactionRef = array();
     $exportData = str_getcsv($csvExport, "\n");
     $num = count($exportData);
     for ($i = 3; $i < $num - 2; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (count($transactionExportArray) <= 1) {
             throw new Exception('Fail getting the transactions');
         }
         //to avoid the repeated transaction reference
         $transactionRef[$transactionExportArray[2]] = '';
     }
     $urls = array();
     foreach ($transactionRef as $ref => $nothing) {
         $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
         $valuesFormExport[] = new Oara_Curl_Parameter('startDayFilter', $dStartDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('startMonthFilter', $dStartDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('startYearFilter', $dStartDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endDayFilter', $dEndDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endMonthFilter', $dEndDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endYearFilter', $dEndDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartDayFilter', $dStartDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartMonthFilter', $dStartDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartYearFilter', $dStartDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndDayFilter', $dEndDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndMonthFilter', $dEndDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndYearFilter', $dEndDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('bookingRecord.idString', $ref);
         $urls[] = new Oara_Curl_Request('http://www.traveljigsawgroup.com/affiliates/AffiliateBookingRecord.do', $valuesFormExport);
     }
     if (count($urls) > 0) {
         $exportReport = $this->_client->post($urls);
         $num = count($exportReport);
         for ($z = 0; $z < $num; $z++) {
             $doc = new DOMDocument();
             libxml_use_internal_errors(true);
             $doc->validateOnParse = true;
             $doc->loadHTML($exportReport[$z]);
             $tableList = $doc->getElementsByTagName('table');
             $exportData1 = self::htmlToCsv(self::DOMinnerHTML($tableList->item(6)));
             $exportData3 = self::htmlToCsv(self::DOMinnerHTML($tableList->item(8)));
             $exportStatus = self::htmlToCsv(self::DOMinnerHTML($tableList->item(9)));
             $obj = array();
             $rowNum = count($exportData1);
             for ($i = 1; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportData1[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $rowNum = count($exportData3);
             for ($i = 1; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportData3[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $rowNum = count($exportStatus);
             for ($i = $rowNum - 2; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportStatus[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $transactions[] = $obj;
         }
     }
     return $transactions;
 }