0){ $result=str_replace(' ','#',$result); $pattern="/[^0-9a-zA-Z#-]/"; $result=preg_replace($pattern,'',$result); $result=str_replace('#','-',$result); $result=str_replace('--','-',$result); $result=str_replace('`','',$result); } return $result; } function get_extensi_file($file_tipe) { $file_tipe=strtoupper($file_tipe); $hasil=$file_tipe; if ($file_tipe=='IMAGE/JPG') $hasil="jpg"; elseif ($file_tipe=='IMAGE/JPEG') $hasil="jpeg"; elseif ($file_tipe=='IMAGE/BMP') $hasil='bmp'; elseif ($file_tipe=='IMAGE/GIF') $hasil='gif'; elseif ($file_tipe=='IMAGE/PNG') $hasil='png'; return($hasil); } function resize_gambar($filename, $nama_gambar_baru, $ukuran_baru, $path_hasil) { if(!file_exists($filename)){ throw new Exception('Unknown source file'); } $image_info = getimagesize($filename); $mime = $image_info['mime']; $is_png=false; switch ($mime) { case 'image/jpeg': $image_create_func = 'imagecreatefromjpeg'; $image_save_func = 'imagejpeg'; $new_image_ext = 'jpg'; break; case 'image/png': $image_create_func = 'imagecreatefrompng'; $image_save_func = 'imagepng'; $new_image_ext = 'png'; $is_png=true; break; case 'image/gif': $image_create_func = 'imagecreatefromgif'; $image_save_func = 'imagegif'; $new_image_ext = 'gif'; break; default: throw new Exception('Unknown image type.'); } $lebar_lama=$image_info[0]; $panjang_lama=$image_info[1]; if($lebar_lama>=$panjang_lama) $pembagi=$lebar_lama; else $pembagi=$panjang_lama; $lebar_baru=ceil(($lebar_lama * $ukuran_baru)/$pembagi); $panjang_baru=ceil(($panjang_lama * $ukuran_baru)/$pembagi); $img = $image_create_func($filename); $tmp = imagecreatetruecolor($lebar_baru, $panjang_baru); if($is_png) imagealphablending($tmp, false); imagecopyresampled($tmp,$img,0,0,0,0,$lebar_baru,$panjang_baru,$lebar_lama,$panjang_lama); if($is_png) imagesavealpha($tmp, true); $berhasil=$image_save_func($tmp, $path_hasil.$nama_gambar_baru); $h=file_exists($path_hasil.$nama_gambar_baru); if(!$h || !$berhasil){ throw new Exception('Can"t create image type. '.$path_hasil.$nama_gambar_baru); } return $h; } function resize_gambar2($originalFile,$targetFile, $newWidth) { $info = getimagesize($originalFile); $mime = $info['mime']; $is_png=false; switch ($mime) { case 'image/jpeg': $image_create_func = 'imagecreatefromjpeg'; $image_save_func = 'imagejpeg'; $new_image_ext = 'jpg'; break; case 'image/png': $image_create_func = 'imagecreatefrompng'; $image_save_func = 'imagepng'; $new_image_ext = 'png'; $is_png=true; break; case 'image/gif': $image_create_func = 'imagecreatefromgif'; $image_save_func = 'imagegif'; $new_image_ext = 'gif'; break; default: throw new Exception('Unknown image type.'); } $img = $image_create_func($originalFile); list($width, $height) = getimagesize($originalFile); //$newHeight = ($height / $width) * $newWidth; if($width>=$height) $pembagi=$width; else $pembagi=$height; $newWidth=ceil(($width * $newWidth)/$pembagi); $newHeight=ceil(($height * $newWidth)/$pembagi); $tmp = imagecreatetruecolor($newWidth, $newHeight); if($is_png) imagealphablending($tmp, false); imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); if($is_png) imagesavealpha($tmp, true); $fullDestinationFile=$targetFile; if (file_exists($fullDestinationFile)) { unlink($fullDestinationFile); } $image_save_func($tmp, $fullDestinationFile ); return file_exists($fullDestinationFile); } function resize_gambar_ratio($filename,$nama_gambar_baru,$ukuran_lebar_tinggi=100,$lokasi_folder){ $filename=trim($filename); $nama_gambar_baru=trim($nama_gambar_baru); $lokasi_folder=trim($lokasi_folder); if(strlen($filename)>0 && file_exists($filename) && strlen($nama_gambar_baru)>0 && strlen($lokasi_folder)>0){ $ukuran_baru=$ukuran_lebar_tinggi; $image_info=getimagesize($filename); $image_type=$image_info[2]; if($image_type == IMAGETYPE_JPEG) $myimage=imagecreatefromjpeg($filename); elseif($image_type == IMAGETYPE_GIF) $myimage=imagecreatefromgif($filename); else $myimage=imagecreatefrompng($filename); $lama_lebar=$image_info[0]; $lama_panjang=$image_info[1]; $thumb_width=$ukuran_lebar_tinggi; $thumb_height=$ukuran_lebar_tinggi; $aspect_original=$lama_lebar / $lama_panjang; $aspect_thumb=$thumb_width / $thumb_height; if($aspect_original>=$aspect_thumb){ $baru_panjang=$thumb_height; $baru_lebar=$lama_lebar / ($lama_panjang / $thumb_height); } else{ $baru_lebar=$thumb_width; $baru_panjang=$lama_panjang /($lama_lebar / $thumb_width); } $image_new=imagecreatetruecolor($thumb_width,$thumb_height); imagecopyresampled($image_new,$myimage, 0-($baru_lebar - $thumb_width) / 2, 0-($baru_panjang - $thumb_height) / 2, 0,0, $baru_lebar, $baru_panjang, $lama_lebar, $lama_panjang ); if($image_type == IMAGETYPE_JPEG) imagejpeg($image_new,$lokasi_folder."/".$nama_gambar_baru); elseif($image_type == IMAGETYPE_GIF) imagegif($image_new,$lokasi_folder."/".$nama_gambar_baru); else imagepng($image_new,$lokasi_folder."/".$nama_gambar_baru); imagedestroy($image_new); } } function valid_input_tanggal($tanggal="",&$msg="", &$hasil=""){ $tanggal=trim($tanggal); $tgl=$tanggal; $tanggal=str_replace(" ","",$tanggal); $tanggal=str_replace("-","",$tanggal); $tanggal=str_replace("/","",$tanggal); if(strlen($tanggal)<1) { $msg="Tanggal belum diisi"; return false; } if(preg_match("/[a-zA-Z]/",$tanggal)) { $msg="$tgl"; return false; } $panjang=strlen($tanggal); if(strlen($tanggal)<=5 || (($panjang % 2)==1) ) { $msg="($tgl)"; return false; } $t=0; $b=0; $h=0; if(strlen($tanggal)<=6) { $t=substr($tanggal,0,2); $b=substr($tanggal,2,2); $h=substr(date("Y"),0,2).substr($tanggal,4,2); } else{ $t=substr($tanggal,0,2); $b=substr($tanggal,2,2); $h=substr($tanggal,4,4); } $jumlah=($t*$b*$t); if($jumlah<=0 || !checkdate($b,$t,$h)){ $msg="($tgl)"; return false; } $hasil=$h."-".$b."-".$t; return true; } function tanggal_over_to($yourDate,$checkDate){ //$yourDate = Tanggal yang akan dicheck //$checkDate = Tanggal ke apakah tanggal 1 melebih tanggal 2 //format tanggal mysql 1999-12-31 Tahun Bulan Tanggal; $tgl=explode("-",$yourDate); $th_a=$tgl[0]*1; $bl_a=$tgl[1]*1; $tg_a=$tgl[2]*1; $tgl=explode("-",$checkDate); $th_b=$tgl[0]*1; $bl_b=$tgl[1]*1; $tg_b=$tgl[2]*1; if($tg_a<10) $tg_a="0".$tg_a; if($tg_b<10) $tg_b="0".$tg_b; if($bl_a<10) $bl_a="0".$bl_a; if($bl_b<10) $bl_b="0".$bl_b; $StrA=$th_a."/".$bl_a."/".$tg_a; /// tahun / bulan / tanggal $StrB=$th_b."/".$bl_b."/".$tg_b; /// tahun / bulan / tanggal $from=date("Y-m-d",strtotime($StrA)); $to=date("Y-m-d",strtotime($StrB)); //echo ".: \$from = ".$from." \$to = ".$to." :.
"; return ($from>$to); } function tanggal_low_from($yourDate,$checkDate){ //format tanggal mysql 1999-10-10; $tgl=explode("-",$yourDate); $th_a=$tgl[0]*1; $bl_a=$tgl[1]*1; $tg_a=$tgl[2]*1; $tgl=explode("-",$checkDate); $th_b=$tgl[0]*1; $bl_b=$tgl[1]*1; $tg_b=$tgl[2]*1; $A=$th_a."-".$bl_a."-".$tg_a; $B=$th_b."-".$bl_b."-".$tg_b; return tanggal_over_to($B,$A); } /// function clear chache image by pos sub str filename function ClearChache($path,$filename,$displayrep=false) { $path=trim($path); $filename=trim($filename); $nsource=trim(basename($filename)); if($displayrep) { echo "Path=".$path."
filename=$filename
"; } if(file_exists($path) && is_dir($path) && strlen($filename)>0 && strlen($nsource)>0) { if(substr($path,strlen($path)-1,1)!="/") { $path.="/"; if($displayrep) echo "Trailing slash $path
"; } $files = glob($path."*.*"); for ($i=0; $i"; if(strtoupper($ndel)==strtoupper($nsource)) { unlink($path.$image); if($displayrep) echo "Delete ".$ndel."
"; } else { if($displayrep) echo " Image = $image
source = $nsource ndel = $ndel
Is not some
"; } } } } function split_string($data_string,$limit_split){ return implode(' ', array_slice(explode(' ', $data_string), 0, $limit_split)); } function FilterAdd(&$source_string,$new_id){ if(isset($source_string) && isset($new_id) && !is_array($source_string) && !is_array($new_id) ) { if(strlen($source_string)>0) $source_string.=","; $source_string.=$new_id; } } function time_stamp($waktu_sesi,$iseng=false) { $selisih_waktu = time() - $waktu_sesi ; $detik = $selisih_waktu ; $menit = round($selisih_waktu / 60 ); $jam = round($selisih_waktu / 3600 ); $hari = round($selisih_waktu / 86400 ); $minggu = round($selisih_waktu / 604800 ); $bulan = round($selisih_waktu / 2419200 ); $tahun = round($selisih_waktu / 29030400 ); $hasil=""; if($iseng){ if($detik <= 60) { if($detik>0) $hasil="$detik "; $hasil.="sec"; } elseif($menit <= 60){ if($menit==1) $hasil="One minute"; else $hasil="$menit minutes"; } elseif($jam <= 24){ if($jam==1) $hasil="One hour"; else $hasil="$jam hours"; } elseif($hari <= 7){ if($hari==1) $hasil="One day"; else $hasil="$hari days"; } elseif($minggu <= 4){ if($minggu==1) $hasil="On week"; else $hasil="$minggu weeks"; } else if($bulan <= 12){ if($bulan==1) $hasil="One month"; else $hasil="$bulan months"; } else{ if($tahun==1) $hasil="One year"; else $hasil="$tahun years"; } } else{ if($detik<=0) $hasil="beberapa detik"; elseif($detik <= 60) $hasil="$detik detik"; elseif($menit <= 60){ if($menit==1) $hasil="Satu menit"; else $hasil="$menit menit"; } elseif($jam <= 24){ if($jam==1) $hasil="Satu jam"; else $hasil="$jam jam"; } elseif($hari <= 7){ if($hari==1) $hasil="Satu hari"; else $hasil="$hari hari"; } elseif($minggu <= 4){ if($minggu==1) $hasil="Satu minggu"; else $hasil="$minggu minggu"; } else if($bulan <= 12){ if($bulan==1) $hasil="Satu bulan"; else $hasil="$bulan bulan"; } else{ if($tahun==1) $hasil="Satu tahun"; else $hasil="$tahun tahun"; } } $hasil=trim($hasil); if(strlen($hasil)>=1){ if($iseng) $hasil.=" ago"; else $hasil.=" lalu"; } return $hasil; } function timestamp($waktu_sesi,$iseng=false){ return time_stamp($waktu_sesi,$iseng); } function get_my_ip(){ if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else{ $ip=$_SERVER['REMOTE_ADDR'];} if($ip=="::1" || strtoupper($ip)=="LOCALHOST") $ip="127.0.0.1"; return $ip; } function GetMyIp(){ return get_my_ip(); } function getRelativeRoot() { /*** get the document root ***/ $dr = $_SERVER['DOCUMENT_ROOT']; /*** get the current working directory ***/ $cwd = getcwd(); /*** return the path ***/ return str_replace($dr, '', $cwd); } function getBulan($bln){ switch ($bln){ case 1:return "Januari";break; case 2: return "Februari";break; case 3: return "Maret"; break; case 4: return "April"; break; case 5: return "Mei"; break; case 6: return "Juni"; break; case 7: return "Juli"; break; case 8: return "Agustus"; break; case 9: return "September"; break; case 10: return "Oktober"; break; case 11: return "November"; break; case 12: return "Desember"; break; } } function namabulan($blnnomor){ return getBulan($blnnomor); } function tgl_indo($tgl){ $tanggal = substr($tgl,8,2); $bulan = getBulan(substr($tgl,5,2)); $tahun = substr($tgl,0,4); return $tanggal.' '.$bulan.' '.$tahun; } function validasi($value){ $value=trim($value); $value=trim(stripslashes($value)); //if($this->IsMySQL()) $value=mysql_real_escape_string($value); //else $value=pg_escape_string($value); $value=str_replace("'","\"",$value); $value=trim($value); return $value; } function authRequest($strContent=''){ header("HTTP/1.1 401 Authorization Required"); $headerContent='

Authorization Required

401 Auth Required

'; echo $headerContent; echo $strContent; } function authNotFound($strContent=''){ header('HTTP/1.1 404 Not Found'); $headerContent='

Not Found

Page or data not found

404 Not Found

'; echo $headerContent; echo $strContent; } ?> */?> e-ProtrackBase GET("mod","",true); if(strlen($modul)<1) $modul="beranda"; if(strlen($modul)>0) $fileModul=$modul.".php"; $existsFileModul=(strlen($fileModul)>0) && file_exists(__DIR__ . "app.php/" .$fileModul); $bodyClass=""; if(strtolower($modul)=="beranda") $bodyClass="beranda"; ?>
if(self==top){ self='Ups!!!'; top='WAW'; } */?>