Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ZANOX
- * -----------------------------------------------------------------------------
- */
- class AffiliStat_Zanox extends AffiliStat implements iAffiliStat
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function __destruct()
- {
- parent::__destruct();
- }
- /**
- * Connexion
- */
- public function login()
- {
- $URL = 'https://ui.zanox.com/bin/z_in_frm.dll?1001100110030&0c0&201_981202310868_113_201';
- $data = array(
- 't_login_user_name' => $this->login,
- 't_login_password' => $this->passe,
- 'fx_loginform' => '',
- 'b_next' => 'Ouvrir+une+session',
- );
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- curl_setopt($this->ch, CURLOPT_HEADER, true);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->implode_array($data));
- curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- //curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($this->ch);
- // echo $String;
- $mes_static = preg_replace('|.*statistic.html\?([^"]*)" class="head_nav_main_normal">.*|is','$1',$String);
- $mes_static = str_replace('&','&',$mes_static);
- // echo $mes_static;
- /**
- * Mes statistiques
- */
- $URL = 'https://publisher.zanox.com/publisher_stats_classic/statistic.html?' . $mes_static;
- //echo $URL;
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
- $String = curl_exec($this->ch);
- //echo $String;
- //preg_match('|.*<a href="([^"]*)">Lien sur les statistiques.*|is', $String, $rawmes_static);
- //$mes_static = $rawmes_static[1];
- preg_match('/<li class="releaseHistoryLinkItem"><a href="([^"]*)/', $String, $rawurl);
- $mes_static = $rawurl[1];
- //print_r($rawurl);
- // $mes_static = str_replace('&','&',$mes_static);
- //echo $mes_static;
- /**
- * Mes statistiques
- */
- $URL = $mes_static;
- //echo $URL;
- //$ch = curl_init();
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
- //curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- //curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($this->ch);
- //echo $String;
- preg_match('/<a class="prmreiter_nonactiv" style="border:0px;" href="([^"]*)/', $String, $rawurl2);
- $stat_det = $rawurl2[1];
- //echo $stat_det;
- // $stat_det = preg_replace('|.*style="border:0px;" href="([^"]*)">Statistiques détaillées.*|is','$1',$String);
- // $stat_det = str_replace('&','&',$stat_det);
- /**
- * On récupère le lien "action" des stats en temps réél
- */
- preg_match('/<form method="post" action="([^"]*)/', $String, $rawurl3);
- $stat_reel = $rawurl3[1];
- //echo $stat_reel;
- //$stat_reel = preg_replace('|.*<form method="post" action="([^"]*)" id="fx_form" name="tstest">.*|is','$1',$String);
- //$stat_reel = str_replace('&','&',$stat_reel);
- $this->stat_reel = $stat_reel;
- /**
- * Stat détaillé
- */
- $URL = $stat_det;
- //echo $URL;
- //$ch = curl_init();
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- /*
- curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- */
- $String = curl_exec($this->ch);
- //echo $String;
- //curl_close($ch);
- $stat_custom = preg_replace('|.*<form method="post" action="([^"]*)" id="fx_form" name="tstest">.*|is','$1',$String);
- $this->stat_custom = str_replace('&','&',$stat_custom);
- //echo $this->stat_custom.'<br /><br />';
- // on enregistre quelques données de sessions Zanox
- $arrRecord = array($this->_getRecordValue() =>
- array(
- 'mes_static' => $mes_static,
- 'time' => time(),
- 'stat_custom' => $this->stat_custom,
- 'stat_reel' => $this->stat_reel
- )
- );
- $this->_setRecord($arrRecord);
- }
- /**
- * Stats par jour
- */
- public function parJour($parDate=NULL, $moinsJour=NULL)
- {
- if ($moinsJour == 0 && !isset($this->param['channel']) )
- {
- $data = array(
- 'd_accounting_currency' => '1',
- 'r_light_report_select' => '1',
- 'b_next' => 'Afficher+les+Stats'
- );
- $URL = $this->stat_reel;
- //$ch = curl_init();
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->implode_array($data));
- //curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- //curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($this->ch);
- //curl_close($ch);
- $total = preg_replace('|.*Total.*right(.*) </div>.*<!-- result navi -->.*|is','$1',$String);
- $total = str_replace(',','.',ereg_replace("[^0-9,]","",$total));
- $return = array();
- $return[$parDate] = $total;
- return $return;
- }
- else
- {
- if ($moinsJour !== NULL)
- {
- $parDate = date('d/m/Y',time()-3600*24*$moinsJour);
- }
- $dateZanox = str_replace('/','.',$parDate);
- //echo $dateZanox;
- $data = $this->_parametreDay($dateZanox);
- $URL = $this->stat_custom;
- //$ch = curl_init();
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->implode_array($data));
- //curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- //curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($this->ch);
- //echo '<br /><br />STRING--<br />'.$String.'<br /><br />';
- //curl_close($ch);
- $total = preg_replace('|.*Total.*right(.*) </div>.*<!-- result navi -->.*|is','$1',$String);
- $total = str_replace(',','.',ereg_replace("[^0-9,]","",$total));
- $return = array();
- $return[$parDate] = $total;
- return $return;
- }
- }
- /**
- * Stats par mois
- */
- public function parMois($mois=NULL, $an=NULL, $moinsMois=NULL)
- {
- if ($moinsMois !== NULL)
- {
- $leMois = date('m/Y',strtotime('-' . $moinsMois . ' month'));
- $data = $this->_parametreMois(
- date('Y',strtotime('-' . $moinsMois . ' month')),
- date('m',strtotime('-' . $moinsMois . ' month')));
- }
- elseif ($mois !== NULL && $an !== NULL)
- {
- $leMois = $mois.'/'.$an;
- $data = $this->_parametreMois(
- $an,
- $mois);
- }
- $URL = $this->stat_custom;
- //$ch = curl_init();
- curl_setopt($this->ch, CURLOPT_URL, $URL);
- //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->implode_array($data));
- //curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- //curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($this->ch);
- //curl_close($ch);
- $total = preg_replace('|.*Total.*right(.*) </div>.*<!-- result navi -->.*|is','$1',$String);
- $total = str_replace(',','.',ereg_replace("[^0-9,]","",$total));
- $return = array();
- $return[$leMois] = $total;
- return $return;
- }
- /**
- * On est connecté ?
- public function isConnecte()
- {
- $arrRecordFile = $this->_getRecord();
- $arrRecordFile = $arrRecordFile[$this->_getRecordValue()];
- if (isset($arrRecordFile))
- {
- $diffTime = time()-(int)$arrRecordFile['time'];
- if ($arrRecordFile['mes_static'] == 'wait')
- {
- sleep(6);
- $arrRecordFile = $this->_getRecord();
- $arrRecordFile = $arrRecordFile[$this->_getRecordValue()];
- }
- if ($diffTime < (15*60))
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $arrRecordFile['mes_static']);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_getCookie());
- curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_getCookie());
- $String = curl_exec($ch);
- curl_close($ch);
- if (!preg_match('|.*Erreur.*|is',$String) && !preg_match('|.*Error.*|is',$String))
- {
- $this->stat_custom = $arrRecordFile['stat_custom'];
- $this->stat_reel = $arrRecordFile['stat_reel'];
- return true;
- }
- }
- }
- // on enregistre quelques données de sessions Zanox
- $arrRecord = array($this->_getRecordValue() =>
- array(
- 'mes_static' => 'wait'
- )
- );
- $this->_setRecord($arrRecord);
- return false;
- }
- */
- /**
- * Fonction
- */
- private function _parametreDay ($date)
- {
- return array(
- 'b_next' => 'any',
- 't_date' => $date,
- 'd_website_name' => '0',
- 'd_adbox_name' => '0',
- 'd_prog_name' => '0',
- 'd_link_name' => '0',
- 'd_accounting_currency' => '1',
- 'c_show_view' => 'c_show_view',
- 'c_show_click' => 'c_show_click',
- 'c_show_lead' => 'c_show_lead',
- 'c_show_sale' => 'c_show_sale',
- 'd_screen_file' => '0',
- 'd_group' => '1',
- );
- }
- private function _parametreMois ($dateAn, $dateMois)
- {
- $data = array(
- 'b_next' => 'any',
- 'd_periode_year' => $dateAn,
- 'd_periode_month' => $dateMois,
- 'd_periode_week' => '0',
- 't_date' => '',
- 'd_adbox_name' => '0',
- 'd_prog_name' => '0',
- 'd_link_name' => '0',
- 'd_accounting_currency' => '1',
- 'c_show_view' => 'c_show_view',
- 'c_show_click' => 'c_show_click',
- 'c_show_lead' => 'c_show_lead',
- 'c_show_sale' => 'c_show_sale',
- 'd_screen_file' => '0',
- 'd_group' => '1',
- );
- if (isset($this->param['channel']) && !empty($this->param['channel']))
- {
- $data += array('d_website_name' => $this->param['channel']);
- }
- else
- {
- $data += array('d_website_name' => '0');
- }
- return $data;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement