Advertisement
pastebinmu

Class curl BCA

Nov 28th, 2016
2,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.33 KB | None | 0 0
  1. <?php //
  2.  
  3. // Author :  ramadhansepmprot
  4.  
  5.  
  6.  
  7. define('URL_LOGIN', 'https://ibank.klikbca.com/authentication.do');
  8. define('URL_SALDO', 'https://ibank.klikbca.com/balanceinquiry.do');
  9. define('URL_MUTASI_INDEX', 'https://ibank.klikbca.com/accountstmt.do?value(actions)=acct_stmt');
  10. define('URL_MUTASI_VIEW', 'https://ibank.klikbca.com/accountstmt.do?value(actions)=acctstmtview');
  11. define('URL_MUTASI_DOWNLOAD', 'https://ibank.klikbca.com/stmtdownload.do?value(actions)=account_statement');
  12.  
  13.  
  14.  
  15. class klikbca_by_semprot {
  16.  
  17.     var $ch = false;
  18.  
  19.     var $ip = '';
  20.  
  21.     var $last_html = '';
  22.  
  23.     var $logged_in = false;
  24.  
  25.     var $password = 'password_saya';
  26.  
  27.     var $username = 'username_saya';
  28.  
  29.  
  30.  
  31.     function klikbca_by_semprot() {
  32.  
  33.         $this->ip = $_SERVER['REMOTE_ADDR'];
  34.  
  35.         $this->logged_in = false;
  36.  
  37.     }
  38.  
  39.     function cek_saldo() {
  40.  
  41.         if ($this->logged_in == false) {
  42.  
  43.             //trigger_error('LOGIN FIRST', E_USER_WARNING);
  44.  
  45.             //return false;
  46.  
  47.         }
  48.  
  49.         $res = $this->my_curl_get(URL_SALDO);
  50.  
  51.         $this->last_html = $res['response'];
  52.  
  53.         preg_match_all('/color=\"\#0000bb\"\>([ ]+)?([0-9\,]+)/i', $res['response'], $match);
  54.  
  55.         //echo '<pre>';print_r($match);echo '</pre>';
  56.  
  57.         return true;
  58.  
  59.     }
  60.  
  61.  
  62.  
  63.     function login() {
  64.  
  65.         $this->logged_in = false;
  66.  
  67.         $data = array(
  68.  
  69.             'value(actions)' => 'login',
  70.  
  71.             'value(user_id)' => $this->username,
  72.  
  73.             'value(user_ip)' => $this->ip,
  74.  
  75.             'value(pswd)' => $this->password,
  76.  
  77.             'value(Submit)' => 'LOGIN'
  78.  
  79.             );
  80.  
  81.         $data = http_build_query($data);
  82.  
  83.         $res = $this->my_curl_post(URL_LOGIN, $data);
  84.  
  85.         $this->last_html = $res['response'];
  86.  
  87.         if (preg_match('/value\(user_id\)/i', $res['response'])) {
  88.  
  89.             trigger_error('CAN NOT LOGIN TO KLIKBCA', E_USER_WARNING);
  90.  
  91.             return false;
  92.  
  93.         }
  94.  
  95.         $this->logged_in = true;
  96.  
  97.         return true;
  98.  
  99.     }
  100.  
  101.  
  102.  
  103.     function my_curl_close() {
  104.  
  105.         if ($this->ch != false) {
  106.  
  107.             curl_close($this->ch);
  108.  
  109.         }
  110.  
  111.     }
  112.  
  113.  
  114.  
  115.     function my_curl_get($url, $ref = '') {
  116.  
  117.         if ($this->ch == false) {
  118.  
  119.             $this->my_curl_open();
  120.  
  121.         }
  122.  
  123.         $ssl = false;
  124.  
  125.         if (preg_match('/^https/i', $url)) {
  126.  
  127.             $ssl = true;
  128.  
  129.         }
  130.  
  131.         if ($ssl) {
  132.  
  133.             curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
  134.  
  135.         }
  136.  
  137.         if ($ref == '') {
  138.  
  139.             $ref = $url;
  140.  
  141.         }
  142.  
  143.         curl_setopt($this->ch, CURLOPT_URL, $url);
  144.  
  145.         curl_setopt($this->ch, CURLOPT_REFERER, $ref);
  146.  
  147.         $res = curl_exec($this->ch);
  148.  
  149.         $info = curl_getinfo($this->ch);
  150.  
  151.         return array(
  152.  
  153.             'response' => trim($res),
  154.  
  155.             'info' => $info
  156.  
  157.             );
  158.  
  159.     }
  160.  
  161.  
  162.  
  163.     function my_curl_open() {
  164.  
  165.         $this->ch = curl_init();
  166.  
  167.         curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
  168.  
  169.         curl_setopt($this->ch, CURLOPT_AUTOREFERER, true);
  170.  
  171.         @curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
  172.  
  173.         curl_setopt($this->ch, CURLOPT_MAXREDIRS, 2);
  174.  
  175.         curl_setopt($this->ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/curl-cookie.txt');
  176.  
  177.         curl_setopt($this->ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/curl-cookie.txt');
  178.  
  179.         curl_setopt($this->ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  180.  
  181.     }
  182.  
  183.  
  184.  
  185.     function my_curl_post($url, $post_data, $ref = '') {
  186.  
  187.         if ($this->ch == false) {
  188.  
  189.             $this->my_curl_open();
  190.  
  191.         }
  192.  
  193.         $ssl = false;
  194.  
  195.         if (preg_match('/^https/i', $url)) {
  196.  
  197.             $ssl = true;
  198.  
  199.         }
  200.  
  201.         if ($ssl) {
  202.  
  203.             curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
  204.  
  205.         }
  206.  
  207.         if ($ref == '') {
  208.  
  209.             $ref = $url;
  210.  
  211.         }
  212.  
  213.         curl_setopt($this->ch, CURLOPT_URL, $url);
  214.  
  215.         curl_setopt($this->ch, CURLOPT_REFERER, $ref);
  216.  
  217.         curl_setopt($this->ch, CURLOPT_POST, 1);
  218.  
  219.         curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_data);
  220.  
  221.         $res = curl_exec($this->ch);
  222.  
  223.         $info = curl_getinfo($this->ch);
  224.  
  225.         return array(
  226.  
  227.             'response' => trim($res),
  228.  
  229.             'info' => $info
  230.  
  231.             );
  232.  
  233.     }
  234.  
  235. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement