Example #1
0
 public function runAction()
 {
     require $this->fileName;
     $o = $this->objName;
     mgTrace();
     $tmp = new $o();
     mgTrace(false);
     mgDebug('Create Module', $tmp);
     mgTrace();
     $output = $tmp->runModule($this->args);
     mgTrace(false);
     mgDebug('Run Module', $tmp);
     $this->stack['action']['content_type'] = "content-Type: text/html; charset={$this->stack['static_var']['charset']}";
     header($this->stack['action']['content_type']);
     echo Json::json_encode($output);
 }
Example #2
0
                    if (mb_strpos(mb_strtoupper($r['ground']), mb_strtoupper($Transact_array_)) !== false) {
                        // echo 'YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
                        // echo '<'.$r['ground'].'=='.$Transact_array_.'><br>';
                        $flag = true;
                        $ArrayCategories[$i][3] = floatval($ArrayCategories[$i][3] + floatval($r['Sum_']));
                    }
                }
            }
            if (!$flag and floatval($r['Sum_']) != 0) {
                $rows[] = array('Sum' => $r['Sum_'], 'Ground' => $r['ground']);
            }
        }
        //  print_r($rows);
        // print_r($ArrayCategories);
        foreach ($ArrayCategories as $ArrayCategories_) {
            if (floatval($ArrayCategories_[3]) != 0) {
                $rows[] = array('Sum' => $ArrayCategories_[3], 'Ground' => $ArrayCategories_[1]);
            }
        }
        //На всякий случай пишем сгуппированные данные в таблицу
        $sql = "delete from categoryoperations where  LoginId=" . $loginid;
        $delCatOper = query($sql);
        foreach ($rows as $rows_) {
            $sql = "insert into categoryoperations (LoginId,Sum,CategoryText) \n                     values ('" . $loginid . "','" . $rows_['Sum'] . "','" . $rows_['Ground'] . "' )";
            //echo $sql;
            $addCatOper = query($sql);
        }
        //--------------------------------------------------------
        echo Json::json_encode($rows);
    }
}
 /**
  * @param string $LoginName
  * @param string $Password
  * @return string $XML
  */
 public function SBERRestAccount($LoginName, $Password)
 {
     $Dir_path = str_replace('\\', '/', __DIR__);
     $logger = new Logger('logger_service');
     $logger->pushHandler(new StreamHandler($Dir_path . '/../logs/sber_json_debbug-' . $LoginName . '.log', Logger::DEBUG, false));
     $logger->pushHandler(new StreamHandler($Dir_path . '/../logs/sber_json_error-' . $LoginName . '.log', Logger::WARNING, false));
     $logger->pushHandler(new StreamHandler($Dir_path . '/../logs/sber_json_info-' . $LoginName . '.log', Logger::INFO, false));
     $logger->pushHandler(new FirePHPHandler());
     $logger->addInfo('------------------------------------------------------------------------------------------');
     $logger->addInfo('Start running SBERRestAccount class');
     $deviceprint = "deviceprintversion=3.4.0.0_2&pm_fpua=mozilla/5.0 (windows nt 6.3) applewebkit/537.36 (khtml, like gecko) chrome/36.0.1985.143 safari/537.36|5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36|Win32&pm_fpsc=24|1280|1024|984&pm_fpsw=&pm_fptz=4&pm_fpln=lang=ru|syslang=|userlang=&pm_fpjv=1&pm_fpco=1&pm_fpasw=widevinecdmadapter|pepflashplayer|internal-remoting-viewer|ppgooglenaclpluginchrome|pdf|npspwrap|npbssplugin|npgoogleupdate3|npdeployjava1|npjp2|npmeetingjoinpluginoc|npvlc|npitunes|npctrl&pm_fpan=Netscape&pm_fpacn=Mozilla&pm_fpol=true&pm_fposp=&pm_fpup=&pm_fpsaw=1280&pm_fpspd=24&pm_fpsbd=&pm_fpsdx=&pm_fpsdy=&pm_fpslx=&pm_fpsly=&pm_fpsfse=&pm_fpsui=&pm_os=Windows&pm_brmjv=36&pm_br=Chrome&pm_inpt=&pm_expt=";
     $htmlinjection = 'htmlinjection={"functions":{"names":[],"excluded":{"size":0,"count":0},"truncated":false},"inputs":[],"iframes":[],"scripts":[],"collection_status":3}';
     $manvsmachinedetection = 'manvsmachinedetection=1,1,INPUT:text,6;2,2,INPUT:text,22@1,3,0;1,1,0;1,1,0;1,1,0;1,1,0;1,1,0;1,1,0;1,1,0;1,4,0@0,1409563058988,0';
     $postData = urldecode('field(login)=' . $LoginName . '&field(password)=' . $Password . '&operation=button.begin&' . $deviceprint . '&' . $htmlinjection . '&' . $manvsmachinedetection);
     //$postData=  urldecode('field(login)='.$LoginName.'&field(password)='.$Password).'&operation=button.begin';
     //$logger->addInfo('>>>>>'.$postData);
     $data = http_requestSDM('https://online.sberbank.ru/CSAFront/index.do', false, '', false, '', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537', 30);
     if (!$data) {
         $logger->addError('не можем получить информацию по счетам URL 1');
         return 'не можем получить информацию по счетам';
     }
     $logger->addDebug('DATA1:' . $data . 'END DATA1');
     $cookie = substr($data, strpos($data, 'cookie=') + 7, strlen($data));
     $logger->addInfo('COOKIE1:' . $cookie . 'END DATA 1');
     $data = http_requestSDM('https://online.sberbank.ru/CSAFront/login.do', true, $postData, false, $cookie, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537', 30);
     if (!$data) {
         $logger->addError('не можем получить информацию по счетам URL 2');
         return 'не можем получить информацию по счетам';
     }
     $logger->addDebug('DATA2:' . $data . 'END DATA2');
     $URL_WITH_TOKEN = str_replace(';cookie=', '', str_replace('">', '', strstr($data, 'https')));
     if (!$URL_WITH_TOKEN) {
         $logger->addError('нет кукисов - возможно введен неверный пароль URL_WITH_TOKEN!');
         return 'нет кукисов - возможно введен неверный пароль!';
     }
     $logger->addInfo($URL_WITH_TOKEN);
     $data = http_requestSDM($URL_WITH_TOKEN, true, '', false, $cookie, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537', 30);
     if (!$data) {
         return 'не можем получить информацию по счетам URL 3';
     }
     $cookie = substr($data, strpos($data, 'cookie=') + 7, strlen($data));
     $logger->addInfo('COOKIE3:' . $cookie);
     $logger->addDebug('DATA3:' . $data . 'END DATA 3');
     //$data=  http_request('https://online.sberbank.ru/PhizIC/private/accounts.do',true, '' ,false,$cookie,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36',60);
     //$data=  http_requestSDM('https://online.sberbank.ru/PhizIC/private/cards/list.do',true, '' ,false,$cookie,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537',30);
     $data = http_requestSDM('https://node2.online.sberbank.ru/PhizIC/private/cards/list.do', true, '', false, $cookie, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537', 30);
     if (!$data) {
         return 'не можем получить информацию по счетам';
     }
     $logger->addDebug('DATA4:' . $data . 'END DATA 4');
     $body = substr($data, strpos($data, 'body=') + 5, -8);
     //  echo($body);
     if (!$body) {
         return 'не можем получить информацию по счетам';
     }
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->loadHTML($body);
     libxml_clear_errors();
     $xpath = new DOMXPath($doc);
     $CardProductName = $xpath->query('//div[@class="productCover activeProduct"]//span[@class="mainProductTitle mainProductTitleLight"]');
     //$CardProductName = $xpath->query('//span[@class="mainProductTitle mainProductTitleLight"]');
     $CardNumber = $xpath->query('//div[@class="accountNumber decoration-none"]');
     $CardAmount = $xpath->query('//span[@class="overallAmount nowrap"] | //span[@class="overallAmount nowrap negativeAmount"]');
     $CardhRef = $xpath->query('//div[@class="productName"]//a[contains(@href,"/PhizIC/private/cards/info.do?id=")]');
     $CardsArray = '';
     $ArrayAccountID = '';
     $logger->addInfo('Count CardProductName=' . count($CardProductName));
     $logger->addInfo('Count CardNumber=' . count($CardNumber));
     $logger->addInfo('Count CardAmount=' . count($CardAmount));
     $logger->addInfo('Count CardhRef=' . count($CardhRef));
     $i = 0;
     foreach ($CardProductName as $CardProductName_) {
         $logger->addInfo('for I=' . $i);
         $logger->addInfo('CardProductName:' . GetCardProductNameSber($CardProductName_));
         $logger->addInfo('CardNumber:' . GetCardNumberSber($CardNumber->item($i)));
         $logger->addInfo('CardAmount:' . nodeContent($CardAmount->item($i)));
         $logger->addInfo('CardhRef:' . GetCardhRefValueSber($CardhRef->item($i)));
         $CardsArray[] = GetCardProductNameSber($CardProductName->item($i));
         $CardsArray[] = GetCardNumberSber($CardNumber->item($i));
         $CardsArray[] = nodeContent($CardAmount->item($i));
         $CardsArray[] = GetCardhRefValueSber($CardhRef->item($i));
         $ArrayAccountID[] = GetCardhRefValueSber($CardhRef->item($i));
         //Попробуем с кодами валют
         $logger->addInfo('CurrCode:' . CurrCodeSber($CardAmount->item($i)));
         $CardsArray[] = CurrCodeSber($CardAmount->item($i));
         $i++;
     }
     $json = array("AccountsList" => array(), "CardList" => array(), "AcountStatements" => array());
     $logger->addInfo('>>>>>RealResult starting');
     $logger->addInfo('Count Array=' . count($CardsArray));
     for ($i = 0; $i < count($CardsArray) / 5; $i++) {
         for ($j = 0; $j < 5; $j++) {
             //echo ('i='.$i.';j='.$j.'<br>');
             switch ($j) {
                 case 0:
                     $logger->addInfo('CardProductName:' . $CardsArray[$i * 5 + $j]);
                     $CardType = $CardsArray[$i * 5 + $j];
                     break;
                 case 1:
                     $logger->addInfo('CardNumber:' . $CardsArray[$i * 5 + $j]);
                     $CardNumber = $CardsArray[$i * 5 + $j];
                     break;
                 case 2:
                     $logger->addInfo('CardAmount:' . $CardsArray[$i * 5 + $j]);
                     $Rest = str_replace(",", ".", str_replace(' ', '', $CardsArray[$i * 5 + $j]));
                     break;
                 case 3:
                     $logger->addInfo('CardhRef:' . $CardsArray[$i * 5 + $j]);
                     $CardID = $CardsArray[$i * 5 + $j];
                     break;
                 case 4:
                     $logger->addInfo('CurrCode:' . $CardsArray[$i * 5 + $j]);
                     $CurrCode = $CardsArray[$i * 5 + $j];
                     break;
                 default:
                     break;
             }
         }
         if ($CardType != '') {
             $json["CardList"][] = array("CardType" => $CardType, "CardNumber" => $CardNumber, "Rest" => $Rest, "CardID" => $CardID, "CurrCode" => $CurrCode);
         }
     }
     //https://online.sberbank.ru/PhizIC/private/cards/print.do?id=9045783&printAbstract=true
     /*
     foreach ($ArrayAccountID as $ArrayAccountID_)
         {
       //  sel:c:9045783
     //fromDateString:01/01/2014
     //toDateString:03/03/2014
       //  $postData= 'fromDateString=01/01/2014&toDateString=03/0132014&sel:c:9045783';
         $data=  http_request('https://online.sberbank.ru/PhizIC/private/accounts/print.do?sel=c:'.$ArrayAccountID_.'&fromDateString=01/01/2014&toDateString=03/03/2014',true, '' ,false,$cookie,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537',30);
         if (!$data) {
                $logger->addError('не можем получить информацию по выписке');
                //return 'не можем получить информацию по выписке';
            }
         $logger->addDebug('DATA5_STATEMENT1:'.$data.'END DATA5_STATEMENT1');
     
     
          $body=substr($data,strpos($data, 'body=')+5,-8);
          $logger->addDebug('DATA5:'.$body.'END DATA 5');
        
          $doc->loadHTML($body);
          libxml_clear_errors();
          $xpath = new DOMXPath($doc);
     
     $logger->addInfo('STATEMENT7:');
           //Выписка                      
          $TableTrStatement = $xpath->query('//table');
                    foreach ($TableTrStatement as $tag1) {
                       $logger->addInfo('NodeContent1:'.($tag1->nodeValue));
               }  
              
         
         }*/
     $logger->addInfo('Good result: ' . Json::json_encode($json));
     $logger->addInfo('End SBERRestAccount class');
     return Json::json_encode($json);
 }