Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Script Cek Mutasi V2 */
- /* Mblo.co, 2015 */
- //error_reporting( 0 );
- include('app/lib/config.php');
- $arrs = array();
- $no = array();
- $no['jumlah'] = 0;
- $no['total'] = 0;
- $no['val'] = '';
- if (!function_exists('curl_init')){
- die('Maaf cURL Tidak Terpasang!');
- }
- function hasilcek( $a, $b = 0, $c, $d, $e )
- {
- global $no;
- /* Variabel hasil cek mutasi */
- $hasil['jumlah'] = $a; // Jumlah / Total yang dimutasi
- $hasil['tanggal'] = $b; //Tanggal Mutasi
- $hasil['detail'] = $c; // Detail Mutasi
- $hasil['bank'] = $d; // Bank Mutasi
- $hasil['tipe'] = $e;
- $no['jumlah']++; // Count Jumlah Semua Mutasi
- $no['total'] = $no['total'] + $hasil['jumlah']; // Count Total Semua Mutasi
- /* Uncomment baris dibawah untuk mengaktifkan fungsi */
- // kirimEmail('EMAIL-ANDA', 'HOST-EMAIL', 'PORT-EMAIL', 'ssl/tls/none', 'PASSWORD_EMAIL', $hasil); // Kirim Hasil Data Cek Mutasi Ke Email
- // masukkanKeDB($hasil); // Masukkan Hasil Data Cek Mutasi Ke Database
- // pushKeURL('URL-PUSH', $hasil); // Push Hasil Data Cek Mutasi Ke URL
- // SengGrid('api_name', 'api_key', 'EMAIL_TUJUAN',$hasil); // Kirim Hasil Data Cek Mutasi Ke Email Via SendGrid
- /* Script yang akan dijalankan setelah mutasi diterima */
- //$no['val'] = $no['val'] . "------<br/>Dari Bank: ".$hasil['bank']."<br/>Jumlah: ".$hasil['jumlah']."<br/>Tanggal: ".$hasil['tanggal']."<br/>Detail: ".$hasil['detail']."------<br/><br/>";
- // echo $hasil['jumlah'].'<br/>'.$hasil['detail'];
- /* End */
- $arrs[] = array($b, $c, $e, $a);
- }
- /* Cek BRI */
- include('app/lib/ambil.bri.php');
- echo print_r($arrs, 1);
- function kirimEmail( $email, $host, $port, $security, $password, $hasil )
- {
- require_once 'app/lib/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- //$mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = $host; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = $email; // SMTP username
- $mail->Password = $password; // SMTP password
- $mail->SMTPSecure = 'none'; // Enable encryption, `ssl` also accepted
- $mail->Port = 25; // TCP port to connect to
- $mail->setFrom( $email, 'Mblo.co Cek Mutasi' );
- $mail->isHTML( true ); // Set email format to HTML
- $mail->Subject = 'Ada Mutasi Di Bank: '.$hasil['bank'];
- $mail->Body = "------<br/>Dari Bank: ".$hasil['bank']."<br/>Jumlah: ".$hasil['jumlah']."<br/>Tanggal: ".$hasil['tanggal']."<br/>Detail: ".$hasil['detail']."<br/>------<br/><br/>";
- if ( !$mail->send() ) {
- echo 'Pesan Tidak Dapat Dikirim.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Pesan Telah Dikirimkan<br/>';
- }
- }
- function masukkanKeDB( $hasil, $tabel)
- {
- global $option;
- $conn = @mysqli_connect ($option['db_host'], $option['db_username'], $option['db_password'], $option['db_name']);
- if(!$conn){
- die( "Database Error: ".mysqli_error($conn));
- }
- $a = $hasil['jumlah']; // Jumlah / Total yang dimutasi
- $b = $hasil['tanggal']; //Tanggal Mutasi
- $c = $hasil['detail']; // Detail Mutasi
- $d = $hasil['bank']; // Bank Mutasi
- $q = mysqli_query($conn, "INSERT INTO $tabel VALUES(DEFAULT, '$a', '$b', '$c', '$d')");
- if((!$q)) echo 'Error saat insert ke database<br/>';
- }
- function pushKeURL( $url, $hasil = 0)
- {
- // Silahkan gunakan urldecode dan serialize pada script / kode di URL tujuan untuk mengambil hasil array dari fungsi pushKeURL
- $ch = curl_init();
- if($hasil) {
- curl_setopt($ch, CURLOPT_URL, $url.urlencode(serialize($hasil)));
- } else {
- curl_setopt($ch, CURLOPT_URL, $url);
- }
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- 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' );
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT,4);
- $results = curl_exec($ch);
- return $results;
- }
- function SendGrid( $username, $password, $email, $hasil )
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://api.sendgrid.com/api/mail.send.json');
- 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']));
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT,4);
- curl_setopt($ch, CURLOPT_POST, 1);
- $results = curl_exec($ch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement