Advertisement
Guest User

Untitled

a guest
Mar 25th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. <?php
  2. /* Script Cek Mutasi V2 */
  3. /* Mblo.co, 2015 */
  4.  
  5. //error_reporting( 0 );
  6. include('app/lib/config.php');
  7. $arrs = array();
  8. $no = array();
  9. $no['jumlah'] = 0;
  10. $no['total'] = 0;
  11. $no['val'] = '';
  12.  
  13. if (!function_exists('curl_init')){
  14. die('Maaf cURL Tidak Terpasang!');
  15. }
  16.  
  17. function hasilcek( $a, $b = 0, $c, $d, $e )
  18. {
  19. global $no;
  20.  
  21. /* Variabel hasil cek mutasi */
  22. $hasil['jumlah'] = $a; // Jumlah / Total yang dimutasi
  23. $hasil['tanggal'] = $b; //Tanggal Mutasi
  24. $hasil['detail'] = $c; // Detail Mutasi
  25. $hasil['bank'] = $d; // Bank Mutasi
  26. $hasil['tipe'] = $e;
  27. $no['jumlah']++; // Count Jumlah Semua Mutasi
  28. $no['total'] = $no['total'] + $hasil['jumlah']; // Count Total Semua Mutasi
  29.  
  30. /* Uncomment baris dibawah untuk mengaktifkan fungsi */
  31. // kirimEmail('EMAIL-ANDA', 'HOST-EMAIL', 'PORT-EMAIL', 'ssl/tls/none', 'PASSWORD_EMAIL', $hasil); // Kirim Hasil Data Cek Mutasi Ke Email
  32. // masukkanKeDB($hasil); // Masukkan Hasil Data Cek Mutasi Ke Database
  33. // pushKeURL('URL-PUSH', $hasil); // Push Hasil Data Cek Mutasi Ke URL
  34. // SengGrid('api_name', 'api_key', 'EMAIL_TUJUAN',$hasil); // Kirim Hasil Data Cek Mutasi Ke Email Via SendGrid
  35.  
  36. /* Script yang akan dijalankan setelah mutasi diterima */
  37. //$no['val'] = $no['val'] . "------<br/>Dari Bank: ".$hasil['bank']."<br/>Jumlah: ".$hasil['jumlah']."<br/>Tanggal: ".$hasil['tanggal']."<br/>Detail: ".$hasil['detail']."------<br/><br/>";
  38. // echo $hasil['jumlah'].'<br/>'.$hasil['detail'];
  39. /* End */
  40. $arrs[] = array($b, $c, $e, $a);
  41. }
  42.  
  43. /* Cek BRI */
  44. include('app/lib/ambil.bri.php');
  45.  
  46. echo print_r($arrs, 1);
  47.  
  48. function kirimEmail( $email, $host, $port, $security, $password, $hasil )
  49. {
  50. require_once 'app/lib/PHPMailerAutoload.php';
  51.  
  52. $mail = new PHPMailer;
  53.  
  54. //$mail->SMTPDebug = 3; // Enable verbose debug output
  55.  
  56. $mail->isSMTP(); // Set mailer to use SMTP
  57. $mail->Host = $host; // Specify main and backup SMTP servers
  58. $mail->SMTPAuth = true; // Enable SMTP authentication
  59. $mail->Username = $email; // SMTP username
  60. $mail->Password = $password; // SMTP password
  61. $mail->SMTPSecure = 'none'; // Enable encryption, `ssl` also accepted
  62. $mail->Port = 25; // TCP port to connect to
  63.  
  64. $mail->setFrom( $email, 'Mblo.co Cek Mutasi' );
  65.  
  66. $mail->isHTML( true ); // Set email format to HTML
  67.  
  68. $mail->Subject = 'Ada Mutasi Di Bank: '.$hasil['bank'];
  69. $mail->Body = "------<br/>Dari Bank: ".$hasil['bank']."<br/>Jumlah: ".$hasil['jumlah']."<br/>Tanggal: ".$hasil['tanggal']."<br/>Detail: ".$hasil['detail']."<br/>------<br/><br/>";
  70.  
  71. if ( !$mail->send() ) {
  72. echo 'Pesan Tidak Dapat Dikirim.';
  73. echo 'Mailer Error: ' . $mail->ErrorInfo;
  74. } else {
  75. echo 'Pesan Telah Dikirimkan<br/>';
  76. }
  77. }
  78.  
  79. function masukkanKeDB( $hasil, $tabel)
  80. {
  81. global $option;
  82. $conn = @mysqli_connect ($option['db_host'], $option['db_username'], $option['db_password'], $option['db_name']);
  83.  
  84. if(!$conn){
  85. die( "Database Error: ".mysqli_error($conn));
  86. }
  87.  
  88. $a = $hasil['jumlah']; // Jumlah / Total yang dimutasi
  89. $b = $hasil['tanggal']; //Tanggal Mutasi
  90. $c = $hasil['detail']; // Detail Mutasi
  91. $d = $hasil['bank']; // Bank Mutasi
  92.  
  93. $q = mysqli_query($conn, "INSERT INTO $tabel VALUES(DEFAULT, '$a', '$b', '$c', '$d')");
  94.  
  95. if((!$q)) echo 'Error saat insert ke database<br/>';
  96. }
  97.  
  98. function pushKeURL( $url, $hasil = 0)
  99. {
  100. // Silahkan gunakan urldecode dan serialize pada script / kode di URL tujuan untuk mengambil hasil array dari fungsi pushKeURL
  101. $ch = curl_init();
  102. if($hasil) {
  103. curl_setopt($ch, CURLOPT_URL, $url.urlencode(serialize($hasil)));
  104. } else {
  105. curl_setopt($ch, CURLOPT_URL, $url);
  106. }
  107. curl_setopt($ch, CURLOPT_HEADER, 0);
  108. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  109. curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36' );
  110. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  111. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  112. curl_setopt($ch, CURLOPT_TIMEOUT,4);
  113. $results = curl_exec($ch);
  114.  
  115. return $results;
  116. }
  117.  
  118. function SendGrid( $username, $password, $email, $hasil )
  119. {
  120.  
  121. $ch = curl_init();
  122. curl_setopt($ch, CURLOPT_URL, 'https://api.sendgrid.com/api/mail.send.json');
  123. curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_user='.$username.'&api_key='.$password.'&to='.$email.'&from='.$email.'&fromname=Mblo Cek Mutasi&subject='.urlencode('Ada Mutasi Di Bank: '.$hasil['bank']).'&html='.urlencode('Dari Bank: '.$hasil['bank'].'<br/>Jumlah: '.$hasil['jumlah'].'<br/>Tanggal: '.$hasil['tanggal'].'<br/>Detail: '.$hasil['detail']));
  124. curl_setopt($ch, CURLOPT_HEADER, 0);
  125. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  126. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  127. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  128. curl_setopt($ch, CURLOPT_TIMEOUT,4);
  129. curl_setopt($ch, CURLOPT_POST, 1);
  130. $results = curl_exec($ch);
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement