<?php
defined("BASEPATH") or exit("No direct access allowed");
if (isset($_POST['ubah'])){

    //$namal = mysqli_real_escape_string($con,$namal);
    $hp = mysqli_real_escape_string($con,$hp);
    $pixel = mysqli_real_escape_string($con,$pixel);
    $urlhost = mysqli_real_escape_string($con,$urlhost);
    $emailhost = mysqli_real_escape_string($con,$emailhost);
    $passhost = mysqli_real_escape_string($con,$passhost);
    $tombolWA = mysqli_real_escape_string($con,$tombolWA);
    $namao = mysqli_real_escape_string($con,$namao);
    $port = mysqli_real_escape_string($con,$port);
    $emailapi = mysqli_real_escape_string($con,$emailapi);
    $keyapi = mysqli_real_escape_string($con,$keyapi);
    $smsaktif = mysqli_real_escape_string($con,$smsaktif);
    $catkaki = mysqli_real_escape_string($con,$catkaki);
    $idtelegram = mysqli_real_escape_string($con,$idtelegram);
    $tokentelegram = mysqli_real_escape_string($con,$tokentelegram);
    $cunsub = mysqli_real_escape_string($con,$cunsub);
    $namato = mysqli_real_escape_string($con,$namato);
    $emailto = mysqli_real_escape_string($con,$emailto);
    $usersmtp = mysqli_real_escape_string($con,$usersmtp);
    $kodenegara = mysqli_real_escape_string($con,$kodenegara);
    $captcha = mysqli_real_escape_string($con,$captcha);
    $proteksi = mysqli_real_escape_string($con,$proteksi);
    $pin = mysqli_real_escape_string($con,$pin);
    
    mysqli_query($con,"update akunn set hp='$hp', pixel='$pixel',e1='$urlhost',e2='$emailhost',e3='$passhost',twa='$tombolWA', nama='$namao', e4='$port', emailapi='$emailapi', keyapi='$keyapi', smsaktif='$smsaktif', catkaki='$catkaki', idtelegram='$idtelegram', tokentelegram='$tokentelegram', cunsub='$cunsub', namato='$namato', emailto='$emailto', usersmtp='$usersmtp', kodenegara='$kodenegara', captcha='$captcha',proteksi='$proteksi',pin='$pin' where id=1");
    
    $data = array("url"=>$weburl,"hp"=>$hp);
    //$send = sendSMS(base64_decode('aHR0cHM6Ly9hcHAuYml6bmlzLnRvcC9tZW1iZXIvYmxhY2sucGhw'),json_encode($data));
    
    echo '
        <script>
            	swal("Good Job","Anda sukses menyimpan setting","success");
        </script>
    ';
    		
        echo '
		<!-- <div class="alert alert-success alert-dismissable" style="margin-top:20px">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon glyphicon glyphicon-remove"></i> Anda sukses menyimpan setting.</div> -->
		';
        
   
}

$data=mysqli_fetch_row(mysqli_query($con,"select * from akunn where id=1"));

?>
    <style>
        #image-holder {
            margin-top: 8px;
        }
        
        #image-holder img {
            border: 8px solid #DDD;
            max-width:100%;
        }
    </style>
    
   <div class="card-header">
          
          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="#"><i class="far fa-file"></i> Akun</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i> Setting</li>
                      </ol>
                    </nav>
					
          </div>

               <div class="card-body">
                <form action="" method="POST"> 
                       <!--
                       <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">User Name</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="namal" id="tiga" value="<?php echo $data[1]; ?>" required>
                            <i>Digunakan untuk login</i>    
                            </div>
                        </div> -->
                        
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Nama Owner</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="namao" id="tiga" value="<?php echo $data[10]; ?>" required>
                            <i>tampil di penerima email</i>    
                            </div>
                        </div>
                    
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Kode Negara</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="kodenegara" id="tiga" value="<?php echo isset($data[23])?$data[23]:''; ?>" required>
                            <i>Sesuaikan dengan negara tempat tinggal anda. Cth: 62 untuk Indonesia, 60 untu Malaysia</i>    
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">HP</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="hp" id="tiga" value="<?php echo isset($data[7])?$data[7]:''; ?>" required>
                            <i>Kontak tombol WA dalam email. Terkirim SMS Notifikasi ke HP ini.</i>    
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Aktifkan Tombol WA di email</label>
                            <div class="col-sm-10">
                                
                           <?php  
                                
                               
                                $result = mysqli_query($con,"SELECT * FROM akunn where id =1 ORDER BY id");
                                  while($row = mysqli_fetch_assoc($result))
                                   {
                                     if($row['twa']==0) {
                                          $ktw = 'Tidak Aktif';
                                     }else{
                                          $ktw = 'Aktif';
                                     }     
                                     echo "<select name='tombolWA' class='form-control'>
                                     <option value=$row[twa]>$ktw</option>
                                     <option value='0'>Tidak Aktif</option>
                                     <option value='1'>Aktif</option>
                                        </select> 
                                     ";
                                    } 
                                    ?>
                                        
                            <i>Jika Aktif maka tombol WA dalam email akan tampil</i>    
                            </div>
                        </div>
                        
                        <div class="form-group">
                            
                            <?php
                            echo "
                                <label for='tiga' class='col-sm-2 control-label'>ID Piksel Facebook, cek <a href='https://www.facebook.com/events_manager/custom-conversion' target='_blank'>Disini</a></label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='pixel' id='tiga' value='$data[8]' >
                                    <i>Untuk merekam aktifitas pengunjung via pixel Fb. Pixel tertanam dalam link tracking.</i>
                                </div><hr><i><p id='URL'>Cek panduan setting SMTP email domain <a href='https://blog.biznis.top/2018/11/broadcast-email-dengan-email-domain.html' target='_blank'> KLIK DISINI </a> atau cek dalam panduan instalasi. Jika kesulitan <a href='https://wa.me/6282150651122' target='_blank'> KLIK DISINI </a> tuk diremot.</p></i>
                                <label for='tiga' class='col-sm-2 control-label'>URL Host (Outgoing Server)</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='urlhost' id='tiga' value='$data[4]' >
                                </div>
                                <label for='tiga' class='col-sm-2 control-label'>Email Host</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='emailhost' id='tiga' value='$data[5]' >
                                </div>
                                 <label for='tiga' class='col-sm-2 control-label'>User SMTP</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='usersmtp' id='tiga' value='$data[22]' placeholder='Kosongkan jika tidak ada' >
                                <i>User SMTP biasanya ada pada Amazon SES</i>
                                </div>
                                <label for='tiga' class='col-sm-2 control-label'>Password Email Host</label>
                                <div class='col-sm-10'>
                                    <input type='password' class='form-control' name='passhost' id='tiga' value='$data[6]' >
                                </div>
                                <div class='form-group'>
                                <label for='tiga' class='col-sm-2 control-label'>Port</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='port' id='tiga' value='$data[11]' required>
                                </div>
                                 </div>
                                 <hr>
                                 <i>Email Balasan</i>
                                 <div class='form-group'>
                                <label for='tiga' class='col-sm-2 control-label'>Nama Pemilik</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='namato' id='tiga' value='$data[20]' required>
                                </div>
                                 </div>
                                 <div class='form-group'>
                                <label for='tiga' class='col-sm-2 control-label'>Email</label>
                                <div class='col-sm-10'>
                                    <input type='email' class='form-control' name='emailto' id='tiga' value='$data[21]' required>
                                </div>
                                 </div>
                                 <hr><i>Belum Punya Email dan Token Key Api SMS, daftar <a href='https://sms.yantonaim.web.id/' target='_blank'>DISINI</a><br>
                                 <label for='tiga' class='col-sm-2 control-label'>Email Key</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='emailapi' id='tiga' value='$data[12]' >
                                </div>
                                <label for='tiga' class='col-sm-2 control-label'>Token Key</label>
                                <div class='col-sm-10'>
                                    <input type='password' class='form-control' name='keyapi' id='tiga' value='$data[13]' >
                                </div>
                                
                            ";
                            ?>
                        </div>

                        <hr>
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Aktifkan SMS?</label>
                            <div class="col-sm-10">
                                
                           <?php  
                                
                               
                                $result = mysqli_query($con,"SELECT * FROM akunn where id =1 ORDER BY id");
                                  while($row = mysqli_fetch_assoc($result))
                                   {
                                     if($row['smsaktif']==0) {
                                          $ktw = 'Tidak Aktif';
                                     }else{
                                          $ktw = 'Aktif';
                                     }     
                                     echo "<select name='smsaktif' class='form-control'>
                                     <option value=$row[smsaktif]>$ktw</option>
                                     <option value='0'>Tidak Aktif</option>
                                     <option value='1'>Aktif</option>
                                        </select> 
                                     ";
                                    } 
                                    ?>
                                        
                            <i>Jika aktif, maka pesan SMS Auto dan notifikasi terkirim</i>    
                            </div>
                        </div>
                        
                        <div class='form-group'>
                                <label for='tiga' class='col-sm-2 control-label'>Catatan Kaki Email</label>
                                <div class='col-sm-10'>
                                    <textarea name="catkaki" cols="40" class='ckeditor'>
                                        <?php echo $data[15]; ?> 
                                       </textarea>
                                </div>
                                 </div>
                                 
                        <div class='form-group'>
                                <label for='tiga' class='col-sm-4 control-label'>Catatan Unsub. Tambahkan tag [nama], [email], [linkunsub]</label>
                                <div class='col-sm-10'>
                                     <input type='text' class='form-control' name='cunsub' id='tiga' value='<?php echo $data[19]; ?>' >
                                </div>
                                 </div>         
                                 
                        <hr><i>Cek panduan mendapatkan ID dan Token Telegram <a href='https://blog.biznis.top/2019/05/notifikasi-via-telegram.html' target='_blank'> KLIK DISINI </a>.</i> Ini berfungsi untuk menerima notifikasi via telegram.<br> 
                        <div class="form-group">
                            <?php
                            echo "
                                <label for='tiga' class='col-sm-2 control-label'>ID Telegram</label>
                                <div class='col-sm-10'>
                                    <input type='text' class='form-control' name='idtelegram' id='tiga' value='$data[16]' >
                                </div>
                                <label for='tiga' class='col-sm-2 control-label'>Token Telegram</label>
                                <div class='col-sm-10'>
                                    <input type='password' class='form-control' name='tokentelegram' id='tiga' value='$data[17]' >
                                </div>
                            ";
                            ?>
                        </div>
                        <hr>
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Aktifkan Captcha saat login?</label>
                            <div class="col-sm-10">
                                
                           <?php  
                                
                               
                                $result = mysqli_query($con,"SELECT * FROM akunn where id =1 ORDER BY id");
                                  while($row = mysqli_fetch_assoc($result))
                                   {
                                     if($row['captcha']==0) {
                                          $ktw = 'Tidak';
                                     }else{
                                          $ktw = 'Ya';
                                     }     
                                     echo "<select name='captcha' class='form-control'>
                                     <option value=$row[captcha]>$ktw</option>
                                     <option value='0'>Tidak Aktif</option>
                                     <option value='1'>Aktif</option>
                                        </select> 
                                     ";
                                    } 
                                    ?>
                                        
                            <i>Jika Aktif maka gambar Captcha akan tampil saat login. Pastikan Versi PHP yang aktif Versi PHP 7.1</i>    
                            </div>
                        </div>
                        
                        <hr>
                        <div class="form-group">
                            <label for="tiga" class="col-sm-4 control-label">Aktifkan Proteksi Email Spam?</label>
                            <div class="col-sm-10">
                                
                           <?php  
                                
                               
                                $result = mysqli_query($con,"SELECT * FROM akunn where id =1 ORDER BY id");
                                  while($row = mysqli_fetch_assoc($result))
                                   {
                                     if($row['proteksi']==0) {
                                          $ktw = 'Tidak';
                                     }else{
                                          $ktw = 'Ya';
                                     }     
                                     echo "<select name='proteksi' class='form-control'>
                                     <option value=$row[proteksi]>$ktw</option>
                                     <option value='0'>Tidak Aktif</option>
                                     <option value='1'>Aktif</option>
                                        </select> 
                                     ";
                                    } 
                                    ?>
                                        
                            <i>Jika diaktifkan Ya dan tidak berfungsi dengan baik, kemungkinan hosting anda tidak terintegrasi baik dengan layanan google. Kembalikan ke proteksi standart dengan pilih Tidak.</i>    
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">PIN</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="pin" id="tiga" value="<?php echo $data[26]; ?>" required>
                            <i>PIN berfungsi untuk verifikasi lupa password, pastikan anda mengganti pin default 1234. Batas 6 digit.</i>    
                            </div>
                        </div>
                    
                        <div class="form-group">
                          <div class  ="col-sm-4">
                            <button type="submit" class="btn btn-primary" name="ubah"><span class="glyphicon glyphicon-pencil"></span>Simpan Setting</button>
                          </div>
                        </div>

                </form>
            </div>
        
      
    