setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbConn->exec("SET NAMES UTF8"); } catch(PDOException $e) { echo $e->getMessage(); } /*** buat slug ***/ function buatSlug($teks){ $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $teks); return $slug; } /*** format tanggal ***/ function tanggal($tanggal) { // 2018-03-04 $tgl = substr($tanggal, 8, 2); // 04 $bln = substr($tanggal, 5, 2); // 10 $thn = substr($tanggal, 0, 4); // 2018 $bulan = array('Januari', 'Pebruari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'Nopember', 'Desember'); $tanggal = $tgl.' '.$bulan[$bln-1].' '.$thn; return $tanggal; } /*** nama hari ***/ function hari($tanggal) { $nama_hari = date('D', strtotime($tanggal)); switch($nama_hari) { case 'Mon': $nama_hari = 'Senin'; break; case 'Tue': $nama_hari = 'Selasa'; break; case 'Wed': $nama_hari = 'Rabu'; break; case 'Thu': $nama_hari = 'Kamis'; break; case 'Fri': $nama_hari = 'Jum\'at'; break; case 'Sat': $nama_hari = 'Sabtu'; break; case 'Sun': $nama_hari = 'Ahad'; break; default: $nama_hari = '?'; } return $nama_hari; } /*** tambah hit_lihat ***/ function tambahHitLihat($slug) { global $dbConn; $s="UPDATE unduhan SET hit_lihat=hit_lihat+1 WHERE slug='$slug'"; $q=$dbConn->prepare($s); $q->execute(); } /*** tambah hit_unduh ***/ function tambahHitUnduh($slug) { global $dbConn; $s="UPDATE unduhan SET hit_unduh=hit_unduh+1 WHERE slug='$slug'"; $q=$dbConn->prepare($s); $q->execute(); } /*** baca semua order DESC ***/ function bacaSemuaOrderDesc() { global $dbConn; $sql="SELECT * FROM unduhan ORDER BY id DESC"; $q=$dbConn->prepare($sql); $q->execute(); return $q; } /*** baca semua RANDOM LIMIT ***/ function bacaSemuaRandomLimit($limit) { global $dbConn; $sql="SELECT * FROM unduhan ORDER BY RAND() LIMIT $limit"; $q=$dbConn->prepare($sql); $q->execute(); return $q; } /*** baca detail ***/ function bacaDetail($slug) { global $dbConn; $sql="SELECT * FROM unduhan WHERE slug='$slug'"; $q=$dbConn->prepare($sql); $q->execute(); return $q; } /*** baca tautan unduhan ***/ function bacaTautan($slug) { global $dbConn; $sql="SELECT tautan_unduhan FROM unduhan WHERE slug='$slug'"; $q=$dbConn->prepare($sql); $q->execute(); return $q; } /*** 20220416 iklan studio.BHC.display ***/ function displayIklan() { echo ''; } /*** 20220416 minifying HTML output ***/ /*function minifyHTML($buffer) { $protected_parts = array('
,
','<,>'); //Bagian yang tidak diminify $extracted_values = array(); $i = 0; foreach ($protected_parts as $part) { $finished = false; $search_offset = $first_offset = 0; $end_offset = 1; $startend = explode(',', $part); if (count($startend) === 1) $startend[1] = $startend[0]; $len0 = strlen($startend[0]); $len1 = strlen($startend[1]); while ($finished === false) { $first_offset = strpos($buffer, $startend[0], $search_offset); if ($first_offset === false) $finished = true; else { $search_offset = strpos($buffer, $startend[1], $first_offset + $len0); $extracted_values[$i] = substr($buffer, $first_offset + $len0, $search_offset - $first_offset - $len0); $buffer = substr($buffer, 0, $first_offset + $len0).'$$#'.$i.'$$'.substr($buffer, $search_offset); $search_offset += $len1 + strlen((string)$i) + 5 - strlen($extracted_values[$i]); ++$i; } } } $buffer = preg_replace("/s/", " ", $buffer); $buffer = preg_replace("/s{2,}/", " ", $buffer); $replace = array('> <'=>'><', ' >'=>'>','< '=>'<',''$status"; //echo "$ikon
$status
"; } // fungsi login function login($user, $pass) { global $dbConn; $s="SELECT * FROM pengguna WHERE user=:user AND sandi=:sandi"; $q=$dbConn->prepare($s); $q->bindparam('user', $user); $q->bindparam('sandi', md5($pass)); $q->execute(); $r=$q->fetch(PDO::FETCH_OBJ); if($r->user===$user) { $_SESSION['user'] = $user; // $r->id_user $_SESSION['kode'] = TRUE; $_SESSION['terserah'] = "BangHajiDotCom"; $_SESSION['nama'] = $r->nama; $_SESSION['level'] = $r->level; header('location:dasbor.php'); } else { echo '
Gagal login!
'; } } // fungsi cek sesi function akses() { if(($_SESSION['kode']<>TRUE) && ($_SESSION['terserah']<>"BangHajiDotCom")) { header('location:index.php'); //header('location:ditolak.php'); } } // fungsi ganti_sandi() // 2018-11-05 11:01 by Muhammad Erfan // tambahan, ini tertinggal penjelasannya saat tatap muka ke-26 function ganti_sandi($s1, $s2, $sl) { global $dbConn; if($s1==$s2) { $s="SELECT * FROM pengguna WHERE user=:user"; $q=$dbConn->prepare($s); $q->bindparam(':user', $_SESSION['user']); $q->execute(); $r=$q->fetch(PDO::FETCH_OBJ); if($r->sandi==md5($sl)) { $sX="UPDATE pengguna SET sandi=:sandi WHERE user=:user"; $qX=$dbConn->prepare($sX); $qX->bindparam(':sandi', md5($s1)); $qX->bindparam(':user', $_SESSION['user']); $qX->execute(); //echo "Sandi berhasil diganti!"; header('location:keluar.php'); } else { $pesan="Sandi lama salah!"; } } else { $pesan="Sandi baru tidak sama!"; } echo '
'.$pesan.'
'; } // pesan CRUD function berhasil($kode) { switch($kode) { case 'c' : $pesan='menambah'; break; case 'u' : $pesan='mengubah'; break; case 'd' : $pesan='menghapus'; break; default : $pesan=''; } echo '
Berhasil '.$pesan.' data.
'; } function gagal($kode) { switch($kode) { case 'c' : $pesan='menambah'; break; case 'u' : $pesan='mengubah'; break; case 'd' : $pesan='menghapus'; break; default : $pesan=''; } echo '
Gagal '.$pesan.' data.
'; } // fungsi satuan bilangan function satuan($jumlah) { $jumlah=number_format($jumlah, 0, ',', '.'); return $jumlah; } // fungsi menghitung jumlah pembayaran function total() { global $dbConn; $s="SELECT SUM(jumlah) AS total FROM transaksi"; $q=$dbConn->prepare($s); $q->execute(); if($r=$q->fetch(PDO::FETCH_OBJ)) { return $r->total; } else { return 0; } } // fungsi menghitung jumlah record function jumlah_record($tabel, $kolom) { global $dbConn; $s="SELECT COUNT($kolom) AS hasil FROM $tabel"; $q=$dbConn->prepare($s); $q->execute(); $r=$q->fetch(PDO::FETCH_OBJ); return $r->hasil; } ?> BangHaji DotCom Studio

Gratis dari
BangHaji DotCom

Memudahkan ~ Mencerahkan ~ Mencerdaskan

Berbagi pengetahuan dan memberikan manfaat bagi orang lain melalui gambar, semoga menjadi amal berterusan.

Lihat Galeri Studio

Galeri Studio

Berbagi pengetahuan dan memberikan manfaat bagi orang lain melalui gambar, semoga menjadi amal berterusan.