<main>
  <div class="container-fluid mt-3">
    <div class="row">
      <div class="col-10">
  <?php
  switch($op2) {
      case "php_save";          
          file_put_contents($_POST['file_name'], $_POST['content']);
          $_GET['id']=$_POST['id'];
          $udt=array(
            'update_at'=>time(),
          );
          Update($db,"cp_filephp_api",$udt,"id=".$_POST['id'],1);

          edit($_POST['id']);
          break;
      case "edit";
        edit($_GET['id']);
        break;
      case "copy";
        $sql4 = "select id from `cp_filephp_api` order by id desc limit 1";
        $res4 = mysqli_query($db, $sql4);
        $rw4 = mysqli_fetch_assoc($res4);
        $id2=$rw4['id']+1;

        $sql3 = "select * from `cp_filephp_api` where id=".$_GET['id'];
        $res3 = mysqli_query($db, $sql3);
        $r3 = mysqli_fetch_assoc($res3);
        $idt=array(
          'id'=>$id2,
          //'modul'=>trim($r3['modul']),
          'slug'=>$r3['slug']."-",
          'folder'=>trim($r3['folder']),
          'param'=>trim($r3['param']),
          'method'=>trim($r3['method']),
          'php'=>gpc(trim($r3['php'])),
          'update_at'=>time(),
          'body'=>gpc(trim($r3['body'])),
        );
        Insert($db,"cp_filephp_api",$idt,0);
        edit($id2);
        break;
      case "edit2";
        //echo "<pre>"; print_r($_POST); echo "</pre>";
        $udt=array(
          //'modul'=>trim($_POST['modul']),
          'slug'=>$_POST['slug'],
          //'name'=>$_POST['name'],
          'param'=>trim($_POST['param']),
          'method'=>trim($_POST['method']),
          'folder'=>$_POST['folder'],
          //'file_jsapi'=>$_POST['file_jsapi'],
          'remark'=>trim($_POST['remark']),
          'php'=>gpc(trim($_POST['php'])),
          //'js'=>gpc(trim($_POST['js'])),
          //'js_api'=>gpc(trim($_POST['js_api'])),
          'body'=>gpc(trim($_POST['body'])),
          'update_at'=>time(),
          //'js_update_at'=>time(),
          //'jsapi_update_at'=>time(),
        );
        Update($db,"cp_filephp_api",$udt,"id=".$_POST['id'],0);
        $_GET['id']=$_POST['id'];
        edit($_POST['id']);
        break;
      case "list";
        list_filephp($q,$col,$q2,$col2,$q3,$col3);
      default;
    }
  ?>
      </div>
      <div class="col-2 small">
<?php 
  $sql1 = "select `folder`,id,slug from `cp_filephp_api` where del=0 order  by `folder`,slug";
  $res1 = mysqli_query($db, $sql1);
  while($r1 = mysqli_fetch_assoc($res1)) {
    //$dt[$c]['folder']=$r1['folder'];
    if(isset($_GET['id']) && $_GET['id']==$r1['id']) {
      $sl='<b>'.substr($r1['folder'],4)."".$r1['slug'].'</b>';
    } else {
      $sl=substr($r1['folder'],4)."".$r1['slug'];
    }
    ?>
    <a href="?op=filephp&op2=edit&id=<?=$r1['id'];?>"><?=$sl;?></a><br>
    <?php
  }   
?>
        </div>
    </div>          
  </div>
</main>
<?php
function list_filephp($q,$col,$q2,$col2,$q3,$col3) {
  global $db,$ar;  
  //print_r($ar);
  ?>  
  <table class="table table-bordered" id="dataTable_5d" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th>ID</th>
        <th>Folder</th>
        <th>Slug</th>
        <th>is_api</th>
        <th>met</th>
        <th>uAt</th>
        <th>Menu</th>
      </tr>
    </thead>
    <tbody>
      <?php
      $sql = "select * from cp_filephp_api where id>0 ";
      if($col!='') {
        $sql .= " and ".$col."='".$q."' ";
      }
      if($col2!='') {
        $sql .= " and ".$col2."='".$q2."' ";
      }
      if($col3!='') {
        $sql .= " and ".$col3."='".$q3."' ";
      }
      //$sql .= " and st=1";
      $res = mysqli_query($db, $sql);
      //echo $sql;
      while($rw = mysqli_fetch_assoc($res)) {  
      ?>
      <tr>
        <td><?=$rw['id'];?></td>
        <td><a href="?op=filephp&col=folder&q=<?=$rw['folder'];?>"><?=$rw['folder'];?></a></td>
        <td><?=$rw['slug'];?></td>
        <td><?=$rw['type'];?></td>              
        <td><?=$rw['method'];?></td>
        <td class="text-right"><?=date("Y-m-d H:i",$rw['update_at']);?></td>
        <td>
          <a class="btn btn-xs btn-primary" href="?op=filephp&op2=edit&id=<?=$rw['id'];?>">edit</a> 
          <a href="#" onClick="uCol(<?=$rw['id'];?>,'del',1,'cp_filephp_api');" class="btn btn-xs btn-color-red">del</a>
          <a href="#" onClick="uCol(<?=$rw['id'];?>,'type',0,'cp_filephp_api');" class="btn btn-xs btn-color-green">non-api</a>               
        </td>
      </tr>
        <?php
        }
        ?>  
    </tbody>
  </table>
  <br><?=$sql;?><br>
  <?php   
}
function edit($id) {
   global $db,$ar;    
  $sql = "select * from `cp_filephp_api` where id=".$id;
  $res = mysqli_query($db, $sql);
  //echo $sql;
  $rw = mysqli_fetch_assoc($res);
$php_file=$ar['path_core'].''.$rw['folder'].''.$rw['slug'].'.php';
  if (file_exists($php_file)) {
    $filecontent=file_get_contents($php_file);
  } else {
    $filecontent="<?php

?>";      
  } 
  ?>
<div class="row">
  <div class="col-8">
  <form action="index.php?op=filephp&op2=edit2" method="post">
    <input type="hidden" name="id" value="<?=$id;?>">
    <div class="row">
      <div class="col-6">        
      </div>
      <div class="col-6 text-end">
      <?php if($rw['type']==1) { ?>
        <a href="tes_curl.php?id=<?=$id;?>&c=1" target="_blank" class="btn btn-xs btn-info">Tes cURL [1]</a>
      <?php } ?>
      <?php if($rw['method']=='GET') { ?>
        <a href="<?=$ar['site_url'].''.substr($rw['folder'],4).''.substr($rw['slug'],4);?>" target="_blank" class="btn btn-xs btn-success">Tes GET</a>
      <?php } ?>
        <a class="btn btn-xs btn-warning" href="?op=filephp&op2=copy&id=<?=$id;?>">Copy This</a>
        <button type="submit" name="submit" class="btn btn-sm btn-primary">Save</button>
      </div>
    </div>
    <div class="row">
      <div class="col-3">
        <label for="folder" class="label">folder</label>
        <input type="text" class="form-control" name="folder" value="<?=$rw['folder'];?>">
        <label for="slug" class="label">slug</label>
        <input type="text" class="form-control" name="slug" value="<?=$rw['slug'];?>">          
        <label for="method" class="label">method</label>
        <input type="text" class="form-control" name="method" value="<?=$rw['method'];?>">                
        <label for="param" class="label">param</label>
        <textarea rows="4" id="param" class="form-control" name="param"><?=ugpc($rw['param']);?></textarea>          
        <label for="body" class="label">body</label>
        <textarea rows="4" id="body" class="form-control" name="body"><?=ugpc($rw['body']);?></textarea>
        <label for="remark" class="label">remark</label>
        <textarea rows="4" id="body" class="form-control" name="remark"><?=ugpc($rw['remark']);?></textarea>
      </div>
      <div class="col-9"><pre name="body2" class="line-numbers" data-start="1" style="white-space:pre-wrap;"><code contenteditable class="language-javascript"><?=htmlspecialchars($filecontent);?></code></pre>
      </div>
    </div>
  </form>
  </div>
  <div class="col-4">
    <?php 
    ?>    
    <div class="card">
      <div class="card-body">
<?=$ar['path_core'];?>
        <h5 class="card-title"><?=$rw['folder'];?><?=$rw['slug'];?>.php</h5>
        <form method="post" action="index.php?op=filephp&op2=php_save">
          <input type="hidden" name="file_name" value="<?=$php_file;?>">
          <input type="hidden" name="id" value="<?=$rw['id'];?>">
          <textarea class="form-control" rows="20" name="content"><?=htmlspecialchars($filecontent);?></textarea>
          <input type="submit" name="submit" class="btn btn-success mt-2">
        </form>
      </div>
    </div>
  </div>
</div>
  <?php
  //echo "<pre>"; print_r($rw); echo "</pre>";
}
?>
/home/u902783705/domains/azkapersada.com/public_html/sub/
rs2/inc/inc.filephp.php
si/common.function
si/dom/get.img
si/api/post_location
si/api/post_loc_v3
si/api/post_tag_v2
si/api/post_tag_v3
common.function
common.function-
footer
header
inc.app.function
inc.ar.app
index
tes_curl
ucol
api/v2/api.function
api/v2/inc.mail
api/v2/index
api/v2/php/agen
api/v2/php/armada_jalan_byday
api/v2/php/armada_perpal_byday
api/v2/php/armada_perpal_byday-
api/v2/php/beda_byday
api/v2/php/cek_rute_baru
api/v2/php/cek_rute_time
api/v2/php/cek_rute_time_v1
api/v2/php/cek_rute_time_v2
api/v2/php/city
api/v2/php/dr_time_byday
api/v2/php/dr_time_jalan_byday
api/v2/php/email_cek
api/v2/php/get_nl_byday
api/v2/php/get_nl_kelas_armada
api/v2/php/js_armada_tax_expire
api/v2/php/js_blue_armada
api/v2/php/js_blue_expire
api/v2/php/js_car_srut_blank
api/v2/php/js_img_todl
api/v2/php/js_jalurnew
api/v2/php/js_kebid
api/v2/php/js_nl_latest
api/v2/php/js_nl_min
api/v2/php/js_noken
api/v2/php/js_noken_mesin_blank
api/v2/php/js_noken_no_lambung
api/v2/php/js_noken_spionam_cek
api/v2/php/js_noken_tax_cek
api/v2/php/js_rute
api/v2/php/js_rute_bycity
api/v2/php/js_rute_min
api/v2/php/js_spionam_id
api/v2/php/js_spionam_kps
api/v2/php/kd_armada
api/v2/php/kd_armada_dr_time
api/v2/php/kd_armada_to_time
api/v2/php/naik_byday
api/v2/php/nk_pilih
api/v2/php/nl_noken_bytgl
api/v2/php/nl_pilih
api/v2/php/nl_reset
api/v2/php/noken_koreksi
api/v2/php/otw
api/v2/php/otw_not_full
api/v2/php/password_forgot
api/v2/php/post_1naik
api/v2/php/post_1turun
api/v2/php/post_blue
api/v2/php/post_dr_time_byday_local
api/v2/php/post_kebid_byday
api/v2/php/post_noken_mesin
api/v2/php/post_noken_no_lambung
api/v2/php/post_sakpol
api/v2/php/post_spionam
api/v2/php/post_spionam_cek
api/v2/php/post_spionam_update
api/v2/php/post_spnm_noken
api/v2/php/ricar
api/v2/php/rute_price
api/v2/php/selisih_bagasi
api/v2/php/signin
api/v2/php/tool
api/v2/php/tool_armada
api/v2/php/tool_lambung
api/v2/php/tool_noken
api/v2/php/turun_byday
api/v2/php/ucol
api/v2/php/uji_no
api/v2/php/update_agen
api/v2/php/update_armada_byday
api/v2/php/update_armada_v2_byday
api/v2/php/update_bagasi_byday
api/v2/php/update_bagasi_city
api/v2/php/update_jalan_byday
api/v2/php/update_penumpang_byday
api/v2/php/update_trayek_dr_time
api/v2/php/update_trayek_to_time
daily/10_tool_seq
daily/14_update_kd_armada
daily/15_update_rute_dr_to_ccd
daily/16_kdagen_to_id
daily/16_kdagen_to_id-
daily/17_update_dr_to_time
inc/inc.cp_sphp
inc/inc.filephp
inc/inc.job_kebid
inc/inc.js_pergi
inc/inc.rs4_css
inc/inc.rs4_html
inc/inc.rs4_h_page
inc/inc.rs4_h_tab
inc/inc.rs4_js
inc/inc.rs4_jsf
inc/inc.t1_css
inc/inc.t1_html
inc/inc.t1_h_page
inc/inc.t1_h_tab
inc/inc.t1_js
inc/inc.t1_jsf
xhr/inc.xhr