SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `cp_sphp`;
CREATE TABLE `cp_sphp` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `modul` varchar(99) DEFAULT NULL,
  `name` varchar(99) DEFAULT NULL,
  `folder` varchar(99) DEFAULT NULL,
  `body` text DEFAULT NULL,
  `is` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '0',
  `del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1=delete',
  `level` tinyint(4) NOT NULL DEFAULT 0,
  `parent` int(11) NOT NULL DEFAULT 0,
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `folder_name` (`folder`(20),`name`),
  KEY `id_folder_slug` (`id`,`modul`(20)),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=232 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `cp_sphp` VALUES('1','common.function','inc.common.function','cpcp/','','php','0','1','0','1790671188');
INSERT INTO `cp_sphp` VALUES('2','olahxls','inc.olahxls.function','cpcp/','','php','0','1','0','1790671195');
INSERT INTO `cp_sphp` VALUES('4','filephp','filephp.function','cpcp/','','php','0','1','0','1790671180');
INSERT INTO `cp_sphp` VALUES('5','olahcsv','inc.olahcsv.function','cpcp/','','php','0','1','0','1790671202');
INSERT INTO `cp_sphp` VALUES('10','api','api.function','cpcp/','','php','0','1','0','1790671210');
INSERT INTO `cp_sphp` VALUES('101','common.function','getIdClass','','function getIdClass($html3) {\n  $dt=$dt1=array();\n  $html = new simple_html_dom();\n  $html->load($html3);  \n  foreach ($html->find(\'*\') as $el) { \n    if($el->getAttribute("id")!=\'\') {\n      $dt1[\'id\'][]=$el->getAttribute("id");\n    }\n  }\n  foreach ($html->find(\'*\') as $el) { \n    if($el->getAttribute("class")!=\'\') {\n      $dt1[\'class\'][]=$el->getAttribute("class");\n    }\n  }\n\n  foreach ($html->find(\'*\') as $el) { \n    if($el->getAttribute("data-lang")!=\'\') {\n      $dt1[\'lang\'][]=$el->getAttribute("data-lang");\n    }\n  }\n  foreach ($html->find(\'*\') as $el) { \n    if($el->getAttribute("data-ph_lang")!=\'\') {\n      $dt1[\'ph_lang\'][]=$el->getAttribute("data-ph_lang");\n    }\n  }\n  if($dt1[\'lang\']) {\n    $dt[\'lang\'] = array_unique($dt1[\'lang\']);\n  }\n  if($dt1[\'ph_lang\']) {\n    $dt[\'ph_lang\'] = array_unique($dt1[\'ph_lang\']);\n  }\n  if($dt1[\'id\']) {\n    $dt[\'id\'] = array_unique($dt1[\'id\']);\n  }\n  if($dt1[\'class\']) {\n    $dt[\'class\'] = array_unique($dt1[\'class\']);\n  }\n  return $dt;\n}','php','0','2','1','1787096373');
INSERT INTO `cp_sphp` VALUES('107','olahxls','olahxls_wafat','','function olahxls_wafat($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"]) ) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $ex=explode("/",$r[11]);\n          $dt[$k] = [\n            \'no\' => $r[0],\n            \'reg\' => $r[1],\n            \'emb\' => $r[2],\n            \'klt\' => $r[3],\n            \'porsi\' => $r[4],\n            \'nama\' => $r[5],\n            \'ayah\' => $r[6],\n            \'lp\' => $r[7],\n            \'paspor\' => $r[8],\n            \'pelapor\' => $r[9],\n            \'tempat_wafat\' => $r[10],\n            \'tgl_wafat\' => $ex[2].\'-\'.$ex[1].\'-\'.$ex[0].\' \'.trim($r[12]).\':00\',\n            \'sebab\' => $r[13],\n            \'makam\' => $r[14],\n            \'usia\' => $r[15],\n            \'maktab\' => $r[16],\n            \'no_rumah\' => $r[17],\n            \'provinsi\' => $r[18],\n            \'kokab\' => $r[19],\n            \'alamat\' => $r[20],\n            \'desa\' => $r[21],\n            \'code\' => trim($r[2]).\'\'.trim($r[3]),\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'</textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    \n    foreach ($dt as $k => $v) {\n      $idt=array(\n        \'id\'=>$v[\'no\'],\n        \'reg\'=>$v[\'reg\'],\n        \'emb\'=>$v[\'emb\'],\n        \'klt\'=>$v[\'klt\'],\n        \'code\'=>$v[\'code\'],\n        \'porsi\'=>$v[\'porsi\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'ayah\'=>gpc($v[\'ayah\']),\n        \'lp\'=>$v[\'lp\'],\n        \'paspor\'=>$v[\'paspor\'],\n        \'pelapor\'=>$v[\'pelapor\'],\n        \'tempat_wafat\'=>gpc($v[\'tempat_wafat\']),\n        \'tgl_wafat\'=>$v[\'tgl_wafat\'],\n        \'jam_wafat\'=>strtotime($v[\'tgl_wafat\']),\n        \'sebab\'=>gpc($v[\'sebab\']),\n        \'makam\'=>$v[\'makam\'],\n        \'usia\'=>$v[\'usia\'],\n        \'maktab\'=>$v[\'maktab\'],\n        \'no_rumah\'=>$v[\'no_rumah\'],\n        \'kokab\'=>$v[\'kokab\'],\n        \'provinsi\'=>$v[\'provinsi\'],\n        \'alamat\'=>$v[\'alamat\'],\n        \'desa\'=>$v[\'desa\'],\n        \'update_at\'=>time(),\n      );\n      $udt=array(\n        \'nama\'=>gpc($v[\'nama\']),\n        \'ayah\'=>gpc($v[\'ayah\']),\n        \'tempat_wafat\'=>gpc($v[\'tempat_wafat\']),\n        \'tgl_wafat\'=>$v[\'tgl_wafat\'],\n        \'jam_wafat\'=>strtotime($v[\'tgl_wafat\']),\n        \'sebab\'=>gpc($v[\'sebab\']),\n        \'update_at\'=>time(),\n      );\n      InsertUpdate($db,"wafat",$idt,$udt,1);\n      $udt2=array(\n        \'is_wafat\'=>1,\n        \'wafat_id\'=>$v[\'no\'],\n      );\n      Update($db,"penempatan",$udt2,"`paspor`=\'".$v[\'paspor\']."\'",1);\n    }\n    /* */\n    $sql2="SELECT `code`,`gel` from berangkat";\n    $res2=mysqli_query($db,$sql2);\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $udt3=array(\n        \'daker\'=>2,\n        \'gel\'=>$r2[\'gel\'],\n      );\n      Update($db,"wafat",$udt3,"`code`=\'".$r2[\'code\']."\'",1);\n    }   \n    $sql3="SELECT lp,daker,sektor,gel,porsi,paspor,wafat_id,no_rumah from penempatan where is_wafat=1 and wafat_id>0";\n    $res3=mysqli_query($db,$sql3);\n    while($r3=mysqli_fetch_assoc($res3)) {\n      $udt3=array(\n        \'daker\'=>$r3[\'daker\'],\n        \'gel\'=>$r3[\'gel\'],\n        \'lp\'=>$r3[\'lp\'],\n        \'sektor\'=>$r3[\'sektor\'],\n        \'norumah\'=>$r3[\'no_rumah\'],\n      );\n      Update($db,"wafat",$udt3,"`id`=\'".$r3[\'wafat_id\']."\'",1);            \n    }    \n  } else {\n    echo \'tak ada data<br>\';\n  }\n}','php','0','2','2','1787092922');
INSERT INTO `cp_sphp` VALUES('108','olahxls','olahxls_dirawat','','function olahxls_dirawat($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"]) ) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $ex=explode("-",$r[3]);\n          $dt[$k] = [\n            \'no\' => $r[0],\n            \'porsi\' => $r[1],\n            \'paspor\' => $r[2],\n            \'urut\' => $r[4],\n            \'provinsi\' => $r[5],\n            \'nama\' => $r[6],\n            \'rs\' => $r[7],\n            \'dr\' => $r[8],\n            \'tgl\' => trim(relp_space($r[9])),\n            \'wilayah\' => $r[10],\n            \'usia\' => $r[11],\n            \'st\' => $r[12],\n            \'code\' => trim($ex[0]).\'\'.trim($ex[1]),\n            \'emb\' => trim($ex[0]),\n            \'klt\' => trim($ex[1]),\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'</textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    \n    foreach ($dt as $k => $v) {\n      $e1=explode(" ",$v[\'tgl\']);\n      $e2=explode("-",$e1[0]);\n      $idt=array(\n        \'id\'=>$v[\'no\'],\n        \'porsi\'=>$v[\'porsi\'],\n        \'paspor\'=>$v[\'paspor\'],\n        \'urut\'=>$v[\'urut\'],\n        \'provinsi\'=>$v[\'provinsi\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'rs\'=>$v[\'rs\'],\n        \'tgl\'=>$e2[2]."-".$e2[1]."-".$e2[0],\n        \'jam\'=>strtotime($e2[2]."-".$e2[1]."-".$e2[0]." ".$e1[1].":00"),\n        \'wilayah\'=>$v[\'wilayah\'],\n        \'usia\'=>$v[\'usia\'],\n        \'st\'=>$v[\'st\'],\n        \'emb\'=>$v[\'emb\'],\n        \'klt\'=>$v[\'klt\'],\n        \'code\'=>$v[\'code\'],\n      );\n      $udt=array(\n        \'dr\'=>$v[\'dr\'],\n        \'tgl\'=>$e2[2]."-".$e2[1]."-".$e2[0],\n        \'jam\'=>strtotime($e2[2]."-".$e2[1]."-".$e2[0]." ".$e1[1].":00"),\n        \'st\'=>$v[\'st\'],\n        \'update_at\'=>time()\n      );\n      InsertUpdate($db,"dirawat",$idt,$udt,1);\n      $udt2=array(\n        \'is_dirawat\'=>1,\n        \'dirawat_id\'=>$v[\'no\'],\n        \'ket_rawat\'=>$v[\'st\'],\n      );\n      Update($db,"penempatan",$udt2,"`paspor`=\'".$v[\'paspor\']."\'",1);\n    }\n    /* */\n\n    $sql2="SELECT code,gel from mykloter";\n    $res2=mysqli_query($db,$sql2);\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $udt3=array(\n        \'daker\'=>2,\n        \'gel\'=>$r2[\'gel\'],\n      );\n      Update($db,"dirawat",$udt3,"`code`=\'".$r2[\'code\']."\'",1);\n    }\n\n    $sql3="SELECT lp,daker,sektor,gel,porsi,paspor,dirawat_id,no_rumah from penempatan where is_dirawat=1 and dirawat_id>0";\n    $res3=mysqli_query($db,$sql3);\n    while($r3=mysqli_fetch_assoc($res3)) {\n      $udt3=array(\n        \'daker\'=>$r3[\'daker\'],\n        \'gel\'=>$r3[\'gel\'],\n        \'lp\'=>$r3[\'lp\'],\n        \'sektor\'=>$r3[\'sektor\'],\n        \'norumah\'=>$r3[\'no_rumah\'],\n      );\n      Update($db,"dirawat",$udt3,"`id`=\'".$r3[\'dirawat_id\']."\'",1);            \n    }     \n  } else {\n    echo \'tak ada data<br>\';\n  }      \n}','php','0','2','2','1787089103');
INSERT INTO `cp_sphp` VALUES('109','olahxls','olahxls_manifest','','function olahxls_manifest($POST,$FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"]) ) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $dt[$k] = [\n            \'no\' => $r[0],\n            \'emb\' => $r[1],\n            \'klt\' => $r[2],\n            \'urut\' => $r[3],\n            \'porsi\' => $r[4],\n            \'nama\' => $r[5],\n            \'paspor\' => $r[6],\n            \'visa\' => $r[7],\n            \'lp\' => $r[8],\n            \'romb\' => $r[9],\n            \'regu\' => $r[10],\n            \'tugas\' => $r[11],\n            \'kokab\' => $r[12],\n            \'umur\' => $r[13]\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    $code=$dt[1][\'emb\']."".$dt[1][\'klt\'];\n    $emb=$dt[1][\'emb\'];\n    $klt=$dt[1][\'klt\'];\n    echo "rows: ".count($dt)." ".$code."<br>";\n    foreach ($dt as $k => $v) {\n      if($v[\'umur\']>64) {\n        $lan=1;\n      } else {\n        $lan=0;\n      }\n      $idt=array(\n        \'emb\'=>$v[\'emb\'],\n        \'klt\'=>$v[\'klt\'],\n        \'urut\'=>$v[\'urut\'],\n        \'porsi\'=>$v[\'porsi\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'paspor\'=>$v[\'paspor\'],\n        \'visa\'=>$v[\'visa\'],\n        \'lp\'=>$v[\'lp\'],\n        \'romb\'=>$v[\'romb\'],\n        \'regu\'=>$v[\'regu\'],\n        \'tugas\'=>$v[\'tugas\'],\n        \'jenis_petugas\'=>trim($v[\'tugas\']),\n        \'kokab\'=>$v[\'kokab\'],\n        \'usia\'=>$v[\'umur\'],\n        \'daker\'=>$POST[\'daker\'],\n        \'gel\'=>$POST[\'gel\'],\n        \'lan\'=>$lan,\n      );\n      $udt=array(\n        \'emb\'=>$v[\'emb\'],\n        \'klt\'=>$v[\'klt\'],\n        \'urut\'=>$v[\'urut\'],\n        \'porsi\'=>$v[\'porsi\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'paspor\'=>$v[\'paspor\'],\n        \'visa\'=>$v[\'visa\'],\n        \'lp\'=>$v[\'lp\'],\n        \'romb\'=>$v[\'romb\'],\n        \'regu\'=>$v[\'regu\'],\n        \'tugas\'=>trim($v[\'tugas\']),\n        \'jenis_petugas\'=>trim($v[\'tugas\']),\n        \'kokab\'=>$v[\'kokab\'],\n        \'usia\'=>$v[\'umur\'],\n        \'lan\'=>$lan,\n        \'daker\'=>$POST[\'daker\'],\n        \'gel\'=>$POST[\'gel\'],\n      );\n      InsertUpdate($db,"penempatan",$idt,$udt,0);\n    }\n    tool_kloter_lp();\n    tool_kloter_lan_lp() ;\n    tool_kloter_manifest();\n    tool_kloter_ptg_lp();\n  } else {\n    echo "tak ada data<br>";\n  }\n}','php','0','2','2','1787089607');
INSERT INTO `cp_sphp` VALUES('110','olahxls','olahxls_penempatan','','function olahxls_penempatan($POST,$FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"]) ) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $dt[$k] = [\n            \'porsi\' => $r[0],\n            \'nama\' => $r[1],\n            \'lp\' => $r[2],\n            \'usia\' => $r[3],\n            \'no_rumah\' => $r[4],\n            \'hotel\' => $r[5],\n            \'gedung\' => $r[6],\n            \'lantai\' => $r[7],\n            \'kamar\' => $r[8],\n            \'romb\' => $r[9],\n            \'regu\' => $r[10],\n            \'lahir\' => $r[11],\n            \'paspor\' => $r[12],\n            \'visa\' => $r[13],\n            \'emb\' => $r[14],\n            \'klt\' => $r[15]\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    $code=$dt[1][\'emb\']."".$dt[1][\'klt\'];\n    $emb=$dt[1][\'emb\'];\n    $klt=$dt[1][\'klt\'];\n    echo "rows: ".count($dt)."; ".$dt[1][\'emb\']."".$dt[1][\'klt\']."<br>";\n    if($dt[1][\'gedung\']!=\'\' && $dt[1][\'no_rumah\']!=\'\' && $dt[1][\'no_kamar\']!=\'\') {\n      foreach ($dt as $k => $v) {\n        if(strlen($v[\'no_rumah\'])>3) {\n          $sektor=substr($v[\'no_rumah\'],0,2);\n        } else {\n          $sektor=substr($v[\'no_rumah\'],0,1);                \n        }\n        $el=explode("/",$v[\'lahir\']);\n        if($v[\'umur\']>64) {\n          $lan=1;\n        } else {\n          $lan=0;\n        }\n\n        $idt=array(\n          \'emb\'=>$v[\'emb\'],\n          \'klt\'=>$v[\'klt\'],\n          \'porsi\'=>$v[\'porsi\'],\n          \'nama\'=>gpc($v[\'nama\']),\n          \'paspor\'=>$v[\'paspor\'],\n          \'visa\'=>$v[\'visa\'],\n          \'lp\'=>$v[\'lp\'],\n          \'romb\'=>$v[\'romb\'],\n          \'regu\'=>$v[\'regu\'],\n          \'usia\'=>$v[\'umur\'],\n          \'daker\'=>$_POST[\'daker\'],\n          \'gel\'=>$_POST[\'gel\'],\n          \'lan\'=>$lan,\n          \'nama_hotel\'=>gpc($v[\'hotel\']),\n          \'no_rumah\'=>$v[\'no_rumah\'],\n          \'gedung\'=>$v[\'gedung\'],\n          \'no_lantai\'=>$v[\'lantai\'],\n          \'no_kamar\'=>$v[\'kamar\'],\n          \'sektor\'=>$sektor,\n          \'tgl_lahir\'=>$el[2]."-".$el[1]."-".$el[0],\n        );\n        $udt=array(\n          \'nama_hotel\'=>gpc($v[\'hotel\']),\n          \'no_rumah\'=>$v[\'no_rumah\'],\n          \'gedung\'=>$v[\'gedung\'],\n          \'no_lantai\'=>$v[\'lantai\'],\n          \'no_kamar\'=>$v[\'kamar\'],\n          \'sektor\'=>$sektor,\n          \'tgl_lahir\'=>$el[2]."-".$el[1]."-".$el[0],\n        );\n        InsertUpdate($db,"penempatan",$idt,$udt,1);\n      }\n      $sql1="SELECT * from myhotel where `code`=\'".$code."\' and daker=\'".$_POST[\'daker\']."\' and gel=\'".$_POST[\'gel\']."\'";\n      $res1=mysqli_query($db,$sql1);\n      $r1=mysqli_fetch_assoc($res1);\n      if($r1[\'in_hotel_time\']>0) {\n        $udt1=array(\n          \'in_hotel_time\'=>$r1[\'in_hotel_time\'],\n          \'in_hotel_date\'=>$r1[\'in_hotel_date\'],\n          \'update_at\'=>time(),\n        );\n\n        if($r1[\'out_hotel_time\']>0) {\n          $udt1[\'out_hotel_time\']=$r1[\'out_hotel_time\'];\n          $udt1[\'out_hotel_date\']=$r1[\'out_hotel_dete\'];\n        }\n        if($r1[\'kitchen_code\']!=\'\') {\n          $udt1[\'kitchen_code\']=$r1[\'kitchen_code\'];\n        }\n        Update($db,"penempatan",$udt1,"`emb`=\'".$r1[\'emb\']."\' and klt=\'".$r1[\'klt\']."\' and no_rumah=\'".$r1[\'hotel_no\']."\' and daker=\'".$r1[\'daker\']."\' and gel=\'".$r1[\'gel\']."\'",1);\n      }\n      $sql2="SELECT hp1,paspor from hp_petugas where `emb`=\'".$emb."\' and klt=\'".$klt."\'";\n      $res2=mysqli_query($db,$sql2);\n      while($r2=mysqli_fetch_assoc($res2)) {\n        $udt2=array(\n          \'hpid\'=>$r2[\'hp1\'],\n        );\n        Update($db,"penempatan",$udt2,"paspor=\'".$r2[\'paspor\']."\'",1);\n      }\n      tool_kloter_lp();\n      tool_kloter_lan_lp() ;\n      tool_kloter_manifest();\n      tool_kloter_ptg_lp();\n      tool_hotel_lp();\n      tool_hotel_lan_lp() ;\n      tool_hotel_manifest();\n      tool_hotel_ptg_lp();\n    } else {\n      echo "data kamar masih kosong<br>";\n    }\n  } else {\n    echo "tak ada data<br>";\n  }\n}','php','0','2','2','1787089831');
INSERT INTO `cp_sphp` VALUES('111','olahxls','olahxls_hp_petugas','','function olahxls_hp_petugas($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $dt[$k] = [\n            \'nama\' => $r[0],\n            \'paspor\' => $r[1],\n            \'hp\' => $r[2],\n            \'emb\' => $r[4],\n            \'klt\' => $r[5],\n            \'romb\' => $r[6],\n            \'regu\' => $r[7],\n            \'tugas\' => $r[9],\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    foreach ($dt as $k => $v) {\n      $idt=array(\n        \'emb\'=>$v[\'emb\'],\n        \'klt\'=>$v[\'klt\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'paspor\'=>$v[\'paspor\'],\n        \'romb\'=>$v[\'romb\'],\n        \'regu\'=>$v[\'regu\'],\n        \'tugas\'=>$v[\'tugas\'],\n        \'hp1\'=>to_hp2($v[\'hp\']),\n      );\n      $udt=array(\n        \'romb\'=>$v[\'romb\'],\n        \'regu\'=>$v[\'regu\'],\n        \'tugas\'=>$v[\'tugas\'],\n        \'hp1\'=>to_hp2($v[\'hp\']),\n      );\n      if($v[\'hp\']!=\'\' && $v[\'tugas\']!=\'\') {\n        InsertUpdate($db,"hp_petugas",$idt,$udt,1);\n      }\n    }\n  } else {\n    echo "tak ada data xls<br>";\n  }\n}','php','0','2','2','1787089842');
INSERT INTO `cp_sphp` VALUES('112','olahxls','olahxls_berangkat','','function olahxls_berangkat($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $ex1=explode("/",$r[6]);\n          $ex2=explode("/",$r[9]);\n          $ex3=explode("/",$r[18]);\n          if($r[\'8\']==\'MED\') {\n            $gel=1;\n          } else {\n            $gel=2;\n          }\n          $dt[$k] = [\n            \'emb\' => $r[0],\n            \'klt\' => $r[1],\n            \'rpergi_tgl\' => $ex1[2].\'-\'.$ex1[1].\'-\'.$ex1[0],\n            \'rpergi_jam\' => strtotime($ex1[2].\'-\'.$ex1[1].\'-\'.$ex1[0].\' \'.$r[7].\':00\'),\n            \'port\' => $r[8],\n            \'rtiba_tgl\' => $ex2[2].\'-\'.$ex2[1].\'-\'.$ex2[0],\n            \'rtiba_jam\' => strtotime($ex2[2].\'-\'.$ex2[1].\'-\'.$ex2[0].\' \'.$r[10].\':00\'),\n            \'flight\' => NoSpace($r[11]),\n            \'rjhi\' => $r[12],\n            \'rtphi\' => $r[13],\n            \'rtpihi\' => $r[14],\n            \'rtkhi\' => $r[15],\n            \'rtotal\' => $r[16],\n            \'gel\' => $gel,\n            \'ftiba_tgl\' => $ex3[2].\'-\'.$ex3[1].\'-\'.$ex3[0],\n            \'ftiba_jam\' => strtotime($ex3[2].\'-\'.$ex3[1].\'-\'.$ex3[0].\' \'.$r[19].\':00\'),\n            \'fjhi\' => $r[20],\n            \'ftphi\' => $r[21],\n            \'ftpihi\' => $r[22],\n            \'ftkhi\' => $r[23],\n            \'ftotal\' => $r[24],\n            \'code\' => trim($r[0]).\'\'.trim($r[1]),\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    echo "<pre>"; print_r($dt[2]); echo "</pre>";\n    \n    foreach ($dt as $k => $v) {\n      if($k>1) {\n        $idt=array(\n          \'id\'=>$k-1,\n          \'emb\'=>$v[\'emb\'],\n          \'klt\'=>$v[\'klt\'],\n          \'code\'=>$v[\'code\'],\n          \'rpergi_tgl\'=>$v[\'rpergi_tgl\'],\n          \'rpergi_jam\'=>$v[\'rpergi_jam\'],\n          \'port\'=>$v[\'port\'],\n          \'rtiba_tgl\'=>$v[\'rtiba_tgl\'],\n          \'rtiba_jam\'=>$v[\'rtiba_jam\'],\n          \'flight\'=>$v[\'flight\'],\n          \'rjhi\'=>$v[\'rjhi\'],\n          \'rtphi\'=>$v[\'rtphi\'],\n          \'rtkhi\'=>$v[\'rtkhi\'],\n          \'rtpihi\'=>$v[\'rtpihi\'],\n          \'rtotal\'=>$v[\'rtotal\'],\n          \'gel\'=>$v[\'gel\'],\n          \'ftiba_tgl\'=>$v[\'ftiba_tgl\'],\n          \'ftiba_jam\'=>$v[\'ftiba_jam\'],\n          \'fjhi\'=>$v[\'fjhi\'],\n          \'ftphi\'=>$v[\'ftphi\'],\n          \'ftpihi\'=>$v[\'ftpihi\'],\n          \'ftkhi\'=>$v[\'ftkhi\'],\n          \'ftotal\'=>$v[\'ftotal\'],\n          \'update_at\'=>time(),\n        );\n        $udt=array(\n          \'code\'=>$v[\'code\'],\n          \'rpergi_tgl\'=>$v[\'rpergi_tgl\'],\n          \'rpergi_jam\'=>$v[\'rpergi_jam\'],\n          \'port\'=>$v[\'port\'],\n          \'rtiba_tgl\'=>$v[\'rtiba_tgl\'],\n          \'rtiba_jam\'=>$v[\'rtiba_jam\'],\n          \'flight\'=>$v[\'flight\'],\n          \'rjhi\'=>$v[\'rjhi\'],\n          \'rtphi\'=>$v[\'rtphi\'],\n          \'rtkhi\'=>$v[\'rtkhi\'],\n          \'rtpihi\'=>$v[\'rtpihi\'],\n          \'rtotal\'=>$v[\'rtotal\'],\n          \'gel\'=>$v[\'gel\'],\n          \'ftiba_tgl\'=>$v[\'ftiba_tgl\'],\n          \'ftiba_jam\'=>$v[\'ftiba_jam\'],\n          \'fjhi\'=>$v[\'fjhi\'],\n          \'ftphi\'=>$v[\'ftphi\'],\n          \'ftpihi\'=>$v[\'ftpihi\'],\n          \'ftkhi\'=>$v[\'ftkhi\'],\n          \'ftotal\'=>$v[\'ftotal\'],\n          \'update_at\'=>time(),\n        );\n        InsertUpdate($db,"berangkat",$idt,$udt,1);\n\n        $udt2=array(\n          \'id_takeoff_date\'=>$v[\'rpergi_tgl\'],\n          \'id_takeoff_time\'=>$v[\'rpergi_jam\'],\n          \'sa_arrival_port\'=>$v[\'port\'],\n          \'flight_no\'=>$v[\'flight\'],\n          \'sa_arrival_date\'=>$v[\'rtiba_tgl\'],\n          \'sa_arrival_time\'=>$v[\'rtiba_jam\'],\n          \'rin_jhi\'=>$v[\'rjhi\'],\n          \'rin_ptg\'=>$v[\'rtphi\']+$v[\'rtpihi\']+$v[\'rtkhi\'],\n          \'rin_total\'=>$v[\'rtotal\'],\n\n          \'fsa_arrival_date\'=>$v[\'ftiba_tgl\'],\n          \'fsa_arrival_time\'=>$v[\'ftiba_jam\'],\n          \'fin_jhi\'=>$v[\'fjhi\'],\n          \'fin_ptg\'=>$v[\'ftphi\']+$v[\'ftpihi\']+$v[\'ftkhi\'],\n          \'fin_total\'=>$v[\'ftotal\'],\n        );\n        Update($db,"mykloter",$udt2,"`code`=\'".$v[\'code\']."\'",1);\n        \n      }\n    }\n    /* */\n  } else {\n    echo "tak ada data xls<br>";    \n  }\n}','php','0','2','2','1787103045');
INSERT INTO `cp_sphp` VALUES('113','olahxls','olahxls_pulang','','function olahxls_pulang($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx = SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $dt[$k] = [\n            \'emb\' => $r[0],\n            \'klt\' => $r[1],\n            //\'hari\' => $r[1],\n            \'tgl\' => $r[3],\n            \'jam\' => strtotime($r[3]),\n            //\'airline\' => $r[4],\n            //\'flight\' => $r[5],\n            \'qty\' => $r[6],\n            \'noh1\' => $r[7],\n            \'hotel1\' => $r[8],\n            \'map1\' => $r[9],\n            \'kap1\' => $r[10],\n\n            \'noh2\' => $r[11],\n            \'hotel2\' => $r[12],\n            \'map2\' => $r[13],\n            \'kap2\' => $r[14],\n            \n            \'noh3\' => $r[15],\n            \'hotel3\' => $r[16],\n            \'map3\' => $r[17],\n            \'kap3\' => $r[18],\n            \'code\' => trim($r[0]).\'\'.trim($r[1]),\n            \'flight_no\' => trim($r[4]).\'\'.trim($r[5]),\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    \n    foreach ($dt as $k => $v) {\n        $idt=array(\n          \'id\'=>$k-1,\n          \'emb\'=>$v[\'emb\'],\n          \'klt\'=>$v[\'klt\'],\n          \'code\'=>$v[\'code\'],\n          \'tgl\'=>$v[\'tgl\'],\n          \'jam\'=>$v[\'jam\'],\n          \'flight_no\'=>$v[\'flight_no\'],\n          \'qty\'=>$v[\'qty\'],\n          \'noh1\'=>$v[\'noh1\'],\n          \'hotel1\'=>gpc($v[\'hotel1\']),\n          \'map1\'=>$v[\'map1\'],\n          \'kap1\'=>$v[\'kap1\'],\n          \'noh2\'=>$v[\'noh2\'],\n          \'hotel2\'=>gpc($v[\'hotel2\']),\n          \'map2\'=>$v[\'map2\'],\n          \'kap2\'=>$v[\'kap2\'],\n          \'noh3\'=>$v[\'noh3\'],\n          \'hotel3\'=>gpc($v[\'hotel3\']),\n          \'map3\'=>$v[\'map3\'],\n          \'kap3\'=>$v[\'kap3\'],\n          \'update_at\'=>time(),\n        );\n        $udt=array(\n          \'emb\'=>$v[\'emb\'],\n          \'klt\'=>$v[\'klt\'],\n          \'code\'=>$v[\'code\'],\n          \'tgl\'=>$v[\'tgl\'],\n          \'jam\'=>$v[\'jam\'],\n          \'flight_no\'=>$v[\'flight_no\'],\n          \'qty\'=>$v[\'qty\'],\n          \'noh1\'=>$v[\'noh1\'],\n          \'hotel1\'=>gpc($v[\'hotel1\']),\n          \'map1\'=>$v[\'map1\'],\n          \'kap1\'=>$v[\'kap1\'],\n          \'noh2\'=>$v[\'noh2\'],\n          \'hotel2\'=>gpc($v[\'hotel2\']),\n          \'map2\'=>$v[\'map2\'],\n          \'kap2\'=>$v[\'kap2\'],\n          \'noh3\'=>$v[\'noh3\'],\n          \'hotel3\'=>gpc($v[\'hotel3\']),\n          \'map3\'=>$v[\'map3\'],\n          \'kap3\'=>$v[\'kap3\'],\n          \'update_at\'=>time(),\n        );\n        InsertUpdate($db,"pulang",$idt,$udt,1);\n\n        $udt2=array(\n          \'sa_departure_flight\'=>$v[\'flight_no\'],\n          \'sa_departure_date\'=>$v[\'tgl\'],\n          \'sa_departure_time\'=>$v[\'jam\'],\n          \'out_qty\'=>$v[\'qty\'],\n        );\n        Update($db,"mykloter",$udt2,"`code`=\'".$v[\'code\']."\'",1);      \n    }\n    /* */\n  } else {\n    echo "tak ada data xls<br>";    \n  }\n}','php','0','2','2','1787091667');
INSERT INTO `cp_sphp` VALUES('114','olahxls','olahxls_xkruki','','function olahxls_xkruki($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          if($r[6]!=\'\' && (is_numeric($r[0]))) {\n            $dt[$k] = [\n              \'urut\' => $r[0],\n              \'lantai\' => $r[1],\n              \'kamar\' => $r[2],\n              \'kapasitas\' => $r[3],\n              \'type\' => $r[4],\n              \'status\' => $r[5],\n              \'kloter\' => $r[6],\n              \'rumah\'=>$xlsx->getCell(0,\'C2\'),\n              \'gedung\'=>$xlsx->getCell(0,\'C3\'),\n              \'filename\' => $_FILES[\'xlsfile\'][\'name\'],\n            ];           \n          }\n        }\n      }\n    }            \n    //echo "<pre>"; print_r($xlsx); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    //echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    /*\n    foreach ($dt as $k => $v) {\n      if(strlen($v[\'rumah\'])>3) {\n        $sek=substr($v[\'rumah\'],0,2);\n      } else {\n        $sek=substr($v[\'rumah\'],0,1);\n      }\n      $idt=array(\n        \'daker\'=>$_POST[\'daker\'],\n        \'gel\'=>$_POST[\'gel\'],\n        \'rumah\'=>$v[\'rumah\'],\n        \'sektor\'=>$sek,\n        \'gedung\'=>$v[\'gedung\'],\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      $udt=array(\n        \'gel\'=>$_POST[\'gel\'],\n        \'sektor\'=>$sek,\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      InsertUpdate($db,"kruki",$idt,$udt,1);\n    }\n    /* */\n  } else {\n    echo "tak ada data xls<br>";    \n  }\n}','php','0','2','2','1787183522');
INSERT INTO `cp_sphp` VALUES('115','olahxls','olahxls_kruki','','function olahxls_kruki($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexls.php\';\n  $dt=[];          \n  $firstrow=0; \n  if ($xlsx=ShuchkinSimpleXLS::parse($FILES["xlsfile"]["tmp_name"])) {\n    $cell=$xlsx->rows();\n    foreach( $xlsx->rows() as $k=>$r ) {\n      if($k>3 && $r[5]==0 && (is_numeric($r[0]))) {\n        $dt[$k-3] = [\n          \'urut\' => $r[0],\n          \'lantai\' => $r[1],\n          \'kamar\' => $r[2],\n          \'kapasitas\' => $r[3],\n          \'type\' => $r[4],\n          \'status\' => $r[5],\n          \'kloter\' => $r[6],\n          \'rumah\'=>$cell[1][2],\n          \'gedung\'=>$cell[2][2],\n          \'filename\' => $FILES[\'xlsfile\'][\'name\'],\n        ];           \n      }\n    }     \n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    //echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    /*\n    foreach ($dt as $k => $v) {\n      if(strlen($v[\'rumah\'])>3) {\n        $sek=substr($v[\'rumah\'],0,2);\n      } else {\n        $sek=substr($v[\'rumah\'],0,1);\n      }\n      $idt=array(\n        \'daker\'=>$_POST[\'daker\'],\n        \'gel\'=>$_POST[\'gel\'],\n        \'rumah\'=>$v[\'rumah\'],\n        \'sektor\'=>$sek,\n        \'gedung\'=>$v[\'gedung\'],\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      $udt=array(\n        \'gel\'=>$_POST[\'gel\'],\n        \'sektor\'=>$sek,\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      InsertUpdate($db,"kruki",$idt,$udt,1);\n    }\n    /* */\n  }   \n}','php','0','2','2','1787092061');
INSERT INTO `cp_sphp` VALUES('144','olahcsv','olah_csv_idmed','','function olah_csv_idmed($p) {\n  global $db,$ar;    \n  //2,JKG5,ABRAJ SAADAH,522,66225,445,NOH\n  //$col = explode("n", $_POST[\'csv\']);\n  //$data = str_getcsv($p);\n  //echo "<pre>"; print_r($data); echo "</pre>";\n  $data=explode(\',\',strtoupper(trim($p)));\n  $dt[\'no\']=$data[0];\n  $dt[\'code\']=trim($data[1]);\n  $dt[\'majmuah\']=trim(to_char_space($data[2]));\n  $dt[\'med_hotel_no\']=trim($data[3]);\n  $dt[\'contract_no\']=trim($data[4]);\n  $dt[\'pax\']=trim($data[5]);\n  $dt[\'kitchen_code\']=trim(to_char_space($data[6]));\n  //echo count($data)."<br>";\n  //echo "<pre>"; print_r($dt); echo "</pre>";\n  if(count($data)!=7) {\n    echo "<pre>"; print_r($dt); echo "</pre>";\n  }\n\n  \n  if(count($data)==7) {\n    $sql1 = "select * from `berangkat` where code=\'".$dt[\'code\']."\'";\n    $res1 = mysqli_query($db, $sql1);\n    //echo $sql;\n    $r1 = mysqli_fetch_assoc($res1);\n\n    //t1 cek code\n    $sql0="SELECT * from mykloter where code=\'".$dt[\'code\']."\'";\n    $res0=mysqli_query($db,$sql0);\n    if(mysqli_num_rows($res0)==0) {\n      $sql4 = "select id from `mykloter` order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      if(mysqli_num_rows($res4)>0) {\n        $rw4 = mysqli_fetch_assoc($res4);\n        $id2=$rw4[\'id\']+1;\n      } else {\n        $id2=1;      \n      } \n      $sql5 = "select id from `myhotel` order by id desc limit 1";\n      $res5 = mysqli_query($db, $sql5);\n      if(mysqli_num_rows($res4)>0) {\n        $r5 = mysqli_fetch_assoc($res5);\n        $id5=$r5[\'id\']+1;\n      } else {\n        $id5=1;      \n      } \n\n      $udt=array(\n        \'id\'=>$id2,\n        \'code\'=>strtoupper($dt[\'code\']),\n        \'no\'=>$dt[\'no\'],\n        \'sa_arrival_port\'=>\'MED\',\n        \'flight_no\'=>$r1[\'flight\'],\n        \'id_takeoff_date\'=>date("Y-m-d",$r1[\'rpergi_jam\']),\n        \'id_takeoff_time\'=>$r1[\'rpergi_jam\'],\n        \'sa_arrival_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']),\n        \'sa_arrival_time\'=>$r1[\'rtiba_jam\'],\n        \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n        \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n        \'jhi\'=>$r1[\'rjhi\'],\n        \'tphi\'=>$r1[\'rtphi\'],\n        \'tpihi\'=>$r1[\'rtpihi\'],\n        \'tkhi\'=>$r1[\'rtkhi\'],\n        \'ptg\'=>$r1[\'rtphi\']+$r1[\'rtpihi\']+$r1[\'rtkhi\'],\n        \'total\'=>$r1[\'rtotal\'],\n        \'code_qty\'=>$r1[\'rtotal\'],\n        \'gel\'=>1,\n        \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n        \'emb\'=>strtoupper(substr($dt[\'code\'],0,3)),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'syarikah\'=>$ar[\'emb2syarikah\'][substr($dt[\'code\'],0,3)],\n        \'create_at\'=>time(),\n        \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time(),\n      );\n      Insert($db,"mykloter",$udt,1);\n\n      $idt=array(\n        \'id\'=>$id5,\n        \'code\'=>strtoupper($dt[\'code\']),\n        \'no\'=>$dt[\'no\'],\n        \'gel\'=>1,\n        \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n        \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n        \'jhi\'=>$r1[\'rjhi\'],\n        \'tphi\'=>$r1[\'rtphi\'],\n        \'tpihi\'=>$r1[\'rtpihi\'],\n        \'tkhi\'=>$r1[\'rtkhi\'],\n        \'ptg\'=>$r1[\'rtphi\']+$r1[\'rtpihi\']+$r1[\'rtkhi\'],\n        \'total\'=>$r1[\'rtotal\'],\n        \'code_qty\'=>$r1[\'rtotal\'],\n        \'majmuah\'=>$dt[\'majmuah\'],\n        \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n        \'hotel_no\'=>trim($dt[\'med_hotel_no\']),\n        \'contract_no\'=>trim($dt[\'contract_no\']),\n        \'pax\'=>$dt[\'pax\'],\n        \'kitchen_code\'=>trim($dt[\'kitchen_code\']),\n        \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n        \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'create_at\'=>time(),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"myhotel",$idt,1);\n\n    } else {\n\n      $udt3=array(\n        \'no\'=>$dt[\'no\'],\n        \'sa_arrival_port\'=>\'MED\',\n        \'flight_no\'=>$r1[\'flight\'],\n        \'id_takeoff_date\'=>date("Y-m-d",$r1[\'rpergi_jam\']),\n        \'id_takeoff_time\'=>$r1[\'rpergi_jam\'],\n        \'sa_arrival_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']),\n        \'sa_arrival_time\'=>$r1[\'rtiba_jam\'],\n        \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n        \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n        \'jhi\'=>$r1[\'rjhi\'],\n        \'tphi\'=>$r1[\'rtphi\'],\n        \'tpihi\'=>$r1[\'rtpihi\'],\n        \'tkhi\'=>$r1[\'rtkhi\'],\n        \'ptg\'=>$r1[\'rtphi\']+$r1[\'rtpihi\']+$r1[\'rtkhi\'],\n        \'total\'=>$r1[\'rtotal\'],\n        \'code_qty\'=>$r1[\'rtotal\'],\n        \'gel\'=>1,\n        \'emb\'=>strtoupper(substr($dt[\'code\'],0,3)),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'syarikah\'=>$ar[\'emb2syarikah\'][substr($dt[\'code\'],0,3)],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time(),\n      );\n      Update($db,"mykloter",$udt3,"`code`=\'".$dt[\'code\']."\'",1);\n\n      $sql6="SELECT * from myhotel where code=\'".$dt[\'code\']."\' and hotel_no=".$dt[\'med_hotel_no\']." and kitchen_code=\'".$dt[\'kitchen_code\']."\'";\n      $res6=mysqli_query($db,$sql6);\n      if(mysqli_num_rows($res6)==0) {\n\n        $sql5 = "select id from `myhotel` order by id desc limit 1";\n        $res5 = mysqli_query($db, $sql5);\n        $r5 = mysqli_fetch_assoc($res5);\n        $id5=$r5[\'id\']+1;\n        $idt=array(\n          \'id\'=>$id5,\n          \'code\'=>strtoupper($dt[\'code\']),\n          \'no\'=>$dt[\'no\'],\n          \'gel\'=>1,\n          \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n          \'klt\'=>substr($dt[\'code\'],3),\n          \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n          \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n          \'jhi\'=>$r1[\'rjhi\'],\n          \'tphi\'=>$r1[\'rtphi\'],\n          \'tpihi\'=>$r1[\'rtpihi\'],\n          \'tkhi\'=>$r1[\'rtkhi\'],\n          \'ptg\'=>$r1[\'rtphi\']+$r1[\'rtpihi\']+$r1[\'rtkhi\'],\n          \'total\'=>$r1[\'rtotal\'],\n          \'code_qty\'=>$r1[\'rtotal\'],\n          \'majmuah\'=>$dt[\'majmuah\'],\n          \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n          \'hotel_no\'=>trim($dt[\'med_hotel_no\']),\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'kitchen_code\'=>trim($dt[\'kitchen_code\']),\n          \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n          \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'create_at\'=>time(),\n          \'update_at\'=>time(),\n        );\n        Insert($db,"myhotel",$idt,1);\n\n\n      } else {\n        $udt=array(\n          \'ptg\'=>$r1[\'rtphi\']+$r1[\'rtpihi\']+$r1[\'rtkhi\'],\n          \'total\'=>$r1[\'rtotal\'],\n          \'code_qty\'=>$r1[\'rtotal\'],\n          \'no\'=>$dt[\'no\'],\n          \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n          \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n          \'majmuah\'=>$dt[\'majmuah\'],\n          \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n          \'hotel_no\'=>trim($dt[\'med_hotel_no\']),\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'kitchen_code\'=>trim($dt[\'kitchen_code\']),\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_at\'=>time(),\n        );\n        Update($db,"myhotel",$udt,"`code`=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'med_hotel_no\']."\' and kitchen_code=\'".$dt[\'kitchen_code\']."\'",1);\n      }\n\n      $udt3=array(\n        \'in_hotel_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']+7200),\n        \'in_hotel_time\'=>$r1[\'rtiba_jam\']+7200,\n        \'update_at\'=>time(),\n      );\n      Update($db,"penempatan",$udt3,"`daker`=2 and gel=1 and `emb`=\'".substr($dt[\'code\'],0,3)."\' and `klt`=\'".substr($dt[\'code\'],3)."\' and no_rumah=\'".$dt[\'med_hotel_no\']."\'",1);\n\n    }\n  }\n  /* */\n}','php','0','2','5','1787356241');
INSERT INTO `cp_sphp` VALUES('145','olahcsv','olah_csv_medmec','','function olah_csv_medmec($p) {\n  global $db,$ar;    \n  //no,code,qty,tgl_pergi,med_hotel_no,bus,bus_no,mec_hotel_no,contract_no,pax\n  //12,UPG2,393,2026-04-30 17,507,DALLAH,1-10,204,71717,393\n  $data=explode(\',\',strtoupper(trim($p)));\n  $dt[\'no\']=$data[0];\n  $dt[\'code\']=trim($data[1]);\n  $dt[\'qty\']=$data[2];\n  if(strlen(trim($data[3]))<9) {\n    $dt[\'date_med\']=\'2026-\'.$data[3].\':00:00\';\n  } else {\n    $dt[\'date_med\']=$data[3].\':00:00\';\n  }\n  $dt[\'med_hotel_no\']=$data[4];\n  $dt[\'bus\']=$data[5];\n  $dt[\'bus_no\']=$data[6];\n  $dt[\'mec_hotel_no\']=$data[7];\n  $dt[\'contract_no\']=$data[8];\n  $dt[\'pax\']=$data[9];\n  if(strlen($dt[\'mec_hotel_no\'])>3) {\n    $dt[\'mec_sektor\']=substr($dt[\'mec_hotel_no\'],0,2);\n  } else {\n    $dt[\'mec_sektor\']=substr($dt[\'mec_hotel_no\'],0,1);\n  }\n  echo "<br>".count($data)."<br>";\n  echo "<pre>"; print_r($dt); echo "</pre>";  \n\n  if(count($data)!=10) {\n\n    echo "data tidak benar<br>";\n\n  } else {\n\n    //t1 cek code\n    $sql0="SELECT * from mykloter where code=\'".$dt[\'code\']."\'";\n    $res0=mysqli_query($db,$sql0);\n    if(mysqli_num_rows($res0)==1) {\n      $udt=array(\n        \'out_no\'=>$dt[\'no\'],\n        \'out_hotel_date\'=>substr($dt[\'date_med\'],0,10),\n        \'out_hotel_time\'=>strtotime($dt[\'date_med\']),\n        \'out_qty\'=>$dt[\'qty\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time(),\n      );\n      Update($db,"mykloter",$udt,"`code`=\'".$dt[\'code\']."\'",1);\n\n      $sql7="SELECT * from myhotel where code=\'".$dt[\'code\']."\' and hotel_no=".$dt[\'med_hotel_no\'];\n      $res7=mysqli_query($db,$sql7);\n      if(mysqli_num_rows($res7)==1) {\n        $udt2=array(\n          \'out_no\'=>$dt[\'no\'],\n          \'out_hotel_date\'=>substr($dt[\'date_med\'],0,10),\n          \'out_hotel_time\'=>strtotime($dt[\'date_med\']),\n          \'out_bus\'=>$dt[\'bus\'],\n          \'out_bus_no\'=>$dt[\'bus_no\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_at\'=>time(),\n        );\n        Update($db,"myhotel",$udt2,"`code`=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'med_hotel_no\']."\'",1);      \n      }\n\n      $udt3=array(\n        \'out_hotel_date\'=>substr($dt[\'date_med\'],0,10),\n        \'out_hotel_time\'=>strtotime($dt[\'date_med\']),\n        \'update_at\'=>time(),\n      );\n      Update($db,"penempatan",$udt3,"`daker`=2 and gel=1 and `emb`=\'".substr($dt[\'code\'],0,3)."\' and `klt`=\'".substr($dt[\'code\'],3)."\' and no_rumah=\'".$dt[\'med_hotel_no\']."\'",1);\n\n\n      //cek data mecca\n      $sql6="SELECT * from secondhotel where code=\'".$dt[\'code\']."\' and hotel_no=".$dt[\'mec_hotel_no\'];\n      $res6=mysqli_query($db,$sql6);\n      if(mysqli_num_rows($res6)==0) {\n\n        $sql5 = "select id from `secondhotel` order by id desc limit 1";\n        $res5 = mysqli_query($db, $sql5);\n        $r5 = mysqli_fetch_assoc($res5);\n        $id5=$r5[\'id\']+1;\n        $idt=array(\n          \'id\'=>$id5,\n          \'gel\'=>1,\n          \'code\'=>strtoupper($dt[\'code\']),\n          \'no\'=>$dt[\'no\'],\n          \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n          \'klt\'=>substr($dt[\'code\'],3),\n          \'in_hotel_date\'=>date("Y-m-d",strtotime($dt[\'date_med\'])+18000),\n          \'in_hotel_time\'=>strtotime($dt[\'date_med\'])+18000,\n          \'code_qty\'=>$dt[\'qty\'],\n          \'sektor\'=>$dt[\'mec_sektor\'],\n          \'hotel_no\'=>trim($dt[\'mec_hotel_no\']),\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'create_at\'=>time(),\n          \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_at\'=>time(),\n        );\n        Insert($db,"secondhotel",$idt,1);\n      }     \n\n      if(mysqli_num_rows($res6)==1) {\n\n        $udt=array(\n          \'no\'=>$dt[\'no\'],\n          \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n          \'klt\'=>substr($dt[\'code\'],3),\n          \'in_hotel_date\'=>date("Y-m-d",strtotime($dt[\'date_med\'])+18000),\n          \'in_hotel_time\'=>strtotime($dt[\'date_med\'])+18000,\n          \'code_qty\'=>$dt[\'qty\'],\n          \'sektor\'=>$dt[\'mec_sektor\'],\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_at\'=>time(),\n        );\n        Update($db,"secondhotel",$udt,"`code`=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'mec_hotel_no\']."\'",1);\n      }     \n    } \n  }\n  /* */\n}','php','0','2','5','1787095306');
INSERT INTO `cp_sphp` VALUES('146','olahcsv','olah_csv_mecmed','','function olah_csv_mecmed($p) {\n  global $db,$ar;    \n  //no,code,BUS,IN_TIME,majmuah,med_hotel_no,pax,BUS_NO,contract_no,kitchen_code,qty\n  //3,SUB57,BARAKAH,1-10,2026-06-07 16,SADU,512,380,66362,SAT,378\n  $data=explode(\',\',strtoupper(trim($p)));\n  $dt[\'no\']=$data[0];\n  $dt[\'code\']=$data[1];\n  $dt[\'bus\']=$data[2];\n  $dt[\'bus_no\']=$data[3];\n  if(strlen(trim($data[4]))<9) {\n    $dt[\'in_time\']=\'2026-\'.$data[4].\':00:00\';\n  } else {\n    $dt[\'in_time\']=$data[4].\':00:00\';\n  }\n  //$dt[\'in_time\']=$data[4];\n  $dt[\'majmuah\']=$data[5];\n  $dt[\'med_hotel_no\']=$data[6];\n  $dt[\'pax\']=$data[7];\n  $dt[\'contract_no\']=$data[8];\n  $dt[\'kitchen\']=$data[9];\n  $dt[\'qty\']=$data[10];\n  echo "<hr>".count($data)."<br>";\n  echo "<pre>"; print_r($dt); echo "</pre>";\n  if(count($data)!=11) {\n    echo "jumalh data sebaris salah<br>";\n  } else {  \n    \n    $sql1 = "select * from `berangkat` where code=\'".$dt[\'code\']."\'";\n    $res1 = mysqli_query($db, $sql1);\n    //echo $sql;\n    $r1 = mysqli_fetch_assoc($res1);\n    //echo "<pre>"; print_r($r1); echo "</pre>";\n\n    $sql2 = "SELECT * from `kloter_jadwal` where code=\'".$dt[\'code\']."\'";\n    $res2 = mysqli_query($db, $sql2);\n    //echo $sql;\n    $r2 = mysqli_fetch_assoc($res2);\n    //echo "<pre>"; print_r($r2); echo "</pre>";\n\n\n    $udt3=array(\n      \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n      \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n      \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n      \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n      \'update_at\'=>time(),\n    );\n    Update($db,"penempatan",$udt3,"`daker`=2 and gel=2 and `emb`=\'".substr($dt[\'code\'],0,3)."\' and `klt`=\'".substr($dt[\'code\'],3)."\' and no_rumah=\'".$dt[\'med_hotel_no\']."\'",1);\n\n    $sql0="SELECT * from mykloter where code=\'".$dt[\'code\']."\'";\n    $res0=mysqli_query($db,$sql0);\n    if(mysqli_num_rows($res0)==0) {\n      $sql4 = "select id from `mykloter` order by id desc limit 1";\n      $res4 = mysqli_query($db, $sql4);\n      $rw4 = mysqli_fetch_assoc($res4);\n      $id2=$rw4[\'id\']+1;\n      $sql5 = "select id from `myhotel` order by id desc limit 1";\n      $res5 = mysqli_query($db, $sql5);\n      $r5 = mysqli_fetch_assoc($res5);\n      $id5=$r5[\'id\']+1;\n\n      $udt=array(\n        \'id\'=>$id2,\n        \'code\'=>strtoupper($dt[\'code\']),\n        \'no\'=>$dt[\'no\'],\n        \'gel\'=>2,\n        \'sa_arrival_port\'=>\'JED\',\n        \'flight_no\'=>$r1[\'flight\'],\n        \'id_takeoff_date\'=>date("Y-m-d",$r1[\'rpergi_jam\']),\n        \'id_takeoff_time\'=>$r1[\'rpergi_jam\'],\n        \'sa_arrival_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']),\n        \'sa_arrival_time\'=>$r1[\'rtiba_jam\'],\n        \'sa_departure_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']),\n        \'sa_departure_time\'=>$r2[\'rpulang_jam\'],\n        \'sa_departure_flight\'=>$r2[\'rpulang_flight\'],\n        \'sa_departure_port\'=>$r2[\'rpulang_port\'],\n        \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n        \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n        \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n        \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n        \'jhi\'=>$r1[\'fjhi\'],\n        \'tphi\'=>$r1[\'ftphi\'],\n        \'tpihi\'=>$r1[\'ftpihi\'],\n        \'tkhi\'=>$r1[\'ftkhi\'],\n        \'ptg\'=>$r1[\'ftphi\']+$r1[\'ftpihi\']+$r1[\'ftkhi\'],\n        \'total\'=>$r1[\'ftotal\'],\n        \'code_qty\'=>$dt[\'qty\'],\n        \'syarikah\'=>$ar[\'emb2syarikah\'][substr($dt[\'code\'],0,3)],\n        \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n        \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'create_at\'=>time(),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"mykloter",$udt,1);\n      $idt=array(\n        \'id\'=>$id5,\n        \'code\'=>strtoupper($dt[\'code\']),\n        \'in_no\'=>$dt[\'no\'],\n        \'gel\'=>2,\n        \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n        \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n        \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n        \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n        \'jhi\'=>$r1[\'fjhi\'],\n        \'tphi\'=>$r1[\'ftphi\'],\n        \'tpihi\'=>$r1[\'ftpihi\'],\n        \'tkhi\'=>$r1[\'ftkhi\'],\n        \'ptg\'=>$r1[\'ftphi\']+$r1[\'ftpihi\']+$r1[\'ftkhi\'],\n        \'total\'=>$r1[\'ftotal\'],\n        \'code_qty\'=>$dt[\'qty\'],\n        \'majmuah\'=>$dt[\'majmuah\'],\n        \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n        \'hotel_no\'=>$dt[\'med_hotel_no\'],\n        \'contract_no\'=>$dt[\'contract_no\'],\n        \'pax\'=>$dt[\'pax\'],\n        \'kitchen_code\'=>$dt[\'kitchen\'],\n        \'in_bus\'=>$dt[\'bus\'],\n        \'in_bus_no\'=>$dt[\'bus_no\'],\n        \'out_bus\'=>$dt[\'bus\'],\n        \'out_bus_no\'=>$dt[\'bus_no\'],\n        \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n        \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'create_at\'=>time(),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"myhotel",$idt,1);\n    } else {\n\n      $udt3=array(\n        \'sa_departure_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']),\n        \'sa_departure_time\'=>$r2[\'rpulang_jam\'],\n        \'sa_departure_flight\'=>$r2[\'rpulang_flight\'],\n        \'sa_departure_port\'=>$r2[\'rpulang_port\'],\n        \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n        \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n        \'out_hotel_date\'=>date("Y-m-d",($r2[\'rpulang_jam\']-21600)),\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n      );\n      Update($db,"mykloter",$udt3,"`code`=\'".$dt[\'code\']."\'",1);\n\n      $sql6="SELECT * from myhotel where code=\'".$dt[\'code\']."\' and hotel_no=".$dt[\'med_hotel_no\'];\n      $res6=mysqli_query($db,$sql6);\n      if(mysqli_num_rows($res6)==0) {\n\n        $sql5 = "select id from `myhotel` order by id desc limit 1";\n        $res5 = mysqli_query($db, $sql5);\n        $r5 = mysqli_fetch_assoc($res5);\n        $id5=$r5[\'id\']+1;\n        $idt=array(\n          \'id\'=>$id5,\n          \'code\'=>strtoupper($dt[\'code\']),\n          \'in_no\'=>$dt[\'no\'],\n          \'gel\'=>2,\n          \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n          \'klt\'=>substr($dt[\'code\'],3),\n          \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n          \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n          \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n          \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n          \'jhi\'=>$r1[\'fjhi\'],\n          \'tphi\'=>$r1[\'ftphi\'],\n          \'tpihi\'=>$r1[\'ftpihi\'],\n          \'tkhi\'=>$r1[\'ftkhi\'],\n          \'ptg\'=>$r1[\'ftphi\']+$r1[\'ftpihi\']+$r1[\'ftkhi\'],\n          \'total\'=>$r1[\'ftotal\'],\n          \'code_qty\'=>$dt[\'qty\'],\n          \'majmuah\'=>$dt[\'majmuah\'],\n          \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n          \'hotel_no\'=>trim($dt[\'med_hotel_no\']),\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'kitchen_code\'=>trim($dt[\'kitchen\']),\n          \'in_bus\'=>$dt[\'bus\'],\n          \'in_bus_no\'=>$dt[\'bus_no\'],\n          \'out_bus\'=>$dt[\'bus\'],\n          \'out_bus_no\'=>$dt[\'bus_no\'],\n          \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n          \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'create_at\'=>time(),\n          \'update_at\'=>time(),\n        );\n        Insert($db,"myhotel",$idt,1);\n      } else {\n        $udt=array(\n          \'in_no\'=>$dt[\'no\'],\n          \'gel\'=>2,\n          \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n          \'klt\'=>substr($dt[\'code\'],3),\n          \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n          \'in_hotel_time\'=>strtotime($dt[\'in_time\']),\n          \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n          \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n          \'jhi\'=>$r1[\'fjhi\'],\n          \'tphi\'=>$r1[\'ftphi\'],\n          \'tpihi\'=>$r1[\'ftpihi\'],\n          \'tkhi\'=>$r1[\'ftkhi\'],\n          \'ptg\'=>$r1[\'ftphi\']+$r1[\'ftpihi\']+$r1[\'ftkhi\'],\n          \'total\'=>$r1[\'ftotal\'],\n          \'code_qty\'=>$dt[\'qty\'],\n          \'majmuah\'=>$dt[\'majmuah\'],\n          \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n          \'contract_no\'=>trim($dt[\'contract_no\']),\n          \'pax\'=>$dt[\'pax\'],\n          \'kitchen_code\'=>trim($dt[\'kitchen\']),\n          \'in_bus\'=>$dt[\'bus\'],\n          \'in_bus_no\'=>$dt[\'bus_no\'],\n          \'out_bus\'=>$dt[\'bus\'],\n          \'out_bus_no\'=>$dt[\'bus_no\'],\n          \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n          \'update_at\'=>time(),\n        );\n        Update($db,"myhotel",$udt,"`code`=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'med_hotel_no\']."\'",1);\n      }\n    }\n  }  \n  /* */\n}','php','0','2','5','1787106239');
INSERT INTO `cp_sphp` VALUES('147','olahcsv','olah_csv_mecmed_v2','','function olah_csv_mecmed_v2($p) {\n  global $db,$ar;    \n  //no,code,BUS,IN_TIME,majmuah,med_hotel_no,pax,BUS_NO,contract_no,kitchen_code,qty\n  //3,SUB57,BARAKAH,1-10,2026-06-07 16,SADU,512,380,66362,SAT,378\n  $data=explode(\',\',strtoupper(trim($p)));\n  $dt[\'no\']=$data[0];\n  $dt[\'code\']=$data[1];\n  $dt[\'bus\']=$data[2];\n  $dt[\'in_time\']=$data[3];\n  $dt[\'majmuah\']=$data[4];\n  $dt[\'med_hotel_no\']=$data[5];\n  $dt[\'pax\']=$data[6];\n  $dt[\'bus_no\']=$data[7];\n  $dt[\'contract_no\']=$data[8];\n  $dt[\'kitchen\']=$data[9];\n  $dt[\'qty\']=$data[10];\n  echo "<pre>"; print_r($dt); echo "</pre>";\n  \n  $sql1 = "select * from `berangkat` where code=\'".$dt[\'code\']."\'";\n  $res1 = mysqli_query($db, $sql1);\n  //echo $sql;\n  $r1 = mysqli_fetch_assoc($res1);\n  echo "<pre>"; print_r($r1); echo "</pre>";\n\n  $sql2 = "SELECT * from `kloter_jadwal` where code=\'".$dt[\'code\']."\'";\n  $res2 = mysqli_query($db, $sql2);\n  //echo $sql;\n  $r2 = mysqli_fetch_assoc($res2);\n  echo "<pre>"; print_r($r2); echo "</pre>";\n\n\n  $udt3=array(\n    \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n    \'in_hotel_time\'=>strtotime($dt[\'in_time\'].":00:00"),\n    \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n    \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n    \'update_at\'=>time(),\n  );\n  Update($db,"penempatan",$udt3,"`daker`=2 and gel=2 and `emb`=\'".substr($dt[\'code\'],0,3)."\' and `klt`=\'".substr($dt[\'code\'],3)."\' and no_rumah=\'".$dt[\'med_hotel_no\']."\'",1);\n\n  \n  $sql0="SELECT * from mykloter where code=\'".$dt[\'code\']."\'";\n  $res0=mysqli_query($db,$sql0);\n  if(mysqli_num_rows($res0)==0) {\n    $sql4 = "select id from `mykloter` order by id desc limit 1";\n    $res4 = mysqli_query($db, $sql4);\n    $rw4 = mysqli_fetch_assoc($res4);\n    $id2=$rw4[\'id\']+1;\n    $sql5 = "select id from `myhotel` order by id desc limit 1";\n    $res5 = mysqli_query($db, $sql5);\n    $r5 = mysqli_fetch_assoc($res5);\n    $id5=$r5[\'id\']+1;\n\n\n    $udt=array(\n      \'id\'=>$id2,\n      \'code\'=>strtoupper($dt[\'code\']),\n      \'no\'=>$dt[\'no\'],\n      \'gel\'=>2,\n      \'sa_arrival_port\'=>\'JED\',\n      \'flight_no\'=>$r1[\'flight\'],\n      \'id_takeoff_date\'=>date("Y-m-d",$r1[\'rpergi_jam\']),\n      \'id_takeoff_time\'=>$r1[\'rpergi_jam\'],\n      \'sa_arrival_date\'=>date("Y-m-d",$r1[\'rtiba_jam\']),\n      \'sa_arrival_time\'=>$r1[\'rtiba_jam\'],\n      \'sa_departure_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']),\n      \'sa_departure_time\'=>$r2[\'rpulang_jam\'],\n      \'sa_departure_flight\'=>$r2[\'rpulang_flight\'],\n      \'sa_departure_port\'=>$r2[\'rpulang_port\'],\n      \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n      \'in_hotel_time\'=>strtotime($dt[\'in_time\'].":00:00"),\n      \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n      \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n      \'jhi\'=>$r1[\'jhi\'],\n      \'tphi\'=>$r1[\'tphi\'],\n      \'tpihi\'=>$r1[\'tpihi\'],\n      \'tkhi\'=>$r1[\'tkhi\'],\n      \'ptg\'=>$r1[\'tphi\']+$r1[\'tpihi\']+$r1[\'tkhi\'],\n      \'total\'=>$r1[\'total\'],\n      \'code_qty\'=>$dt[\'qty\'],\n      \'syarikah\'=>$ar[\'emb2syarikah\'][substr($dt[\'code\'],0,3)],\n      \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n      \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n      \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n      \'create_at\'=>time(),\n      \'update_at\'=>time(),\n    );\n    Insert($db,"mykloter",$udt,1);\n    $idt=array(\n      \'id\'=>$id5,\n      \'code\'=>strtoupper($dt[\'code\']),\n      \'in_no\'=>$dt[\'no\'],\n      \'gel\'=>2,\n      \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n      \'klt\'=>substr($dt[\'code\'],3),\n      \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n      \'in_hotel_time\'=>strtotime($dt[\'in_time\'].":00:00"),\n      \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n      \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n      \'jhi\'=>$r1[\'jhi\'],\n      \'tphi\'=>$r1[\'tphi\'],\n      \'tpihi\'=>$r1[\'tpihi\'],\n      \'tkhi\'=>$r1[\'tkhi\'],\n      \'ptg\'=>$r1[\'tphi\']+$r1[\'tpihi\']+$r1[\'tkhi\'],\n      \'total\'=>$r1[\'total\'],\n      \'code_qty\'=>$dt[\'qty\'],\n      \'majmuah\'=>$dt[\'majmuah\'],\n      \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n      \'hotel_no\'=>$dt[\'med_hotel_no\'],\n      \'contract_no\'=>$dt[\'contract_no\'],\n      \'pax\'=>$dt[\'pax\'],\n      \'kitchen_code\'=>$dt[\'kitchen\'],\n      \'in_bus\'=>$dt[\'bus\'],\n      \'in_bus_no\'=>$dt[\'bus_no\'],\n      \'out_bus\'=>$dt[\'bus\'],\n      \'out_bus_no\'=>$dt[\'bus_no\'],\n      \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n      \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n      \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n      \'create_at\'=>time(),\n      \'update_at\'=>time(),\n    );\n    Insert($db,"myhotel",$idt,1);\n  } else {\n\n    $udt3=array(\n      \'sa_departure_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']),\n      \'sa_departure_time\'=>$r2[\'rpulang_jam\'],\n      \'sa_departure_flight\'=>$r2[\'rpulang_flight\'],\n      \'sa_departure_port\'=>$r2[\'rpulang_port\'],\n      \'out_hotel_date\'=>date("Y-m-d",($r2[\'rpulang_jam\']-21600)),\n      \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n      \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n    );\n    Update($db,"mykloter",$udt3,"`code`=\'".$dt[\'code\']."\'",1);\n\n    $sql6="SELECT * from myhotel where code=\'".$dt[\'code\']."\' and hotel_no=".$dt[\'med_hotel_no\'];\n    $res6=mysqli_query($db,$sql6);\n    if(mysqli_num_rows($res6)==0) {\n\n      $sql5 = "select id from `myhotel` order by id desc limit 1";\n      $res5 = mysqli_query($db, $sql5);\n      $r5 = mysqli_fetch_assoc($res5);\n      $id5=$r5[\'id\']+1;\n      $idt=array(\n        \'id\'=>$id5,\n        \'code\'=>strtoupper($dt[\'code\']),\n        \'in_no\'=>$dt[\'no\'],\n        \'gel\'=>2,\n        \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n        \'in_hotel_time\'=>strtotime($dt[\'in_time\'].":00:00"),\n        \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n        \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n        \'jhi\'=>$r1[\'jhi\'],\n        \'tphi\'=>$r1[\'tphi\'],\n        \'tpihi\'=>$r1[\'tpihi\'],\n        \'tkhi\'=>$r1[\'tkhi\'],\n        \'ptg\'=>$r1[\'tphi\']+$r1[\'tpihi\']+$r1[\'tkhi\'],\n        \'total\'=>$r1[\'total\'],\n        \'code_qty\'=>$dt[\'qty\'],\n        \'majmuah\'=>$dt[\'majmuah\'],\n        \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n        \'hotel_no\'=>trim($dt[\'med_hotel_no\']),\n        \'contract_no\'=>trim($dt[\'contract_no\']),\n        \'pax\'=>$dt[\'pax\'],\n        \'kitchen_code\'=>trim($dt[\'kitchen\']),\n        \'in_bus\'=>$dt[\'bus\'],\n        \'in_bus_no\'=>$dt[\'bus_no\'],\n        \'out_bus\'=>$dt[\'bus\'],\n        \'out_bus_no\'=>$dt[\'bus_no\'],\n        \'daker\'=>$_SESSION[\'user\'][\'daker\'],\n        \'create_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'create_at\'=>time(),\n        \'update_at\'=>time(),\n      );\n      Insert($db,"myhotel",$idt,1);\n    } else {\n      $udt=array(\n        \'in_no\'=>$dt[\'no\'],\n        \'gel\'=>2,\n        \'emb\'=>substr(strtoupper($dt[\'code\']),0,3),\n        \'klt\'=>substr($dt[\'code\'],3),\n        \'in_hotel_date\'=>substr($dt[\'in_time\'],0,10),\n        \'in_hotel_time\'=>strtotime($dt[\'in_time\'].":00:00"),\n        \'out_hotel_date\'=>date("Y-m-d",$r2[\'rpulang_jam\']-21600),\n        \'out_hotel_time\'=>$r2[\'rpulang_jam\']-21600,\n        \'jhi\'=>$r1[\'jhi\'],\n        \'tphi\'=>$r1[\'tphi\'],\n        \'tpihi\'=>$r1[\'tpihi\'],\n        \'tkhi\'=>$r1[\'tkhi\'],\n        \'ptg\'=>$r1[\'tphi\']+$r1[\'tpihi\']+$r1[\'tkhi\'],\n        \'total\'=>$r1[\'total\'],\n        \'code_qty\'=>$dt[\'qty\'],\n        \'majmuah\'=>$dt[\'majmuah\'],\n        \'sektor\'=>substr($dt[\'med_hotel_no\'],0,1),\n        \'contract_no\'=>trim($dt[\'contract_no\']),\n        \'pax\'=>$dt[\'pax\'],\n        \'kitchen_code\'=>trim($dt[\'kitchen\']),\n        \'in_bus\'=>$dt[\'bus\'],\n        \'in_bus_no\'=>$dt[\'bus_no\'],\n        \'out_bus\'=>$dt[\'bus\'],\n        \'out_bus_no\'=>$dt[\'bus_no\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time(),\n      );\n      Update($db,"myhotel",$udt,"`code`=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'med_hotel_no\']."\'",1);\n    }\n  }\n  /* */\n}','php','0','2','5','1787106246');
INSERT INTO `cp_sphp` VALUES('148','olahcsv','olah_csv_timbang','','function olah_csv_timbang($p) {\n  global $db,$ar;    \n  //urut,code,med_hotel_no,pax,jam_timbang,tim_timbang\n  //6,JKG21,506,319,2026-06-16 12,1\n  $data=explode(\',\',strtoupper(trim($p)));\n  $dt[\'no\']=$data[0];\n  $dt[\'code\']=$data[1];\n  $dt[\'med_hotel_no\']=$data[2];\n  $dt[\'pax\']=$data[3];\n  //$dt[\'jam_timbang\']=$data[4];\n  if(strlen(trim($data[4]))<9) {\n    $dt[\'jam_timbang\']=\'2026-\'.$data[4].\':00:00\';\n  } else {\n    $dt[\'jam_timbang\']=$data[4].\':00:00\';\n  }\n  $dt[\'tim\']=$data[5];\n  echo "<br>"; count($data); echo "<br>";  \n  echo "<pre>"; print_r($dt); echo "</pre>";  \n  if(count($data)!=6) {\n    echo "jumlah data sebaris tidak benar<br>";\n  } else {\n    //t1 cek code\n    $sql0="SELECT * from myhotel where code=\'".$dt[\'code\']."\' and hotel_no=\'".$dt[\'med_hotel_no\']."\'";\n    $res0=mysqli_query($db,$sql0);\n    if(mysqli_num_rows($res0)==1) {\n      $udt=array(\n        \'timbang_no\'=>$dt[\'no\'],\n        \'timbang_date\'=>substr($dt[\'jam_timbang\'],0,10),\n        \'timbang_time\'=>strtotime($dt[\'jam_timbang\']),\n        \'timbang_pax\'=>$dt[\'pax\'],\n        \'timbang_tim\'=>$dt[\'tim\'],\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time()\n      );\n      Update($db,"myhotel",$udt,"`code`=\'".$dt[\'code\']."\' and `hotel_no`=\'".$dt[\'med_hotel_no\']."\'",1);\n      $udt2=array(\n        \'timbang_date\'=>substr($dt[\'jam_timbang\'],0,10),\n        \'timbang_time\'=>strtotime($dt[\'jam_timbang\']),\n        \'update_by\'=>$_SESSION[\'user\'][\'petugas\'],\n        \'update_at\'=>time()\n      );\n      Update($db,"mykloter",$udt2,"`code`=\'".$dt[\'code\']."\'",1);\n    }\n  }\n  /* */\n}','php','0','2','5','1787106228');
INSERT INTO `cp_sphp` VALUES('149','common.function','get_color_theme','','function get_color_theme($f_main) {\n  $htm6=file_get_contents($f_main);\n  $dt2=array();\n  $dt4=arCss($htm6);\n  foreach($dt4 as $k => $v) {\n    foreach ($v as $k1 => $v1) {\n      foreach ($v1 as $k2 => $v2) {\n        if($k2==\'background-color\') {\n          //echo $k2.":".$v2."<br>";\n          //echo $v2.", ".$k2.", <br>";\n          $dt2[\'background_color\'][$v2][]=$k1;\n        }\n        if($k2==\'color\') {\n          //echo $k2.":".$v2."<br>";\n          //echo $v2.", ".$k2.", <br>";\n          $dt2[\'color\'][$v2][]=$k1;\n        }\n      }\n    }\n  }\n\n  foreach ($dt2 as $k => $v) {\n    echo $k."<br><ul>";\n    foreach($v as $k1=>$v1) {\n      echo "<li>".$v1."</li>";\n    }\n    echo "</ul>";\n  }\n\n}','php','0','2','1','1787096410');
INSERT INTO `cp_sphp` VALUES('150','common.function','endsWith','','function endsWith(string $haystack, string $needle): bool{\n  $length = strlen($needle);\n  if ($length === 0) {\n      return true; // An empty needle always "ends" a string\n  }\n  return substr($haystack, -$length) === $needle;\n}','php','0','2','1','1787096440');
INSERT INTO `cp_sphp` VALUES('151','common.function','Network','','function Network($id) {\n  global $db,$ar;\n  $sql4 = "select * from network where id=".$id;\n  $res4 = mysqli_query($db, $sql4);\n  $r4 = mysqli_fetch_assoc($res4);\n  return $r4;\n}','php','0','2','1','1787096460');
INSERT INTO `cp_sphp` VALUES('152','common.function','tbl_tool_id','','function tbl_tool_id($tbl,$st=1) {\n  global $db,$ar;\n  $sql4 = "select id from `".$tbl."` where id>=$st order by id";\n  $res4 = mysqli_query($db, $sql4);\n  $a=$st;\n  while($r4 = mysqli_fetch_assoc($res4)) {\n    $udt=array(\n      \'id2\'=>$a,\n    );\n    Update($db,$tbl,$udt,"id=".$r4[\'id\'],1);\n    $a++;\n  }\n  $sql3="UPDATE `".$tbl."` set id=id2 where id>=".$st;\n  $res3=mysqli_query($db,$sql3);\n  $sql5="ALTER TABLE `".$tbl."` AUTO_INCREMENT=".$a+1;\n  $res5=mysqli_query($db,$sql5);\n  echo $sql5."<br>";\n}','php','0','2','1','1787096490');
INSERT INTO `cp_sphp` VALUES('153','common.function','xhr','','function xhr($url){\n  global $ar,$db;\n  include_once $ar[\'path_core\']."dom/request.php";\n  $xhr = request($url);\n  return $xhr;\n}','php','0','2','1','1787096519');
INSERT INTO `cp_sphp` VALUES('154','common.function','copyimg','','function copyimg($file,$newfile) {\n  if ( copy($file, $newfile) ) {\n    $ret="<br>Copy <b>$file</b> success!<br>";\n  }else{\n    $ret="<br>Copy <b>$file</b> failed.<br>";\n  }\n  return $ret;\n}','php','0','2','1','1790684888');
INSERT INTO `cp_sphp` VALUES('155','common.function','getimg','','function getimg($url) {         \n  $headers[] = \'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg\';              \n  $headers[] = \'Connection: Keep-Alive\';         \n  $headers[] = \'Content-type: application/x-www-form-urlencoded;charset=UTF-8\';         \n  $user_agent = \'php\';         \n  $process = curl_init($url);         \n  curl_setopt($process, CURLOPT_HTTPHEADER, $headers);         \n  curl_setopt($process, CURLOPT_HEADER, 0);         \n  curl_setopt($process, CURLOPT_USERAGENT, $user_agent); //check here         \n  curl_setopt($process, CURLOPT_TIMEOUT, 30);         \n  curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);         \n  curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);         \n  $return = curl_exec($process);         \n  curl_close($process);         \n  return $return;     \n}','php','0','2','1','1787096786');
INSERT INTO `cp_sphp` VALUES('156','common.function','hitung_usia','','function hitung_usia($tanggal_lahir) {\n  // Create DateTime objects for the birth date and the current date\n  $tgl_lahir = date_create($tanggal_lahir);\n  $hari_ini = date_create(date("Y-m-d"));\n  // Calculate the difference between the two dates\n  $diff = date_diff($tgl_lahir, $hari_ini);\n  // Get the number of full years from the difference object\n  return $diff->y;\n}','php','0','2','1','1787096822');
INSERT INTO `cp_sphp` VALUES('157','common.function','image_view','','function image_view($modul,$item_id) {\n  global $db,$ar;\n  $sql2 = "SELECT * FROM `files` WHERE modul=\'".$modul."\' and item_id=\'".$item_id."\' and `type`=\'image\' ";\n  $run2 = mysqli_query($db, $sql2);\n  $ret= "<hr><h3>Images</h3><div class=\'row mb-20 pb-20\'>";\n  while($r2 = mysqli_fetch_assoc($run2)) {\n    $img_small=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/small/".$r2[\'url\'];\n    $img_big=$modul."/".$r2[\'path\']."/".$r2[\'seq\']."/image/big/".$r2[\'url\'];\n\n    $ret .= \'\n    <div id="row_\'.$r2[\'id\'].\'" class="col-sm-3 col-lg-2 col-xs-6">\n      <a href="\'.$ar[\'url_img\'].\'\'.$img_big.\'" target="_blank"><div class="card">\n        \n    \';\n    $ret .= \'<img src="\'.$ar[\'url_img\'].\'\'.$img_small.\'" alt="">\';\n    $ret .= \'\';\n    $ret .= \'\n        \n      </div></a>\n      <button type="button" class="btn btn-sm btn-danger mt-2" onClick="media_del(\'.$r2[\'id\'].\')">Delete</button> <button type="button" class="btn btn-sm btn-success mt-2" onClick="media_sel(\'.$r2[\'id\'].\',\'.$r2[\'item_id\'].\')">Select</button>\n    </div>\';\n\n  }\n  $ret .= "</div>";\n\n  return $ret;\n\n}','php','0','2','1','1787096875');
INSERT INTO `cp_sphp` VALUES('158','common.function','Insert','','function Insert($mysqli,$table,$data,$v=0){\n  $fields = array_keys( $data );  \n  $values = array_map( array($mysqli, \'real_escape_string\'), array_values( $data ) );\n  if($v==1) {\n      echo "INSERT INTO `$table`(`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'", $values )."\');";\n  }\n  //exit;  \n  mysqli_query($mysqli, "INSERT INTO `$table`(`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'", $values )."\');") or die( mysqli_error($mysqli) );\n}','php','0','2','1','1787096987');
INSERT INTO `cp_sphp` VALUES('159','common.function','InsertUpdate','','function InsertUpdate($mysqli,$table_name,$i_data,$u_data,$v=0){   \n  $i_fields = array_keys( $i_data );  \n  $i_values = array_map( array($mysqli, \'real_escape_string\'), array_values( $i_data ) );\n  $u_fields = array_keys( $u_data );  \n  $u_values = array_map( array($mysqli, \'real_escape_string\'), array_values( $u_data ) );\n  $sql = "INSERT INTO `$table_name` (`".implode("`,`",$i_fields)."`) VALUES (\'".implode("\',\'", $i_values )."\') ";    \n  $sql .= " on duplicate key UPDATE ";\n  $sets = array();\n  foreach($u_data as $column => $value) {\n    $sets[] = "`".$column."`=\'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n  if($v==1) {\n    echo $sql.";<br>";\n  }\n  return mysqli_query($mysqli,$sql);\n}','php','0','2','1','1787096995');
INSERT INTO `cp_sphp` VALUES('160','common.function','Update','','function Update($mysqli,$table_name, $form_data, $where_clause=\'\',$v=0){   \n  //global $mysqli;\n  // check for optional where clause\n  $whereSQL = \'\';\n  if(!empty($where_clause)){\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\')\n    {\n        // not found, add key word\n        $whereSQL = " WHERE ".$where_clause;\n    } else\n    {\n        $whereSQL = " ".trim($where_clause);\n    }\n  }\n  // start the actual SQL statement\n  $sql = "UPDATE `".$table_name."` SET ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($form_data as $column => $value)\n  {\n       $sets[] = "`".$column."` = \'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n\n  // append the where statement\n  $sql .= $whereSQL;\n       \n  // run and return the query result\n  if($v==1) {\n    echo $sql."<br>";\n  }\n  return mysqli_query($mysqli,$sql);\n}','php','0','2','1','1787097046');
INSERT INTO `cp_sphp` VALUES('161','common.function','Delete','','function Delete($mysqli,$table_name, $where_clause=\'\')\n{   \n    //global $mysqli;\n    // check for optional where clause\n    $whereSQL = \'\';\n    if(!empty($where_clause))\n    {\n        // check to see if the \'where\' keyword exists\n        if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\')\n        {\n            // not found, add keyword\n            $whereSQL = " WHERE ".$where_clause;\n        } else\n        {\n            $whereSQL = " ".trim($where_clause);\n        }\n    }\n    // build the query\n    $sql = "DELETE FROM `".$table_name."` ".$whereSQL;\n     \n    // run and return the query result resource\n    return mysqli_query($mysqli,$sql);\n}','php','0','2','1','1787097065');
INSERT INTO `cp_sphp` VALUES('162','common.function','Insert_v2','','function Insert_v2($mysqli,$table,$data){\n  $dt=array();\n  $fields = array_keys($data);  \n  $values = array_map(array($mysqli,\'real_escape_string\'),array_values($data));\n  $sql="INSERT INTO `$table` (`".implode("`,`",$fields)."`) VALUES (\'".implode("\',\'",$values)."\')";\n  $dt[\'sql\']=$sql;\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }\n  return $dt;\n}','php','0','2','1','1789517645');
INSERT INTO `cp_sphp` VALUES('163','common.function','InsertUpdate_v2','','function InsertUpdate_v2($mysqli,$table_name,$i_data,$u_data){   \n  $dt=array();\n  $i_fields = array_keys($i_data);  \n  $i_values = array_map(array($mysqli, \'real_escape_string\'), array_values($i_data));\n\n  $u_fields = array_keys($u_data);  \n  $u_values = array_map(array($mysqli, \'real_escape_string\'), array_values($u_data));\n\n  $sql = "INSERT INTO `$table_name` (`".implode("`,`",$i_fields)."`) VALUES (\'".implode("\',\'", $i_values)."\')";\n\n  // start the actual SQL statement\n  $sql .= " on duplicate key UPDATE ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($u_data as $column => $value) {\n       $sets[] = "`".$column."`=\'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n  $dt[\'sql\']=$sql.";";\n  // run and return the query result\n  // return mysqli_query($mysqli,$sql);\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return $dt;\n}','php','0','2','1','1789517663');
INSERT INTO `cp_sphp` VALUES('164','common.function','Update_v2','','function Update_v2($mysqli,$table_name, $form_data, $where_clause=\'\'){   \n  //global $mysqli;\n  // check for optional where clause\n  $whereSQL = \'\';\n  if(!empty($where_clause)){\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\'){\n      // not found, add key word\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  // start the actual SQL statement\n  $sql = "UPDATE `".$table_name."` SET ";\n\n  // loop and build the column /\n  $sets = array();\n  foreach($form_data as $column => $value){\n    $sets[] = "`".$column."` = \'".$value."\'";\n  }\n  $sql .= implode(\', \', $sets);\n\n  // append the where statement\n  $sql .= $whereSQL;\n       \n  $dt[\'sql\']=$sql.";";\n  // run and return the query result\n  // return mysqli_query($mysqli,$sql);\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return $dt;\n}','php','0','2','1','1789517267');
INSERT INTO `cp_sphp` VALUES('165','common.function','Delete_v2','','function Delete_v2($mysqli,$table_name, $where_clause=\'\'){   \n  $whereSQL = \'\';\n  if(!empty($where_clause)) {\n    // check to see if the \'where\' keyword exists\n    if(substr(strtoupper(trim($where_clause)), 0, 5) != \'WHERE\') {\n      // not found, add keyword\n      $whereSQL = " WHERE ".$where_clause;\n    } else {\n      $whereSQL = " ".trim($where_clause);\n    }\n  }\n  // build the query\n  $sql = "DELETE FROM `".$table_name."` ".$whereSQL;\n\n  $dt[\'sql\']=$sql.";";\n  // run and return the query result\n  // return mysqli_query($mysqli,$sql);\n  if(mysqli_query($mysqli,$sql)) {\n    $dt[\'result\']="Success";\n  } else {\n    $dt[\'result\']="Error";    \n  }  \n  return $dt;\n}','php','0','2','1','1789517630');
INSERT INTO `cp_sphp` VALUES('166','common.function','getDistance','','function getDistance($latitude1, $longitude1, $latitude2, $longitude2) {\n  $theta = $longitude1 - $longitude2;\n  $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));\n  $miles = acos($miles);\n  $miles = rad2deg($miles);\n  $miles = $miles * 60 * 1.1515;\n  $feet = $miles * 5280;\n  $yards = $feet / 3;\n  $kilometers = $miles * 1.609344;\n  $meters = $kilometers * 1000;\n  //return compact(\'miles\',\'feet\',\'yards\',\'kilometers\',\'meters\'); \n  return $kilometers;\n}','php','0','2','1','1787097165');
INSERT INTO `cp_sphp` VALUES('167','common.function','image_copy_from_url','','function image_copy_from_url($POST,$modul) {\n    global $db,$ar;\n    //echo "<pre>"; print_r($POST); echo "</pre>";\n    //echo "<pre>"; print_r($FILES); echo "</pre>";\n    if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n        $title=$POST[\'title\'];\n    } else {\n        $title="";\n    }\n    if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n        $caption=$POST[\'caption\'];\n    } else {\n        $caption="";\n    }\n    //get last id\n    $sql2= "select id from `files` order by id desc limit 1";\n    $res2=mysqli_query($db,$sql2);\n    $r2=mysqli_fetch_assoc($res2);\n\n    if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n        $iid=$r2[\'id\']+1;\n    } else {\n        $iid=1;\n    }\n\n\n    //get last seq\n    $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n    //echo $sql9."<br>";\n    $res9=mysqli_query($db,$sql9);\n    $r9=mysqli_fetch_assoc($res9);\n\n    if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n        $seq=$r9[\'seq\']+1;\n    } else {\n        $seq=1;\n    }\n\n    $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n    if (!is_dir($folder_y)) {\n        mkdir($folder_y, 0777, true);\n    }\n    $folder_ym=$folder_y."/".date("m");\n    if (!is_dir($folder_ym)) {\n        mkdir($folder_ym, 0777, true);\n    }\n\n    $folder_ymd=$folder_ym."/".date("d");\n    if (!is_dir($folder_ymd)) {\n        mkdir($folder_ymd, 0777, true);\n    }\n\n    $folder_ymdh=$folder_ymd."/".date("H");\n    if (!is_dir($folder_ymdh)) {\n        mkdir($folder_ymdh, 0777, true);\n    }\n\n    $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n    if (!is_dir($folder_main)) {\n        mkdir($folder_main, 0777, true);\n    }\n    $folder_seq=$folder_main."/".$seq;\n    if (!is_dir($folder_seq)) {\n        mkdir($folder_seq, 0777, true);\n    }\n\n    $folder_tmp=$folder_seq."/tmp";\n    if (!is_dir($folder_tmp)) {\n        mkdir($folder_tmp, 0777, true);\n    }\n\n    /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n    switch($_POST[\'file_type\']) {\n      case "Image";\n\n    }*/\n\n    $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n\n    //$e_ext=explode("/",$FILES[\'file\'][\'type\']);\n    //$file_name=date("YmdHis").".".$e_ext[1];\n\n    if($POST[\'url_img_src\']!=\'\') {\n        $info_img = getimagesize($POST[\'url_img_src\']);\n        $e_ext=explode("/",$info_img[\'mime\']);\n        $file_name=date("YmdHis").".".$e_ext[1];\n        $e_url=explode("/",$POST[\'url_img_src\']);\n\n        $icopy=image_copy($POST[\'url_img_src\'],$folder_tmp."/".$file_name);\n        //echo "Image Card Front Uploaded";\n        //$file_name=date("YmdHis").".jpg";\n\n\n        $sub_folder=$folder_seq."/image";\n        $sub_folder_big=$folder_seq."/image/big";\n        $sub_folder_medium=$folder_seq."/image/medium";\n        $sub_folder_small=$folder_seq."/image/small";\n\n        if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n        if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n        if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n        if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n        $source_image=$folder_tmp.\'/\'. $file_name;\n        $img_big= $sub_folder_big."/".$file_name;\n        $img_medium= $sub_folder_medium."/".$file_name;\n        $img_small= $sub_folder_small."/".$file_name;\n        //$destination=$ar[\'img_path\']."".$img_url;\n        //resize(640, $destination, $source_image);\n        image_handler($source_image,$img_big,1080,1080,90,false);\n        image_handler($source_image,$img_medium,800,800,90,false);\n        image_handler($source_image,$img_small,150,150,90,false);\n\n        echo $sub_folder_small."<br>";\n\n        $udata2=array(\n          \'id\'=>$iid,\n          \'seq\'=>$seq,\n          \'modul\'=>$modul,\n          \'item_id\'=>$POST[\'id\'],\n          \'type\'=>\'image\',\n          \'title\'=>gpc($title),\n          \'caption\'=>gpc($caption),\n          \'url_original\'=>\'tmp/\'.$file_name,\n          \'create_at\'=>time(),\n          \'path\'=>$path,\n          \'url\'=>$file_name\n          );\n        Insert($db,"files",$udata2,1);\n\n        $udt2=array(\n          \'img\'=>$modul."/".$path."/".$seq."/image/medium/".$file_name,\n        );\n        Update($db,$modul,$udt2,"id=".$POST[\'id\'],1);\n    }\n}','php','0','2','1','1787097800');
INSERT INTO `cp_sphp` VALUES('168','common.function','image_upload','','function image_upload($POST,$FILES,$modul) {\n    global $db,$ar;\n    //echo "<pre>"; print_r($POST); echo "</pre>";\n    //echo "<pre>"; print_r($FILES); echo "</pre>";\n    if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n        $title=$POST[\'title\'];\n    } else {\n        $title="";\n    }\n    if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n        $caption=$POST[\'caption\'];\n    } else {\n        $caption="";\n    }\n    //get last id\n    $sql2= "select id from `files` order by id desc limit 1";\n    $res2=mysqli_query($db,$sql2);\n    $r2=mysqli_fetch_assoc($res2);\n\n    if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n        $iid=$r2[\'id\']+1;\n    } else {\n        $iid=1;\n    }\n\n\n    //get last seq\n    $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n    echo $sql9."<br>";\n    $res9=mysqli_query($db,$sql9);\n    $r9=mysqli_fetch_assoc($res9);\n\n    if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n        $seq=$r9[\'seq\']+1;\n    } else {\n        $seq=1;\n    }\n\n    $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n    if (!is_dir($folder_y)) {\n        mkdir($folder_y, 0777, true);\n    }\n    $folder_ym=$folder_y."/".date("m");\n    if (!is_dir($folder_ym)) {\n        mkdir($folder_ym, 0777, true);\n    }\n\n    $folder_ymd=$folder_ym."/".date("d");\n    if (!is_dir($folder_ymd)) {\n        mkdir($folder_ymd, 0777, true);\n    }\n\n    $folder_ymdh=$folder_ymd."/".date("H");\n    if (!is_dir($folder_ymdh)) {\n        mkdir($folder_ymdh, 0777, true);\n    }\n\n    $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n    if (!is_dir($folder_main)) {\n        mkdir($folder_main, 0777, true);\n    }\n    $folder_seq=$folder_main."/".$seq;\n    if (!is_dir($folder_seq)) {\n        mkdir($folder_seq, 0777, true);\n    }\n\n    $folder_tmp=$folder_seq."/tmp";\n    if (!is_dir($folder_tmp)) {\n        mkdir($folder_tmp, 0777, true);\n    }\n\n    /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n    switch($_POST[\'file_type\']) {\n      case "Image";\n\n    }*/\n\n    $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n\n    $e_ext=explode("/",$FILES[\'file\'][\'type\']);\n    $file_name=date("YmdHis").".".$e_ext[1];\n\n    if($POST[\'file_type\']==\'image\') {\n        if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_tmp.\'/\'. $FILES["file"][\'name\'])) {\n              //echo "Image Card Front Uploaded";\n              //$file_name=date("YmdHis").".jpg";\n\n\n              $sub_folder=$folder_seq."/image";\n              $sub_folder_big=$folder_seq."/image/big";\n              $sub_folder_medium=$folder_seq."/image/medium";\n              $sub_folder_small=$folder_seq."/image/small";\n\n              if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n              if(!is_dir($sub_folder_big)){ mkdir($sub_folder_big, 0755); }\n              if(!is_dir($sub_folder_medium)){ mkdir($sub_folder_medium, 0755); }\n              if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n              $source_image=$folder_tmp.\'/\'. $FILES["file"][\'name\'];\n              $img_big= $sub_folder_big."/".$file_name;\n              $img_medium= $sub_folder_medium."/".$file_name;\n              $img_small= $sub_folder_small."/".$file_name;\n              //$destination=$ar[\'img_path\']."".$img_url;\n              //resize(640, $destination, $source_image);\n              image_handler($source_image,$img_big,1080,1080,90,false);\n              image_handler($source_image,$img_medium,800,800,90,false);\n              image_handler($source_image,$img_small,150,150,90,false);\n\n              echo $sub_folder_small."<br>";\n\n              $udata2=array(\n                \'id\'=>$iid,\n                \'seq\'=>$seq,\n                \'modul\'=>$modul,\n                \'item_id\'=>$POST[\'id\'],\n                \'type\'=>\'image\',\n                \'title\'=>gpc($title),\n                \'caption\'=>gpc($caption),\n                \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n                \'create_at\'=>time(),\n                \'path\'=>$path,\n                \'url\'=>$file_name\n                );\n              Insert($db,"files",$udata2,1);\n\n              $udt2=array(\n                \'img\'=>$modul."/".$path."/".$seq."/image/medium/".$file_name,\n              );\n              Update($db,$modul,$udt2,"id=".$POST[\'id\'],1);\n        }\n\n    } else {\n\n        if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_seq.\'/\'.$file_name)) {\n              \n            //echo "Image Card Front Uploaded";\n\n            $udata2=array(\n                \'id\'=>$iid,\n                \'seq\'=>$seq,\n                \'modul\'=>$modul,\n                \'item_id\'=>$POST[\'id\'],\n                \'type\'=>$POST[\'file_type\'],\n                \'title\'=>gpc($title),\n                \'caption\'=>gpc($caption),\n                \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n                \'create_at\'=>time(),\n                \'path\'=>$path,\n                \'url\'=>$file_name,\n                );\n            Insert($db,"files",$udata2,0);\n        }\n    }   \n}','php','0','2','1','1787097274');
INSERT INTO `cp_sphp` VALUES('169','common.function','image_upload_original','','function image_upload_original($POST,$FILES,$modul) {\n    global $db,$ar;\n    //echo "<pre>"; print_r($POST); echo "</pre>";\n    //echo "<pre>"; print_r($FILES); echo "</pre>";\n    if(isset($POST[\'title\']) && ($POST[\'title\']!=\'\')) {\n        $title=$POST[\'title\'];\n    } else {\n        $title="";\n    }\n    if(isset($POST[\'caption\']) && ($POST[\'caption\']!=\'\')) {\n        $caption=$POST[\'caption\'];\n    } else {\n        $caption="";\n    }\n    //get last id\n    $sql2= "select id from `files` order by id desc limit 1";\n    $res2=mysqli_query($db,$sql2);\n    $r2=mysqli_fetch_assoc($res2);\n\n    if(isset($r2[\'id\']) && ($r2[\'id\']>0)) {\n        $iid=$r2[\'id\']+1;\n    } else {\n        $iid=1;\n    }\n\n\n    //get last seq\n    $sql9= "select seq from `files` where item_id=".$POST[\'id\']." and modul=\'".$modul."\' order by seq desc limit 1";\n    echo $sql9."<br>";\n    $res9=mysqli_query($db,$sql9);\n    $r9=mysqli_fetch_assoc($res9);\n\n    if(isset($r9[\'seq\']) && ($r9[\'seq\']>0)) {\n        $seq=$r9[\'seq\']+1;\n    } else {\n        $seq=1;\n    }\n\n    $folder_y=$ar[\'img_path\'].$modul."/".date("y");\n    if (!is_dir($folder_y)) {\n        mkdir($folder_y, 0777, true);\n    }\n    $folder_ym=$folder_y."/".date("m");\n    if (!is_dir($folder_ym)) {\n        mkdir($folder_ym, 0777, true);\n    }\n\n    $folder_ymd=$folder_ym."/".date("d");\n    if (!is_dir($folder_ymd)) {\n        mkdir($folder_ymd, 0777, true);\n    }\n\n    $folder_ymdh=$folder_ymd."/".date("H");\n    if (!is_dir($folder_ymdh)) {\n        mkdir($folder_ymdh, 0777, true);\n    }\n\n    $folder_main=$folder_ymdh."/".$POST[\'id\'];\n\n    if (!is_dir($folder_main)) {\n        mkdir($folder_main, 0777, true);\n    }\n    $folder_seq=$folder_main."/".$seq;\n    if (!is_dir($folder_seq)) {\n        mkdir($folder_seq, 0777, true);\n    }\n\n    $folder_tmp=$folder_seq."/tmp";\n    if (!is_dir($folder_tmp)) {\n        mkdir($folder_tmp, 0777, true);\n    }\n\n    /*$sub_folder=$_POST[\'id\']."/".$seq."/";\n    switch($_POST[\'file_type\']) {\n      case "Image";\n\n    }*/\n\n    $path=date("y")."/".date("m")."/".date("d")."/".date("H")."/".$POST[\'id\'];\n\n    $e_ext=explode("/",$FILES[\'file\'][\'type\']);\n    $file_name=date("YmdHis").".".$e_ext[1];\n\n    if($POST[\'file_type\']==\'image\') {\n        if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_tmp.\'/\'. $file_name)) {\n              //echo "Image Card Front Uploaded";\n              //$file_name=date("YmdHis").".jpg";\n\n\n              $sub_folder=$folder_seq."/image";\n              $sub_folder_small=$folder_seq."/image/small";\n\n              if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); }\n              if(!is_dir($sub_folder_small)){ mkdir($sub_folder_small, 0755); }\n\n              $source_image=$folder_tmp.\'/\'. $file_name;\n              $img_small= $sub_folder_small."/".$file_name;\n              //$destination=$ar[\'img_path\']."".$img_url;\n              //resize(640, $destination, $source_image);\n              image_handler($source_image,$img_small,150,150,90,false);\n\n              echo $sub_folder_small."<br>";\n\n              $udata2=array(\n                \'id\'=>$iid,\n                \'seq\'=>$seq,\n                \'modul\'=>$modul,\n                \'item_id\'=>$POST[\'id\'],\n                \'type\'=>\'image\',\n                \'title\'=>gpc($title),\n                \'caption\'=>gpc($caption),\n                \'url_original\'=>\'tmp/\'.$file_name,\n                \'create_at\'=>time(),\n                \'path\'=>$path,\n                \'url\'=>$file_name\n                );\n              Insert($db,"files",$udata2,1);\n\n              $udt2=array(\n                \'img\'=>$modul."/".$path."/".$seq."/tmp/".$file_name,\n                \'img_thumb\'=>$modul."/".$path."/".$seq."/image/small/".$file_name,\n              );\n              Update($db,$modul,$udt2,"id=".$POST[\'id\'],1);\n        }\n\n    } else {\n\n        if (move_uploaded_file($FILES[\'file\'][\'tmp_name\'], $folder_seq.\'/\'.$file_name)) {\n              \n            //echo "Image Card Front Uploaded";\n\n            $udata2=array(\n                \'id\'=>$iid,\n                \'seq\'=>$seq,\n                \'modul\'=>$modul,\n                \'item_id\'=>$POST[\'id\'],\n                \'type\'=>$POST[\'file_type\'],\n                \'title\'=>gpc($title),\n                \'caption\'=>gpc($caption),\n                \'url_original\'=>\'tmp/\'.$FILES["file"][\'name\'],\n                \'create_at\'=>time(),\n                \'path\'=>$path,\n                \'url\'=>$file_name,\n                );\n            Insert($db,"files",$udata2,0);\n        }\n    }   \n}','php','0','2','1','1787097318');
INSERT INTO `cp_sphp` VALUES('170','common.function','image_handler','','function image_handler($source_image,$destination,$tn_w = 100,$tn_h = 100,$quality = 80,$wmsource = false) {\n  // The getimagesize functions provides an "imagetype" string contstant, which can be passed to the image_type_to_mime_type function for the corresponding mime type\n  $info = getimagesize($source_image);\n  $imgtype = image_type_to_mime_type($info[2]);\n  // Then the mime type can be used to call the correct function to generate an image resource from the provided image\n  switch ($imgtype) {\n  case \'image/jpeg\':\n    $source = imagecreatefromjpeg($source_image);\n    break;\n  case \'image/gif\':\n    $source = imagecreatefromgif($source_image);\n    break;\n  case \'image/png\':\n    $source = imagecreatefrompng($source_image);\n    break;\n  default:\n    die($source_image.\'Invalid image type.\');\n  }\n  // Now, we can determine the dimensions of the provided image, and calculate the width/height ratio\n  $src_w = imagesx($source);\n  $src_h = imagesy($source);\n  $src_ratio = $src_w/$src_h;\n  // Now we can use the power of math to determine whether the image needs to be cropped to fit the new dimensions, and if so then whether it should be cropped vertically or horizontally. We\'re just going to crop from the center to keep this simple.\n  if ($tn_w/$tn_h > $src_ratio) {\n  $new_h = $tn_w/$src_ratio;\n  $new_w = $tn_w;\n  } else {\n  $new_w = $tn_h*$src_ratio;\n  $new_h = $tn_h;\n  }\n  $x_mid = $new_w/2;\n  $y_mid = $new_h/2;\n  // Now actually apply the crop and resize!\n  $newpic = imagecreatetruecolor(round($new_w), round($new_h));\n  imagecopyresampled($newpic, $source, 0, 0, 0, 0, $new_w, $new_h, $src_w, $src_h);\n  $final = imagecreatetruecolor($tn_w, $tn_h);\n  imagecopyresampled($final, $newpic, 0, 0, ($x_mid-($tn_w/2)), ($y_mid-($tn_h/2)), $tn_w, $tn_h, $tn_w, $tn_h);\n  // If a watermark source file is specified, get the information about the watermark as well. This is the same thing we did above for the source image.\n  if($wmsource) {\n  $info = getimagesize($wmsource);\n  $imgtype = image_type_to_mime_type($info[2]);\n  switch ($imgtype) {\n    case \'image/jpeg\':\n      $watermark = imagecreatefromjpeg($wmsource);\n      break;\n    case \'image/gif\':\n      $watermark = imagecreatefromgif($wmsource);\n      break;\n    case \'image/png\':\n      $watermark = imagecreatefrompng($wmsource);\n      break;\n    default:\n      die(\'Invalid watermark type.\');\n  }\n  // Determine the size of the watermark, because we\'re going to specify the placement from the top left corner of the watermark image, so the width and height of the watermark matter.\n  $wm_w = imagesx($watermark);\n  $wm_h = imagesy($watermark);\n  // Now, figure out the values to place the watermark in the bottom right hand corner. You could set one or both of the variables to "0" to watermark the opposite corners, or do your own math to put it somewhere else.\n  $wm_x = ($tn_w - $wm_w)/2;\n  $wm_y = ($tn_h - $wm_h)/2;\n  // Copy the watermark onto the original image\n  // The last 4 arguments just mean to copy the entire watermark\n  imagecopy($final, $watermark, $wm_x, $wm_y, 0, 0, $wm_w, $wm_h);\n  }\n  // Ok, save the output as a jpeg, to the specified destination path at the desired quality.\n  // You could use imagepng or imagegif here if you wanted to output those file types instead.\n  if(Imagejpeg($final,$destination,$quality)) {\n  return true;\n  }\n  // If something went wrong\n  return false;\n}','php','0','2','1','1787097346');
INSERT INTO `cp_sphp` VALUES('171','common.function','image_resize_with_mark','','function image_resize_with_mark($source_image,$destination,$new_w,$quality = 80,$wmsource = false) {\n  // The getimagesize functions provides an "imagetype" string contstant, which can be passed to the image_type_to_mime_type function for the corresponding mime type\n  $info = getimagesize($source_image);\n  $imgtype = image_type_to_mime_type($info[2]);\n  // Then the mime type can be used to call the correct function to generate an image resource from the provided image\n  switch ($imgtype) {\n  case \'image/jpeg\':\n    $source = imagecreatefromjpeg($source_image);\n    break;\n  case \'image/gif\':\n    $source = imagecreatefromgif($source_image);\n    break;\n  case \'image/png\':\n    $source = imagecreatefrompng($source_image);\n    break;\n  default:\n    die($source_image.\'Invalid image type.\');\n  }\n  // Now, we can determine the dimensions of the provided image, and calculate the width/height ratio\n  $src_w = imagesx($source);\n  $src_h = imagesy($source);\n  $src_ratio = $src_h/$src_w;\n  // Now we can use the power of math to determine whether the image needs to be cropped to fit the new dimensions, and if so then whether it should be cropped vertically or horizontally. We\'re just going to crop from the center to keep this simple.\n  \n  /*\n  if ($tn_w/$tn_h > $src_ratio) {\n  $new_h = $tn_w/$src_ratio;\n  $new_w = $tn_w;\n  } else {\n  $new_w = $tn_h*$src_ratio;\n  $new_h = $tn_h;\n  }\n  */\n  \n  $new_h=$new_w*$src_ratio;\n  $tn_w=$new_w;\n  $tn_h=$new_h;\n  \n  $x_mid = $new_w/2;\n  $y_mid = $new_h/2;\n\n\n\n  // Now actually apply the crop and resize!\n  $newpic = imagecreatetruecolor(round($new_w), round($new_h));\n  imagecopyresampled($newpic, $source, 0, 0, 0, 0, $new_w, $new_h, $src_w, $src_h);\n  $final = imagecreatetruecolor($tn_w, $tn_h);\n  imagecopyresampled($final, $newpic, 0, 0, ($x_mid-($tn_w/2)), ($y_mid-($tn_h/2)), $tn_w, $tn_h, $tn_w, $tn_h);\n  // If a watermark source file is specified, get the information about the watermark as well. This is the same thing we did above for the source image.\n  if($wmsource) {\n  $info = getimagesize($wmsource);\n  $imgtype = image_type_to_mime_type($info[2]);\n  switch ($imgtype) {\n    case \'image/jpeg\':\n      $watermark = imagecreatefromjpeg($wmsource);\n      break;\n    case \'image/gif\':\n      $watermark = imagecreatefromgif($wmsource);\n      break;\n    case \'image/png\':\n      $watermark = imagecreatefrompng($wmsource);\n      break;\n    default:\n      die(\'Invalid watermark type.\');\n  }\n  // Determine the size of the watermark, because we\'re going to specify the placement from the top left corner of the watermark image, so the width and height of the watermark matter.\n  $wm_w = imagesx($watermark);\n  $wm_h = imagesy($watermark);\n  // Now, figure out the values to place the watermark in the bottom right hand corner. You could set one or both of the variables to "0" to watermark the opposite corners, or do your own math to put it somewhere else.\n  $wm_x = ($tn_w - $wm_w)/2;\n  $wm_y = ($tn_h - $wm_h)/2;\n  // Copy the watermark onto the original image\n  // The last 4 arguments just mean to copy the entire watermark\n  imagecopy($final, $watermark, $wm_x, $wm_y, 0, 0, $wm_w, $wm_h);\n  }\n  // Ok, save the output as a jpeg, to the specified destination path at the desired quality.\n  // You could use imagepng or imagegif here if you wanted to output those file types instead.\n  if(Imagejpeg($final,$destination,$quality)) {\n  return true;\n  }\n  // If something went wrong\n  return false;\n}','php','0','2','1','1787097386');
INSERT INTO `cp_sphp` VALUES('172','common.function','image_resize','','function image_resize($newWidth, $targetFile, $originalFile) {\n\n    //$originalFile = file_get_contents($imgurl);\n\n    $info = getimagesize($originalFile);\n    $mime = $info[\'mime\'];\n\n    switch ($mime) {\n            case \'image/jpeg\':\n                    $image_create_func = \'imagecreatefromjpeg\';\n                    $image_save_func = \'imagejpeg\';\n                    $new_image_ext = \'jpg\';\n                    break;\n\n            case \'image/png\':\n                    $image_create_func = \'imagecreatefrompng\';\n                    $image_save_func = \'imagepng\';\n                    $new_image_ext = \'png\';\n                    break;\n\n            case \'image/gif\':\n                    $image_create_func = \'imagecreatefromgif\';\n                    $image_save_func = \'imagegif\';\n                    $new_image_ext = \'gif\';\n                    break;\n\n            default: \n                    throw new Exception(\'Unknown image type.\');\n    }\n\n    $img = $image_create_func($originalFile);\n    list($width, $height) = getimagesize($originalFile);\n\n    $newHeight = ($height / $width) * $newWidth;\n    $tmp = imagecreatetruecolor($newWidth, $newHeight);\n    imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);\n\n    if (file_exists($targetFile)) {\n            unlink($targetFile);\n    }\n    $image_save_func($tmp, "$targetFile");\n}','php','0','2','1','1787097416');
INSERT INTO `cp_sphp` VALUES('173','common.function','slug','','function slug($text){\n  // replace non letter or digits by -\n  $text = preg_replace(\'~[^pLd]+~u\', \'-\', $text);\n\n  // transliterate\n  $text = iconv(\'utf-8\', \'us-ascii//TRANSLIT\', $text);\n\n  // remove unwanted characters\n  $text = preg_replace(\'~[^-w]+~\', \'\', $text);\n\n  // trim\n  $text = trim($text, \'-\');\n\n  // remove duplicate -\n  $text = preg_replace(\'~-+~\', \'-\', $text);\n\n  // lowercase\n  $text = strtolower($text);\n\n  if (empty($text)) {\n    return \'n-a\';\n  }\n\n  return $text;\n}','php','0','2','1','1787097449');
INSERT INTO `cp_sphp` VALUES('174','common.function','directory_delete','','function directory_delete($dir) {\n  if (is_dir($dir)) {\n    $scn = scandir($dir);\n    foreach ($scn as $files) {\n      if ($files !== \'.\') {\n        if ($files !== \'..\') {\n          if (!is_dir($dir . \'/\' . $files)) {\n              unlink($dir . \'/\' . $files);\n          } else {\n              emptyDir($dir . \'/\' . $files);\n              rmdir($dir . \'/\' . $files);\n          }\n        }\n      }\n    }\n  }\n}','php','0','2','1','1787097530');
INSERT INTO `cp_sphp` VALUES('175','common.function','directory_empty','','function directory_empty($dir) {\n  if (is_dir($dir)) {\n    $scn = scandir($dir);\n    foreach ($scn as $files) {\n      if ($files !== \'.\') {\n        if ($files !== \'..\') {\n          if (!is_dir($dir . \'/\' . $files)) {\n              unlink($dir . \'/\' . $files);\n          } else {\n              emptyDir($dir . \'/\' . $files);\n          }\n        }\n      }\n    }\n  }\n}','php','0','2','1','1787097827');
INSERT INTO `cp_sphp` VALUES('176','common.function','getUserIP','','function getUserIP(){\n  $client  = @$_SERVER[\'HTTP_CLIENT_IP\'];\n  $forward = @$_SERVER[\'HTTP_X_FORWARDED_FOR\'];\n  $remote  = $_SERVER[\'REMOTE_ADDR\'];\n\n  if(filter_var($client, FILTER_VALIDATE_IP))\n  {\n      $ip = $client;\n  }\n  elseif(filter_var($forward, FILTER_VALIDATE_IP))\n  {\n      $ip = $forward;\n  }\n  else\n  {\n      $ip = $remote;\n  }\n\n  return $ip;\n}','php','0','2','1','1787097571');
INSERT INTO `cp_sphp` VALUES('177','common.function','genToken','','function genToken($length = 10) {\n    $characters = \'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ_@!)(^%\';\n    $charactersLength = strlen($characters);\n    $randomString = \'\';\n    for ($i = 0; $i < $length; $i++) {\n        $randomString .= $characters[rand(0, $charactersLength - 1)];\n    }\n    return $randomString;\n}','php','0','2','1','1787097589');
INSERT INTO `cp_sphp` VALUES('178','common.function','genCode','','function genCode($length = 10) {\n  $characters = \'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ\';\n  $charactersLength = strlen($characters);\n  $randomString = \'\';\n  for ($i = 0; $i < $length; $i++) {\n    $randomString .= $characters[rand(0, $charactersLength - 1)];\n  }\n  return $randomString;\n}','php','0','2','1','1787097614');
INSERT INTO `cp_sphp` VALUES('179','common.function','image_copy','','function image_copy($file,$newfile) {\n  if ( copy($file, $newfile) ) {\n    $ret="<br>Copy <b>$file</b> success!<br>";\n  }else{\n    $ret="<br>Copy <b>$file</b> failed.<br>";\n  }\n  return $ret;\n}','php','0','2','1','1787097753');
INSERT INTO `cp_sphp` VALUES('181','filephp','edit','','function edit($id,$q,$col,$tbl) {\n   global $db,$ar;    \n  $sql = "select * from `".$tbl."` where id=".$id;\n  $res = mysqli_query($db, $sql);\n  //echo $sql;\n  $rw = mysqli_fetch_assoc($res);\n  $php_file=$ar[\'path_core\'].\'\'.$rw[\'folder\'].\'\'.$rw[\'slug\'].\'.php\';\n  if (file_exists($php_file)) {\n    $filecontent=file_get_contents($php_file);\n  } else {\n    $filecontent="<?php\n\n?>";      \n  } \n\n?>\n<div class="row">\n  <div class="col-7">\n  <?=form_edit($rw,$filecontent,$q,$col,$tbl);?>\n  </div>\n  <div class="col-5">\n    <div class="card">\n      <div class="card-body">\n        <?=$ar[\'path_core\'];?>\n        <h5 class="card-title"><?=$rw[\'folder\'];?><?=$rw[\'slug\'];?>.php</h5>\n        <form method="post" action="index.php?op=<?=$tbl;?>&op2=php_save&q=<?=$q;?>&col=folder&tbl=<?=$tbl;?>">\n          <input type="hidden" name="file_name" value="<?=$php_file;?>">\n          <input type="hidden" name="id" value="<?=$id;?>">\n          <input type="hidden" name="tbl" value="<?=$tbl;?>">\n          <textarea class="form-control" rows="20" name="content"><?=htmlspecialchars($filecontent);?></textarea>\n          <input type="submit" name="submit" class="btn btn-sm btn-success mt-2">\n        </form>\n      </div>\n    </div>\n  </div>\n</div>\n  <?php\n  //echo "<pre>"; print_r($rw); echo "</pre>";\n}','php','0','2','4','1790671272');
INSERT INTO `cp_sphp` VALUES('182','filephp','form_edit','','function form_edit($rw,$filecontent,$q,$col,$tbl) {\n?>\n<form action="index.php?op=<?=$tbl;?>&op2=edit2&q=<?=$q;?>&col=folder&tbl=<?=$tbl;?>" method="post">\n    <input type="hidden" name="id" value="<?=$rw[\'id\'];?>">\n    <input type="hidden" name="tbl" value="<?=$tbl;?>">\n    <div class="row">\n      <div class="col-6">        \n      </div>\n      <div class="col-6 text-end">\n        <?php if($rw[\'type\']==1) { ?>\n        <a href="tes_curl.php?id=<?=$id;?>&c=1" target="_blank" class="btn btn-sm btn-info">Tes cURL [1]</a>\n      <?php } ?>\n        <a class="btn btn-sm cl-dp5 mr-2" href="?op=<?=$tbl;?>&op2=copy&id=<?=$rw[\'id\'];?>">Copy This</a>\n        <button type="submit" name="submit" class="btn btn-sm btn-primary">Save</button>        \n      </div>\n    </div>\n\n    <div class="row">\n      <div class="col-3">\n        <label for="folder" class="label">folder</label>\n        <input type="text" class="form-control" name="folder" value="<?=$rw[\'folder\'];?>">\n        <label for="slug" class="label">slug</label>\n        <input type="text" class="form-control" name="slug" value="<?=$rw[\'slug\'];?>">          \n        <label for="type" class="label">type</label>\n        <input type="text" class="form-control" name="type" value="<?=$rw[\'type\'];?>">          \n        <label for="method" class="label">method</label>\n        <input type="text" class="form-control" name="method" value="<?=$rw[\'method\'];?>">                \n        <label for="param" class="label">param</label>\n        <textarea rows="4" id="param" class="form-control" name="param"><?=ugpc($rw[\'param\']);?></textarea>          \n        <label for="body" class="label">body</label>\n        <textarea rows="4" id="body" class="form-control" name="body"><?=ugpc($rw[\'body\']);?></textarea>\n        <label for="remark" class="label">remark</label>\n        <textarea rows="4" id="body" class="form-control" name="remark"><?=ugpc($rw[\'remark\']);?></textarea>\n      </div>\n      <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>\n      </div>\n    </div>\n  </form>\n<?php\n}','php','0','2','4','1790685968');
INSERT INTO `cp_sphp` VALUES('183','filephp','right_menu','','function right_menu($q,$col,$tbl){\nglobal $ar,$db;\n  if($col==\'folder\') {\n    $sql1 = "select `folder`,id,slug from `".$tbl."` where del=0 and folder=\'".$q."\' order  by `folder`,slug";\n  } else {\n    $sql1 = "select `folder`,id,slug from `".$tbl."` where del=0 order  by `folder`,slug";\n  }\n  $res1 = mysqli_query($db, $sql1);\n  while($r1 = mysqli_fetch_assoc($res1)) {\n    //$dt[$c][\'folder\']=$r1[\'folder\'];\n    if(isset($_GET[\'id\']) && $_GET[\'id\']==$r1[\'id\']) {\n      $sl=\'<b>\'.substr($r1[\'folder\'],9)."".$r1[\'slug\'].\'</b>\';\n    } else {\n      $sl=substr($r1[\'folder\'],9)."".$r1[\'slug\'];\n    }\n    ?>\n    <a href="?op=<?=$tbl;?>&op2=edit&id=<?=$r1[\'id\'];?>&col=folder&q=<?=$r1[\'folder\'];?>&tbl=<?=$tbl;?>"><?=$sl;?></a><br>\n    <?php\n  }\n}','php','0','2','4','1790670189');
INSERT INTO `cp_sphp` VALUES('184','filephp','edit2','','function edit2($POST) {\n  global $ar,$db;\n  $udt=array(\n    \'slug\'=>$POST[\'slug\'],\n    \'type\'=>$POST[\'type\'],\n    \'param\'=>trim($POST[\'param\']),\n    \'method\'=>trim($POST[\'method\']),\n    \'folder\'=>$POST[\'folder\'],\n    \'remark\'=>trim($POST[\'remark\']),\n    \'php\'=>gpc(trim($POST[\'php\'])),\n    \'body\'=>gpc(trim($POST[\'body\'])),\n    \'update_at\'=>time(),\n  );\n  Update($db,$_POST[\'tbl\'],$udt,"id=".$POST[\'id\'],0);\n}','php','0','2','4','1790669978');
INSERT INTO `cp_sphp` VALUES('185','filephp','fp_copy','','function fp_copy($id2,$r3,$tbl) {\n  global $ar,$db;\n  $idt=array(\n    \'id\'=>$id2,\n    \'slug\'=>$r3[\'slug\']."_",\n    \'folder\'=>trim($r3[\'folder\']),\n    \'param\'=>trim($r3[\'param\']),\n    \'method\'=>trim($r3[\'method\']),\n    \'php\'=>gpc(trim($r3[\'php\'])),\n    \'update_at\'=>time(),\n    \'body\'=>gpc(trim($r3[\'body\'])),\n  );\n  Insert($db,$tbl,$idt,0);\n}','php','0','2','4','1790686101');
INSERT INTO `cp_sphp` VALUES('186','olahxls','olahxls_xkruki_master','','function olahxls_xkruki_master($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          if($r[6]!=\'\' && (is_numeric($r[0]))) {\n            $dt[$k] = [\n              \'urut\' => $r[0],\n              \'lantai\' => $r[1],\n              \'kamar\' => $r[2],\n              \'kapasitas\' => $r[3],\n              \'type\' => $r[4],\n              \'status\' => $r[5],\n              \'kloter\' => $r[6],\n              \'rumah\'=>$xlsx->getCell(0,\'C2\'),\n              \'gedung\'=>$xlsx->getCell(0,\'C3\'),\n              \'filename\' => $_FILES[\'xlsfile\'][\'name\'],\n            ];           \n          }\n        }\n      }\n    }            \n    //echo "<pre>"; print_r($xlsx); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n    //echo "<pre>"; print_r($dt[1]); echo "</pre>";\n    \n    foreach ($dt as $k => $v) {\n      if(strlen($v[\'rumah\'])>3) {\n        $sek=substr($v[\'rumah\'],0,2);\n      } else {\n        $sek=substr($v[\'rumah\'],0,1);\n      }\n      $idt=array(\n        \'daker\'=>$_POST[\'daker\'],\n        \'gel\'=>$_POST[\'gel\'],\n        \'rumah\'=>$v[\'rumah\'],\n        \'sektor\'=>$sek,\n        \'gedung\'=>$v[\'gedung\'],\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      $udt=array(\n        \'gel\'=>$_POST[\'gel\'],\n        \'sektor\'=>$sek,\n        \'urut\'=>$v[\'urut\'],\n        \'lantai\'=>$v[\'lantai\'],\n        \'kamar\'=>$v[\'kamar\'],\n        \'kapasitas\'=>$v[\'kapasitas\'],\n        \'type\'=>$v[\'type\'],\n        \'status\'=>$v[\'status\'],\n        \'kloter\'=>$v[\'kloter\'],\n        \'filename\'=>$v[\'filename\'],\n        \'update_at\'=>time(),\n      );\n      InsertUpdate($db,"tmp_kruki",$idt,$udt,1);\n    }\n    /* */\n  } else {\n    echo "tak ada data xls<br>";    \n  }\n}','php','0','2','2','1787184444');
INSERT INTO `cp_sphp` VALUES('196','api','ucol','','function ucol($js){\n  global $ar,$db;\n  $dt=array();\n  //$dt[\'param\']=$js;\n\n  $sql="SELECT * from `".$js[\'tbl\']."` where `id`=\'".$js[\'id\']."\'";\n  //$dt[\'sql\'][1]=$sql8;\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)==1){\n    $r=mysqli_fetch_assoc($res);\n\n    $udt=array(\n      $js[\'col\']=>$js[\'val\'],\n    );\n    Update($db,$js[\'tbl\'],$udt,"`".$js[\'wc\']."`=".$js[\'id\'],0);\n    $dt[\'success\']=true;\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'message\']="Data not found";        \n  }\n  return $dt;\n}','php','0','2','10','1790684866');
INSERT INTO `cp_sphp` VALUES('200','olahxls','olahxls_stugas','','function olahxls_stugas($FILES) {\n  global $ar,$db;\n  require_once $ar[\'path_core\'].\'dom/simplexlsx.php\';\n  $dt=[];\n  if ($xlsx=SimpleXLSX::parse($FILES["xlsfile"]["tmp_name"])) {\n    foreach($xlsx->rows() as $k=>$r) {\n      if ($k>0){\n        if($r[0]!=\'\') {\n          $ex=explode(" ",strtolower(repl_space($r[4])));\n          $tg1="2026-".$ar[\'bulan\'][$ex[1]]."-".str_pad($ex[0], 2, "0", STR_PAD_LEFT);\n          $tg2="2026-".$ar[\'bulan\'][$ex[4]]."-".str_pad($ex[3], 2, "0", STR_PAD_LEFT);\n          $dt[$k] = [\n            \'id\' => $r[0],\n            \'nama\' => repl_space($r[1]),\n            \'tugas\' => repl_space($r[2]),\n            \'tempat\' => repl_space($r[3]),\n            \'tgl_mulai\' => $tg1,\n            \'tgl_selesai\' => $tg2,\n          ];           \n        }\n      }\n    }\n    //echo "<pre>"; print_r($csv); echo "</pre>";\n    echo \'<textarea class="form-control" rows="10">\'.json_encode($dt).\'></textarea>\';\n    echo "rows: ".count($dt)."<br>";\n\n    foreach ($dt as $k => $v) {\n      $idt=array(\n        \'id\'=>$v[\'id\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'tugas\'=>gpc($v[\'tugas\']),\n        \'tempat\'=>$v[\'tempat\'],\n        \'tgl_mulai\'=>$v[\'tgl_mulai\'],\n        \'tgl_selesai\'=>$v[\'tgl_selesai\'],\n      );\n      $udt=array(\n        //\'tugas\'=>gpc($v[\'tugas\']),\n        //\'tempat\'=>$v[\'tempat\'],\n        \'nama\'=>gpc($v[\'nama\']),\n        \'tgl_mulai\'=>$v[\'tgl_mulai\'],\n        \'tgl_selesai\'=>$v[\'tgl_selesai\'],\n      );\n      InsertUpdate($db,"ptg7_stugas",$idt,$udt,1);\n    }\n    /* */\n  } else {\n    echo "tak ada data xls<br>";\n  }\n}','php','0','2','2','1788747043');
INSERT INTO `cp_sphp` VALUES('201','xhr','xhr_5post','','function xhr_5post($url,$data){\n  global $ar,$db;\n  $dt=[];\n  $headers = [\n    \'Content-Type: application/json\',\n    \'accept-encoding: gzip\',\n    \'host: api-petugas.haji.go.id\',\n    \'origin: https://petugas.haji.go.id\',\n    \'referee: https://petugas.haji.go.id\',\n    \'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW0iOiJhcHBfcGV0dWdhcyIsInN1YiI6IjNlMjVmMDc2LTNlYzgtNGMyOS04Njg0LTkzMGYzNTBmMzdiNiIsImlzcyI6IjJZdHhQVW8xY0FRRjNydkZLdm5kYklNWlV1RXpRU1dvIiwiZXhwIjoxNzg3NjU5NDAzLCJyb2wiOnt9fQ.9fHvoqzyqdqcSgC4v-nG59A1do86h5bPPrs42jtUhrw\',\n    \'x-access-key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imh1d3J1bm1hcnlhbSIsInJvbGVfaWQiOjMsIm5vX3BlbmRhZnRhcmFuIjpudWxsLCJqZW5pc190dWdhc19sYXRlc3QiOiJBS09NIiwiamFiYXRhbl90dWdhcyI6bnVsbCwiZnVsbG5hbWUiOiJNQVJZQU0gSFVXUlVOSVlOIiwiZW1haWwiOiJodXdydW5tYXJ5YW1AZ21haWwuY29tIiwia2Fud2lsX3Byb3ZpbnNpIjoiMDkwMCIsImthbndpbF9rb3RhIjoiMDkwMSIsIm5hbWFfa2Fud2lsIjoiS0FOVE9SIFBVU0FUIiwidGFodW5faGFqaV9uYW1lIjoiMTQ0OCBILzIwMjcgTSIsImlhdCI6MTc4NzY0MTQwMywiZXhwIjoxODEwOTY5NDAzfQ.zbBcTSKUWmDY9t7KLQHr-Zri641PKDyuz5ZgWsoCiKI\',\n    \'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36\',\n    \'sec-fetch-dest: empty\',\n    \'sec-fetch-mode: cors\',\n    \'sec-fetch-site: same-site\',\n    \'Accept: application/json\'\n  ];  \n  $ch = curl_init($url);\n  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n  curl_setopt($ch, CURLOPT_POST, true);\n  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);\n  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n  $response = curl_exec($ch);\n  curl_close($ch);\n  if($response) {\n    return $response;\n  }\n}','php','0','2','11','1788823906');
INSERT INTO `cp_sphp` VALUES('202','xhr','xhr_4post','','function xhr_4post($url,$data){\n  global $ar,$db;\n  $dt=[];\n  $headers = [\n    \'Content-Type: application/json\',\n    \'accept-encoding: gzip\',\n    \'host: api-petugas.haji.go.id\',\n    \'origin: https://petugas.haji.go.id\',\n    \'referee: https://petugas.haji.go.id\',\n    \'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW0iOiJhcHBfcGV0dWdhcyIsInN1YiI6IjNlMjVmMDc2LTNlYzgtNGMyOS04Njg0LTkzMGYzNTBmMzdiNiIsImlzcyI6IjJZdHhQVW8xY0FRRjNydkZLdm5kYklNWlV1RXpRU1dvIiwiZXhwIjoxNzg3NjU5NDAzLCJyb2wiOnt9fQ.9fHvoqzyqdqcSgC4v-nG59A1do86h5bPPrs42jtUhrw\',\n    \'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36\',\n    \'sec-fetch-dest: empty\',\n    \'sec-fetch-mode: cors\',\n    \'sec-fetch-site: same-site\',\n    \'Accept: application/json\'\n  ];  \n  $ch = curl_init($url);\n  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n  curl_setopt($ch, CURLOPT_POST, true);\n  curl_setopt($ch, CURLOPT_POSTFIELDS, $data); \n  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n  $response = curl_exec($ch);\n  if (curl_errno($ch)) {\n    $dt[\'message\']=curl_error($ch);\n  } else {\n    $dt[\'success\']=true;  \n    $dt[\'response\']=$response;\n  }\n  curl_close($ch);\n  return $dt;\n}','php','0','2','11','1788822550');
INSERT INTO `cp_sphp` VALUES('203','api.v2','password_change','','function password_change($js){\n  global $ar,$db;\n  $dt=array();\n  $dt[\'param\']=$js;\n\n  //cek pass lama valid\n  $sql9="SELECT * from `petugas` where password=\'".md5($js[\'password\'])."\' and id=".$js[\'uid\'];\n  //$dt[\'sql\'][0]=$sql9;\n  $res9=mysqli_query($db,$sql9);\n  if(mysqli_num_rows($res9)==1) {\n    $r9=mysqli_fetch_assoc($res9);\n    $sql8="UPDATE `petugas` set `password`=\'".md5($js[\'newpassword\'])."\',update_at=".time()." where `id`=\'".$js[\'uid\']."\'";\n    //$dt[\'sql\'][1]=$sql8;\n    $res8=mysqli_query($db,$sql8);\n    $dt[\'success\']=true;\n    $dt[\'message\']="Password sukses diperbarui";    \n\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'massage\']=\'Password lama tidak cocok\';\n  }\n  return $dt;\n}','php','0','2','12','1788916293');
INSERT INTO `cp_sphp` VALUES('204','api.v2','password_forgot','','function password_forgot($js){\n  global $ar,$db;\n  $dt=array();\n  $dt[\'param\']=$js;\n  \n  $email2 =$js[\'email\'];  \n  $em=explode(\'@\',$email2);\n  $m1 = preg_replace("/[^A-Za-z0-9]/","",$em[0]);\n  \n  if($m1!=\'\' && $em[1]!=\'\') {\n    $email=$m1."@".$em[1];\n    //cek email dobel\n    $sql9="SELECT * from `petugas` where st=1 and email=\'".$email."\'";\n    //$dt[\'sql\'][0]=$sql9;\n    \n    $res9=mysqli_query($db,$sql9);\n    if(mysqli_num_rows($res9)==0) {\n      $dt[\'status\']=false;\n      $dt[\'message\']="Email \'".$email."\' tidak terdaftar";    \n      //$dt[\'info\'][0]="Email \'".$email."\' belum terdaftar";    \n    } else {\n      //$dt[\'message\']="Email \'".$email."\' belum terdaftar";    \n      //cek username\n      if(mysqli_num_rows($res9)==1) {\n\n        //$dt[\'info\'][1]="Email \'".$email."\' terdaftar"; \n        $npass=genCode(8);   \n        $r9=mysqli_fetch_assoc($res9);\n\n        $sql8="UPDATE `petugas` set password=\'".$npass."\' where `email`=\'".$email."\'";\n        //$dt[\'sql\'][1]=$sql8;\n        $res8=mysqli_query($db,$sql8);\n\n        include $ar[\'core_path\']."slatihan/api/v2/inc.mail.php";\n\n        $subject="New password to login ".$ar[\'sitename\'].": ".$npass;\n        $content= "<p>Welcome to ".$ar[\'sitename\']."</p>";\n        $content.= "<p>your password to login is: ".$npass."</p>";\n        $content.= "<p><br><br></p>";\n        $content.= "<p>Best Regards,<br>".$ar[\'sitename\']." Team</p>";\n        //$dt[\'m\'][\'to\']=$name;\n        //$dt[\'m\'][\'email\']=$email;\n        //$dt[\'m\'][\'sub\']=$subject;\n        $cek_mail=sendMail($email,$r9[\'fullname\'],$subject,$content);\n        $dt[\'mail_success\']=$cek_mail;\n        $dt[\'status\']=true;\n        $dt[\'message\']="Password sukses diperbarui silakan cek \'".$email."\'";    \n        //$dt[\'data\']=$r8;\n        //$dt[\'data\'][\'uuid\']=$r8[\'id\'];\n      }\n    }\n  }\n  return $dt;\n}','php','0','2','12','1788916935');
INSERT INTO `cp_sphp` VALUES('205','api.v2','email_cek','','function email_cek($js){\n  global $ar,$db;\n  $dt[\'param\']=$js;\n  include "inc.mail.php";\n  $subject="Cek email ".$ar[\'sitename\'];\n  $content= "<p>Welcome to ".$ar[\'sitename\']."</p>";\n  $content.= "<p><br><br></p>";\n  $content.= "<p>Best Regards,<br>".$ar[\'sitename\']." Team</p>";\n  $cek_mail=sendMail($js[\'email\'],$js[\'name\'],$subject,$content);\n  $dt[\'mail_success\']=$cek_mail;\n  return $dt;\n}','php','0','2','12','1788852544');
INSERT INTO `cp_sphp` VALUES('206','api.v2','account_edit','','function account_edit($js){\n  global $ar,$db;\n  $dt=array();\n  $dt[\'param\']=$js;\n\n  $sql="SELECT id,firstname,lastname,fullname,email,uid,no_telp from `member` where `id`=\'".$js[\'id\']."\'";\n  //$dt[\'sql\'][1]=$sql8;\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res)==1){\n    $r=mysqli_fetch_assoc($res);\n    $udt=array(\n      \'gelar\'=>$js[\'gelar\'],\n      \'no_telp\'=>$js[\'no_telp\'],\n      \'address\'=>$js[\'address\'],\n      \'rt\'=>$js[\'rt\'],\n      \'rw\'=>$js[\'rw\'],\n      \'no\'=>$js[\'no\'],\n      \'postcode\'=>$js[\'postcode\'],\n      \'city\'=>$js[\'city\'],\n      \'kel\'=>$js[\'kel\'],\n      \'kec\'=>$js[\'kec\'],\n      \'gmap\'=>$js[\'gmap\'],\n      \'remark\'=>$js[\'remark\'],\n      \'update_at\'=>time(),\n    );\n    Update($db,"user_address",$udt,"id=".$js[\'aid\'],0);\n    $dt[\'success\']=true;\n    $dt[\'message\']="Update address for ".$r[\'fullname\']." successfull";   \n    $dt[\'data\']=$r;\n  } else {\n    $dt[\'error\']=true;\n    $dt[\'message\']="Account not found";        \n  }\n  return $dt;\n}','php','0','2','12','1788852659');
INSERT INTO `cp_sphp` VALUES('207','api.v2','image_upload','','function image_upload($js){\n  global $ar,$db;\n  $dt=array();\n  //$dt[\'param\']=$js;\n  $p[\'id\']=$js[\'id\'];\n  $p[\'title\']="";\n  $p[\'caption\']="";\n  //$dt[\'p\']=$p;\n\n  UploadImageData($p,$js[\'img_data\'],$js[\'tbl\']);\n  $sql="SELECT * from `files` where modul=\'".$js[\'tbl\']."\' and item_id=".$js[\'id\']." order by id desc";\n  $res=mysqli_query($db,$sql);\n  $c=0;\n  while($r1=mysqli_fetch_assoc($res)) {\n    $dt[\'data\'][$c][\'id\']=$r1[\'id\'];\n    $dt[\'data\'][$c][\'url\'][\'small\']=$ar[\'img_url\']."".$r1[\'modul\']."/".$r1[\'path\']."/".$r1[\'seq\']."/image/small/".$r1[\'url\'];\n    $dt[\'data\'][$c][\'url\'][\'medium\']=$ar[\'img_url\']."".$r1[\'modul\']."/".$r1[\'path\']."/".$r1[\'seq\']."/image/medium/".$r1[\'url\'];\n    $dt[\'data\'][$c][\'url\'][\'big\']=$ar[\'img_url\']."".$r1[\'modul\']."/".$r1[\'path\']."/".$r1[\'seq\']."/image/big/".$r1[\'url\'];\n    $c++;\n  }\n  $dt[\'count\']=$c;  \n  $dt[\'success\']=true;\n  return $dt;\n}','php','0','2','12','1788852769');
INSERT INTO `cp_sphp` VALUES('208','api.v2','kloter_bysektor','','function kloter_bysektor($js){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT `code` from `myhotel` where sektor=\'".$js."\' group by code";\n  $res2=mysqli_query($db,$sql2);\n  $jr2=mysqli_num_rows($res2);\n  $dt[\'sql\']=$sql2;\n\n  //$sql=$sql2." group by code";\n  //echo $sql.";<br>";\n  //$res=mysqli_query($db,$sql);\n  if($jr2>0) {\n    $dt[\'count\']=$jr2;\n    $dt[\'success\']=true;\n    $c=0;\n    while($r2=mysqli_fetch_assoc($res2)) {\n      $sql3="SELECT emb,klt,gel,code,total from mykloter where code=\'".$r2[\'code\']."\'";\n      $res3=mysqli_query($db,$sql3);\n      $r3=mysqli_fetch_assoc($res3);\n      $dt[\'data\'][$c]=$r3;    \n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'error\']=true;\n    $dt[\'message\']="data action not found";\n  }\n  return $dt;\n}','php','0','2','12','1788852998');
INSERT INTO `cp_sphp` VALUES('209','api.v2','kloter_bygel','','function kloter_bygel($p4){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT emb,klt,`code`,gel from `berangkat` where gel=".$p4;\n  $res2=mysqli_query($db,$sql2);\n  $dt[\'count\']=mysqli_num_rows($res2);\n  $dt[\'success\']=true;\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res2)) {\n      $dt[\'data\'][$c]=$r1;    \n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'error\']=true;\n    $dt[\'message\']="data not found";\n  }\n  return $dt;\n}','php','0','2','12','1788853303');
INSERT INTO `cp_sphp` VALUES('210','api.v2','kloter_all','','function kloter_all(){\n  global $ar,$db;\n  $dt=array();\n  $sql2="SELECT `gel`,emb,klt,`code` from `berangkat`";\n  $res2=mysqli_query($db,$sql2);\n  $r2=mysqli_num_rows($res2);\n  $dt[\'count\']=$r2;\n  $dt[\'success\']=true;\n\n  $sql=$sql2." order by `id`";\n  //echo $sql.";<br>";\n  $res=mysqli_query($db,$sql);\n  if(mysqli_num_rows($res2)>0) {\n    $c=0;\n    while($r1=mysqli_fetch_assoc($res)) {\n      $dt[\'data\'][$c]=$r1;    \n      if($r1[\'gel\']==1) {\n        $dt[\'data\'][$c][\'g\']=\'I\';    \n      } else {\n        $dt[\'data\'][$c][\'g\']=\'II\';    \n      }\n      $c++;\n    }\n  } else {\n    $dt[\'count\']=0;\n    $dt[\'error\']=true;\n    $dt[\'message\']="data action not found";\n  }\n  return $dt;\n}','php','0','2','12','1788853161');
INSERT INTO `cp_sphp` VALUES('211','api.v2','signin','','function signin($js){\n  global $ar,$db;\n  $dt=array();\n  //$dt[\'js\']=$js;\n  $email2 =$js[\'email\'];  \n  $em=explode(\'@\',$email2);\n  $m1 = preg_replace("/[^A-Za-z0-9]/","",$em[0]);\n  \n  if($m1!=\'\' && $em[1]!=\'\') {\n    $email=$m1."@".$em[1];\n    //cek email dobel\n    $sql9="SELECT id,nama from `petugas` where email=\'".$email."\'";\n    //$dt[\'sql\'][0]=$sql9;\n    \n    $res9=mysqli_query($db,$sql9);\n    if(mysqli_num_rows($res9)==0) {\n      $dt[\'error\']=true;\n      $dt[\'message\']="Email \'".$email."\' tidak terdaftar";    \n      //$dt[\'info\'][0]="Email \'".$email."\' belum terdaftar";    \n    } else {\n      //$dt[\'message\']="Email \'".$email."\' belum terdaftar";    \n      //cek username\n      if(mysqli_num_rows($res9)==1) {\n\n        //$dt[\'info\'][1]="Email \'".$email."\' terdaftar";    \n\n        $sql8="SELECT id,petugas,daftar,daker,sektor,tusi,email,img,tahun,tahun_haji from `petugas` where `email`=\'".$email."\' and `password`=\'".md5($js[\'password\'])."\' and `st`=1";\n        //$dt[\'sql\'][1]=$sql8;\n        $res8=mysqli_query($db,$sql8);\n        if(mysqli_num_rows($res8)==0) {\n          $dt[\'message\']="Email \'".$email."\' benar, password salah";    \n          //$dt[\'info\'][2]="Email \'".$email."\' terdaftar, password salah";    \n          $dt[\'error\']=true;\n        } else {\n          $r8=mysqli_fetch_assoc($res8);\n          $dt[\'success\']=true;\n          $dt[\'member\'][\'data\']=$r8;\n          $dt[\'member\'][\'data\'][\'image\']=$ar[\'img_url\']."".$r8[\'img\'];\n          \n          $sql9="SELECT * from `files` where modul=\'petugas\' and item_id=".$r8[\'id\']." order by id desc";\n          $res9=mysqli_query($db,$sql9);\n          if(mysqli_num_rows($res9)>0) {\n            $c=0;\n            while($r9=mysqli_fetch_assoc($res9)) {\n              //$dt[\'img\'][\'data\'][$c][\'id\']=$r9[\'id\'];\n              $dt[\'img\'][\'data\'][$c][\'url\'][\'small\']=$ar[\'img_url\']."".$r9[\'modul\']."/".$r9[\'path\']."/".$r9[\'seq\']."/image/small/".$r9[\'url\'];\n              $dt[\'img\'][\'data\'][$c][\'url\'][\'medium\']=$ar[\'img_url\']."".$r9[\'modul\']."/".$r9[\'path\']."/".$r9[\'seq\']."/image/medium/".$r9[\'url\'];\n              $dt[\'img\'][\'data\'][$c][\'url\'][\'big\']=$ar[\'img_url\']."".$r9[\'modul\']."/".$r9[\'path\']."/".$r9[\'seq\']."/image/big/".$r9[\'url\'];\n              $c++;\n            }\n          } else {\n              $dt[\'img\'][\'data\'][0][\'url\'][\'small\']=$ar[\'img_url\']."member/user.png";\n              $dt[\'img\'][\'data\'][0][\'url\'][\'medium\']=$ar[\'img_url\']."member/user.png";\n              $dt[\'img\'][\'data\'][0][\'url\'][\'big\']=$ar[\'img_url\']."member/user.png";\n          }\n          $dt[\'img\'][\'count\']=$c;  \n          $jj[\'uuid\']=$r8[\'id\'];\n        }\n      }\n    }\n  }\n  return $dt;\n}','php','0','2','12','1788913844');
INSERT INTO `cp_sphp` VALUES('213','t6_css','t6_cssf_edit','','function t6_cssf_edit($id,$q,$col) {\n   global $db,$ar;    \n  $sql = "select * from `t6_cssf` where id=".$id;\n  $res = mysqli_query($db, $sql);\n  //echo $sql;\n  $rw = mysqli_fetch_assoc($res);\n  $php_file=$ar[\'path_core\'].\'\'.$rw[\'folder\'].\'\'.$rw[\'slug\'].\'.css\';\n  if (file_exists($php_file)) {\n    $filecontent=file_get_contents($php_file);\n  } else {\n    $filecontent="";      \n  } \n\n?>\n<div class="row">\n  <div class="col-7">\n  <?=t6_css_form_edit($rw,$filecontent,$q,$col);?>\n  </div>\n  <div class="col-5">\n    <div class="card">\n      <div class="card-body">\n        <?=$ar[\'path_core\'];?>\n        <h5 class="card-title"><?=$rw[\'folder\'];?><?=$rw[\'slug\'];?>.css</h5>\n        <form method="post" action="index.php?op=t6_css&op2=php_save&q=<?=$q;?>&col=folder">\n          <input type="hidden" name="file_name" value="<?=$php_file;?>">\n          <input type="hidden" name="id" value="<?=$id;?>">\n          <textarea class="form-control" rows="20" name="content"><?=htmlspecialchars($filecontent);?></textarea>\n          <input type="submit" name="submit" class="btn btn-sm btn-success mt-2">\n        </form>\n      </div>\n    </div>\n  </div>\n</div>\n  <?php\n  //echo "<pre>"; print_r($rw); echo "</pre>";\n}','php','0','2','13','1789181440');
INSERT INTO `cp_sphp` VALUES('214','t6_css','t6_cssf_list','','function t6_cssf_list($q,$col,$q2,$col2,$q3,$col3) {\n  global $db,$ar;\n  ?>  \n  <table class="table table-bordered" id="dataTable_3d" width="100%" cellspacing="0">\n      <thead>\n          <tr>\n              <th>ID</th>\n              <th>Folder</th>\n              <th>Slug</th>\n              <th>uAt</th>\n              <th>Menu</th>\n          </tr>\n      </thead>\n\n      <tbody>\n      <?php\n      $sql = "select * from t6_cssf where id>0 ";\n\n      if($col!=\'\') {\n        $sql .= " and ".$col."=\'".$q."\' ";\n      }\n      \n      if($col2!=\'\') {\n        $sql .= " and ".$col2."=\'".$q2."\' ";\n      }\n\n      if($col3!=\'\') {\n        $sql .= " and ".$col3."=\'".$q3."\' ";\n      }      \n      \n      //$sql .= " and st=1";\n      $res = mysqli_query($db, $sql);\n      //echo $sql;\n\n      while($rw = mysqli_fetch_assoc($res)) {  \n      ?>\n      \n          <tr>\n              <td><?=$rw[\'id\'];?></td>\n              <td contenteditable="true" onBlur="colUpdate(this,\'folder\',<?=$rw[\'id\'];?>,\'t6_cssf\')" onClick="editRow(this);"><?=$rw[\'folder\'];?></td>\n              <td><?=$rw[\'slug\'];?></td>\n              <td class="text-right"><?=date("Y-m-d H:i",$rw[\'update_at\']);?></td>\n              <td>\n              \n                <a class="btn btn-xs btn-primary" href="?op=t6_css&op2=edit&id=<?=$rw[\'id\'];?>&col=folder&q=<?=$rw[\'folder\'];?>">edit</a>\n                <a class="btn btn-xs btn-danger" href="?op=t6_css&op2=del&id=<?=$rw[\'id\'];?>">delete</a>  \n                <a href="#" onClick="uCol(<?=$rw[\'id\'];?>,\'del\',1,\'t6_cssf\');" class="btn btn-xs btn-warning">del</a>\n              </td>\n          </tr>\n        <?php\n        }\n        ?>  \n          \n      </tbody>\n  </table>\n  <br><?=$sql;?><br>\n  <?php   \n}','php','0','2','13','1789181271');
INSERT INTO `cp_sphp` VALUES('215','t6_css','t6_cssf_edit2','','function t6_cssf_edit2($POST) {\n  global $ar,$db;\n  $udt=array(\n    \'slug\'=>$POST[\'slug\'],\n    \'folder\'=>$POST[\'folder\'],\n    \'body\'=>gpc(trim($POST[\'body\'])),\n    \'update_at\'=>time(),\n  );\n  Update($db,"t6_cssf",$udt,"id=".$POST[\'id\'],0);\n}','php','0','2','13','1789179747');
INSERT INTO `cp_sphp` VALUES('216','t6_css','t6_css_form_edit','','function t6_css_form_edit($rw,$filecontent,$q,$col) {\n?>\n<form action="index.php?op=t6_css&op2=edit2&q=<?=$q;?>&col=folder" method="post">\n    <input type="hidden" name="id" value="<?=$rw[\'id\'];?>">\n    <div class="row">\n      <div class="col-6">        \n      </div>\n      <div class="col-6 text-end">\n        <?php if($rw[\'type\']==1) { ?>\n        <a href="tes_curl.php?id=<?=$id;?>&c=1" target="_blank" class="btn btn-sm btn-info">Tes cURL [1]</a>\n      <?php } ?>\n        <a class="btn btn-sm cl-dp5 mr-2" href="?op=t6_css&op2=copy&id=<?=$rw[\'id\'];?>">Copy This</a>\n        <button type="submit" name="submit" class="btn btn-sm btn-primary">Save</button>\n        \n      </div>\n    </div>\n\n    <div class="row">\n      <div class="col-3">\n        <label for="folder" class="label">folder</label>\n        <input type="text" class="form-control" name="folder" value="<?=$rw[\'folder\'];?>">\n        <label for="slug" class="label">slug</label>\n        <input type="text" class="form-control" name="slug" value="<?=$rw[\'slug\'];?>">          \n        <label for="type" class="label">type</label>\n        <input type="text" class="form-control" name="type" value="<?=$rw[\'type\'];?>">          \n        <label for="method" class="label">method</label>\n        <input type="text" class="form-control" name="method" value="<?=$rw[\'method\'];?>">                \n        <label for="param" class="label">param</label>\n        <textarea rows="4" id="param" class="form-control" name="param"><?=ugpc($rw[\'param\']);?></textarea>          \n        <label for="body" class="label">body</label>\n        <textarea rows="4" id="body" class="form-control" name="body"><?=ugpc($rw[\'body\']);?></textarea>\n        <label for="remark" class="label">remark</label>\n        <textarea rows="4" id="body" class="form-control" name="remark"><?=ugpc($rw[\'remark\']);?></textarea>\n      </div>\n      <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>\n      </div>\n    </div>\n  </form>\n<?php\n}','php','0','2','13','1789180585');
INSERT INTO `cp_sphp` VALUES('221','common.function','paginate','','function paginate($item_per_page, $current_page, $total_records, $total_pages, $page_url){\n  /*\n  use bootstrap 4/5\n  */\n    $pagination = \'\';\n    if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages){ //verify total pages and current page number\n        $pagination .= \'<ul class="pagination justify-content-center">\';\n        \n        $right_links    = $current_page + 3; \n        $previous       = $current_page - 3; //previous link \n        $next           = $current_page + 1; //next link\n        $first_link     = true; //boolean var to decide our first link\n        \n        if($current_page > 1){\n      $previous_link = ($previous==0)?1:$previous;\n            $pagination .= \'<li class="first"><a class="page-link" href="?\'.$page_url.\'&page=1" title="First">«</a></li>\'; //first link\n            $pagination .= \'<li><a class="page-link" href="?\'.$page_url.\'&page=\'.$previous_link.\'" title="Previous"><</a></li>\'; //previous link\n                for($i = ($current_page-2); $i < $current_page; $i++){ //Create left-hand side links\n                    if($i > 0){\n                        $pagination .= \'<li><a class="page-link" href="?\'.$page_url.\'&page=\'.$i.\'">\'.$i.\'</a></li>\';\n                    }\n                }   \n            $first_link = false; //set first link to false\n        }\n        \n        if($first_link){ //if current active page is first link\n            $pagination .= \'<li class="first active"><a class="page-link">\'.$current_page.\'</a></li>\';\n        }elseif($current_page == $total_pages){ //if it\'s the last active link\n            $pagination .= \'<li class="last active"><a class="page-link">\'.$current_page.\'</a></li>\';\n        }else{ //regular current link\n            $pagination .= \'<li class="page-item active" aria-current="page"><a class="page-link">\'.$current_page.\'</a></li>\';\n        }\n                \n        for($i = $current_page+1; $i < $right_links ; $i++){ //create right-hand side links\n            if($i<=$total_pages){\n                $pagination .= \'<li class="page-item"><a class="page-link" href="?\'.$page_url.\'&page=\'.$i.\'">\'.$i.\'</a></li>\';\n            }\n        }\n        if($current_page < $total_pages){ \n        $next_link = ($i > $total_pages)? $total_pages : $i;\n                $pagination .= \'<li><a class="page-link" href="?\'.$page_url.\'&page=\'.$next_link.\'" >></a></li>\'; //next link\n                $pagination .= \'<li class="last"><a class="page-link" href="?\'.$page_url.\'&page=\'.$total_pages.\'" title="Last">»</a></li>\'; //last link\n        }\n        \n        $pagination .= \'</ul>\'; \n    }\n    return $pagination; //return pagination links\n}','php','0','2','1','1789347947');
INSERT INTO `cp_sphp` VALUES('225','common.function','isValidPdf','','function isValidPdf($filePath) {\n    // 1. Check if file exists\n    if (!file_exists($filePath)) {\n        return false;\n    }\n\n    // 2. Check MIME type (Requires Fileinfo extension, enabled by default in PHP)\n    $finfo = new finfo(FILEINFO_MIME_TYPE);\n    $mimeType = $finfo->file($filePath);\n    if ($mimeType !== \'application/pdf\') {\n        return false;\n    }\n\n    // 3. Check PDF Magic Number (%PDF-)\n    $handle = fopen($filePath, \'rb\');\n    if (!$handle) {\n        return false;\n    }\n    \n    $firstBytes = fread($handle, 5);\n    fclose($handle);\n\n    if ($firstBytes !== \'%PDF-\') {\n        return false;\n    }\n\n    return true;\n}','php','0','2','1','1789360650');
INSERT INTO `cp_sphp` VALUES('228','htm','htm_16','','function htm_16($p) {\n  global $ar,$db;\n  //include $ar[\'core_path\']."dom/simple_html_dom.php";\n  require_once $ar[\'path_core\'].\'dom/simple_html_dom.php\';\n  $dt=[];\n  $html = new simple_html_dom();\n  $html->load($p); \n  $a=0;\n  foreach($html->find(\'div[jsname="NwW5ce"]\') as $node) {\n   //echo trim($node->find(\'a\', 0)->href)."<br>";\n   $dt[$a][\'url\']=trim($node->find(\'a\', 0)->href);\n   $dt[$a][\'att\']=htmlspecialchars(trim($node->find(\'a\', 0)->innertext));\n   //echo trim($node->find(\'a\', 0)->getAttribute("area-label"))."<br>";\n   //echo trim($node->find(\'>div[class="RY3tic"]\', 0)->{\'data-latest-bg\'})."<br>";\n   //echo trim($node->find(\'div.RY3tic\', 0)->getAttribute(\'data-latest-bg\'))."<br>";\n   //echo trim($node->find(\'div[class="RY3tic"]\', 0)->getAttribute()->{\'data-latest-bg\'})."<br>";\n   $a++;\n  }\n  echo "<pre>"; print_r($dt); echo "</pre>";\n}','php','0','2','14','1789697070');
INSERT INTO `cp_sphp` VALUES('229','chart','chart_pie','','function chart_pie($did,$title,$dt) {\n$lab="[";\n$dat="[";\nforeach($dt as $k=>$v) {\n  $lab .="\'".$k."\',";\n  $dat .=$v.",";\n}\n$label=substr($lab,0,-1)."]";\n$data=substr($dat,0,-1)."]";\n?>\n<canvas id="<?=$did;?>"></canvas>\n<script>const c<?=$did;?>=document.getElementById("<?=$did;?>");new Chart(c<?=$did;?>,{type:"pie",options:{responsive:!0,plugins:{legend:{position:"top"},title:{display:!0,text:"<?=$title;?>"}}},data:{labels:<?=$label;?>,datasets:[{label:"# jumlah",data:<?=$data;?>,borderWidth:1}]}});</script>\n<?php\n}','php','0','2','15','1789858504');
INSERT INTO `cp_sphp` VALUES('230','chart','chart_bar','','function chart_bar($did,$title,$dt) {\n$lab="[";\n$dat="[";\nforeach($dt as $k=>$v) {\n  $lab .="\'".$k."\',";\n  $dat .=$v.",";\n}\n$label=substr($lab,0,-1)."]";\n$data=substr($dat,0,-1)."]";\n?>\n<canvas id="<?=$did;?>"></canvas>\n<script>const c<?=$did;?>=document.getElementById("<?=$did;?>");new Chart(c<?=$did;?>,{type:"bar",options:{responsive:!0,scales:{y:{beginAtZero:true}},plugins:{legend:{position:"top"},title:{display:!0,text:"<?=$title;?>"}}},data:{labels:<?=$label;?>,datasets:[{label:"# jumlah",data:<?=$data;?>,borderWidth:1}]}});</script>\n<?php\n}','php','0','2','15','1789858565');
INSERT INTO `cp_sphp` VALUES('231','chart','chart_pie_nolabel','','function chart_pie_nolabel($did,$title,$dt) {\n$lab="[";\n$dat="[";\nforeach($dt as $k=>$v) {\n$lab .="\'".$k."\',";\n$dat .=$v.",";\n}\n$label=substr($lab,0,-1)."]";\n$data=substr($dat,0,-1)."]";\n?>\n<canvas id="<?=$did;?>"></canvas>\n<script>const c<?=$did;?>=document.getElementById("<?=$did;?>");new Chart(c<?=$did;?>,{type:"pie",options:{responsive:!0,plugins:{title:{display:!0,text:"<?=$title;?>"}}},data:{labels:<?=$label;?>,datasets:[{label:"# jumlah",data:<?=$data;?>,borderWidth:3}]}});</script>\n<?php\n}','php','0','2','15','1789790276');


DROP TABLE IF EXISTS `network`;
CREATE TABLE `network` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(60) DEFAULT NULL,
  `initial` varchar(60) DEFAULT NULL,
  `email` varchar(90) DEFAULT NULL,
  `password` varchar(200) DEFAULT NULL,
  `modul` varchar(200) DEFAULT NULL,
  `modul2` varchar(200) DEFAULT NULL,
  `modul3` varchar(200) DEFAULT NULL,
  `reff` varchar(200) DEFAULT NULL,
  `address` varchar(200) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `wa` varchar(30) DEFAULT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `role` tinyint(4) DEFAULT NULL,
  `web` varchar(90) DEFAULT NULL,
  `fb` varchar(90) DEFAULT NULL,
  `ig` varchar(90) DEFAULT NULL,
  `linkedin` varchar(90) DEFAULT NULL,
  `tw` varchar(90) DEFAULT NULL,
  `nik` varchar(90) DEFAULT NULL,
  `img` varchar(90) DEFAULT NULL,
  `remark` varchar(200) DEFAULT NULL,
  `parent_id` int(11) NOT NULL,
  `create_at` int(11) NOT NULL,
  `update_at` int(11) NOT NULL DEFAULT 0,
  `update_by` int(11) NOT NULL DEFAULT 0,
  `last_login` int(11) NOT NULL,
  `st` tinyint(4) NOT NULL DEFAULT 1,
  `fav` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `wa` (`wa`),
  KEY `id_name_email` (`id`,`name`,`email`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;



DROP TABLE IF EXISTS `t1_php`;
CREATE TABLE `t1_php` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `modul` varchar(20) DEFAULT NULL,
  `slug` varchar(99) DEFAULT NULL,
  `name` varchar(99) DEFAULT NULL,
  `param` varchar(99) DEFAULT NULL,
  `method` varchar(99) NOT NULL DEFAULT 'POST',
  `folder` varchar(99) DEFAULT NULL,
  `php` text DEFAULT NULL,
  `body` text DEFAULT NULL,
  `remark` varchar(150) DEFAULT NULL,
  `st` tinyint(4) NOT NULL,
  `type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1=api,2=non api',
  `del` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1=delete',
  `update_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `folder_slug` (`folder`,`slug`),
  KEY `id_folder_slug` (`id`,`folder`,`slug`),
  KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

INSERT INTO `t1_php` VALUES('1','post','index','item','','GET','swift/','','','','0','1','0','1790686196');
INSERT INTO `t1_php` VALUES('2','','inc/inc.sphp','','','GET','swift/','','','','0','1','0','1790666970');
INSERT INTO `t1_php` VALUES('3','','inc.common.function','','','GET','swift/','','','','0','1','0','1790667083');
INSERT INTO `t1_php` VALUES('4','','inc/inc.t1_php','','','GET','swift/','','','','0','1','0','1790686046');
INSERT INTO `t1_php` VALUES('5','','inc.api.function','','','GET','swift/','','','','0','1','0','1790667126');
INSERT INTO `t1_php` VALUES('6','','inc.ar','','','GET','swift/','','','','0','1','0','1790667142');
INSERT INTO `t1_php` VALUES('7','','inc.ar.app','','','GET','swift/','','','','0','1','0','1790667163');
INSERT INTO `t1_php` VALUES('8','','api/v2/inc.mail','','','GET','swift/','','','','0','1','0','1790667025');
INSERT INTO `t1_php` VALUES('9','','inc/inc.network','','','GET','swift/','','','','0','1','0','1790667001');
INSERT INTO `t1_php` VALUES('10','','theme/sb2/header','','','GET','swift/','','','','0','1','0','1790666702');
INSERT INTO `t1_php` VALUES('11','','theme/sb2/footer','','','GET','swift/','','','','0','1','0','1790666670');
INSERT INTO `t1_php` VALUES('12','','inc/inc.filephp','','','GET','swift/','','','','0','1','0','1790666857');
INSERT INTO `t1_php` VALUES('13','','api/v2/index','','','GET','swift/','','','','0','1','0','1790666930');
INSERT INTO `t1_php` VALUES('14','','api/v2/php/ucol','','','GET','swift/','','','','0','1','0','1790666756');
INSERT INTO `t1_php` VALUES('15','','backup','','','GET','swift/','','','','0','1','0','1790671227');
INSERT INTO `t1_php` VALUES('16','','inc.common','','','GET','swift/','','','','0','1','0','1790666801');
INSERT INTO `t1_php` VALUES('17','','tes_curl','','','GET','swift/','','','','0','1','0','1790667259');
INSERT INTO `t1_php` VALUES('18','','ucol','','','GET','swift/','','','','0','1','0','1791527060');
INSERT INTO `t1_php` VALUES('19','','app.function','','','GET','swift/','','','','0','1','0','1790666824');
INSERT INTO `t1_php` VALUES('20','','inc/inc.t2_php','','','GET','swift/','','','','0','1','0','1790686306');


