<body onload="setInterval('window.location.reload()', 120000);">
Open a link in a new window with specified size
In order to open a link in a new window, add Javascript command onclick=”window.open(‘text-link.htm’, ‘name’,’width=600,height=400′) inside the <a> tag:
<a href=”../html-link.htm” target=”popup” onclick=”window.open(‘../html-link.htm’,’name’,’width=600,height=400′)”>Open page in new window</a>
or
<a href=”#” onclick=”window.open(‘../html-link.htm’,’name’, ‘width=600, height=400’)”>Open page in new window</a>
Source: http://www.rapidtables.com/web/html/link/html-link-new-window.htm
CSS Dropdown Menu Example
<style>
/* Style The Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> – needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
</style>
<div class=“dropdown”>
<button class=“dropbtn”>Dropdown</button>
<div class=“dropdown-content”>
<a href=“#”>Link 1</a>
<a href=“#”>Link 2</a>
<a href=“#”>Link 3</a>
</div>
</div>
how i can close popup window in php …?
echo “<script type=\”text/javascript\” charset=\”utf-8\”>window.self.close()</script>”;
PHP hapus files pada suatu direktori
<?php
// Specify the target directory and add forward slash
$dir = “myFolder/”;
// Open the directory
$dirHandle = opendir($dir);
// Loop over all of the files in the folder
while ($file = readdir($dirHandle)) {
// If $file is NOT a directory remove it
if(!is_dir($file)) {
unlink (“$dir”.”$file”); // unlink() deletes the files
}
}
// Close the directory
closedir($dirHandle);
?>
Mengambil 2 digits terakhir thn ini
var twoDigitsCurrentYear = parseInt(new Date().getFullYear().toString().substr(2,2));
Handling Keyboard Shortcuts in JavaScript
Enkripsi Script PHP Agar Source Code Web PHP Tidak Bisa Dibaca, Menggunakan Fungsi Eval dan Encode 64
Enkripsi Script PHP Agar Source Code Web PHP Tidak Bisa Dibaca, Menggunakan Fungsi Evel dan Encode 64 cukup mudah dilakukan akan tetapi hasilnya cukup efektif untuk menyembunyikan kode program PHP sehingga sulit dibaca atau diedit oleh orang awam.
Tetapi sebenarnya cara ini bukan benar-benar mengamankan Script PHP akan tetapi hanya membuat bingung atau istilahnya obfuscate PHP script sehingga susah untuk dipecahkan walaupun oleh orang yang paham (programmer) dan bahkan kemungkinan besar tidak akan bisa dibaca atau dipecahkan oleh orang awam.
Dalam contoh program yang penulis buat terdiri dari 4 buah file, dengan urutan sebagai berikut :
1. decoded.php (file PHP asli yang dapat dibaca)
2. php-encoder.php (script PHP untuk mengenkripsi script yang ada di file decoded.php menjadi file encoded.php.
3. encoded.php (file PHP yang sudah dienkripsi sehingga tidak dapat dibaca tetapi masih dapat dijalankan secara sempurna.
4. php-decoder.php (script PHP untuk mengembalikan script terenkripsi yang ada pada file encoded.php menjadi file script PHP yang dapat dibaca kembali menjadi file decoded.php.
Jadi urutan pengetesannya kira-kira sebagai berikut :
decoded.php -> php-encoder.php -> encoded.php -> php-decoder.php -> decoded.php -> dst.
Misalnya kita buat contoh file script PHP pada decoded.php sebagai berikut :
decoded.php :
<?php echo date(“Y-m-d”).” Hello World”; ?>
Jika dijalankan dengan cara memanggil halaman web tersebut dengan URL http://localhost/php-encoder/decoded.php akan tampil sebagai berikut :
Kemudian kita buat program PHP dengan nama php-encoder.php untuk mengenkripsi script php yang ada pada file decoded.php.
php-encoder.php :
<?php /*$php_code = ‘<?php echo date(“Y-m-d”).” Hello World”; ?>’;*/ $php_code = file_get_contents(“decoded.php”); //$_F=__FILE__; $_X=’?>’.$php_code; $_X=strtr($_X,’aouie123456′,’123456aouie’); $_X=base64_encode($_X); //$_R=ereg_replace(‘__FILE__’,”‘”.$_F.”‘”,$_X); $result = “<?php \$_F=__FILE__;\$_X='”.$_X.”‘; eval(base64_decode(‘JF9YPWJhc2U2NF9kZWNvZGUoJF9YKTskX1g9c3RydHIoJF9YLC cxMjM0NTZhb3VpZScsJ2FvdWllMTIzNDU2Jyk7JF9SPWVyZWdfcmVwbGFjZSgnX19GS UxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw==’));?>”; file_put_contents(“encoded.php”, $result); echo str_replace(‘<‘,’<’,str_replace(‘>’,’>’,$result)); ?>
Jika halaman php-encoder.php dijalankan dengan cara memanggil http://localhost/php-encoder/php-encoder.php. Hasilnya akan didapatkan file baru dengan nama encoded.php :
encoded.php :
<?php $_F=__FILE__;$_X=’Pz48P3BocA0KNWNoMiBkMXQ1KCJZLW0tZCIpLiIgSDVsbDIgVzJybGQiOw0KPz4=’; eval(base64_decode(‘JF9YPWJhc2U2NF9kZWNvZGUoJF9YKTskX1g9c3RydHIoJF9YLC cxMjM0NTZhb3VpZScsJ2FvdWllMTIzNDU2Jyk7JF9SPWVyZWdfcmVwbGFjZSgnX19GS UxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw==’));?>
Kenyataanya jika halaman encoded.php yang sudah terenkripsi dan tidak dapat dibaca ini dijalankan dengan cara menanggil http://localhost/php-encoder/encoded.php, ternyata hasilnya persis seperti ketika menjalankan halaman decoded.php.
Untuk mengembalikan file yang terlah terenkripsi menjadi script PHP semula, kita buat file php-decoder.php untuk mengubah file encoded.php kembali menjadi file decoded.php yang mampu dibaca kembali.
php-decoder.php
<?php $_F=__FILE__; $encode = file_get_contents(“encoded.php”); $_X = substr($encode, strpos($encode, “='”) + 2, strpos($encode, “‘;”) – strpos($encode, “='”) – 2); //$_X=’Pz48P3BocA0KNWNoMiAiSDVsbDIgVzJybGQiOw0KPz4=’; $_X=base64_decode($_X); $_X=strtr($_X,’123456aouie’,’aouie123456′); $_R=ereg_replace(‘__FILE__’,”‘”.$_F.”‘”,$_X); $_R=substr($_R, 2, strlen($_R)-2); file_put_contents(“decoded.php”, $_R); echo str_replace(‘<‘,’<’,str_replace(‘>’,’>’,$_R)); ?>
Ketika dijalankan dengan memanggil URL http://localhost/php-encoder/php-decoder.php maka akan dihasilkan file decoded.php kembali dengan isi persis seperti semula.
decoded.php
<?php echo date(“Y-m-d”).” Hello World”; ?>
Source Info: http://cariprogram.blogspot.com/2014/03/enkripsi-script-php-agar-source-code-php-tidak-bisa-dibaca.html
4 digits numbering
$num = 9;
$paddedNum = sprintf(“%04d”, $num);
echo $paddedNum; // prints 0009
MySQL SUM() function dengan GROUP BY
MySQL SUM() function retrieves the sum value of an expression which has undergone a grouping operation by GROUP BY clause.
SELECT cate_id,SUM(total_cost)
FROM purchase
GROUP BY cate_id;